From 5c422d1814c2c024ae90981eeff62cc81ef02338 Mon Sep 17 00:00:00 2001 From: rin Date: Sat, 7 Oct 2023 12:02:23 +0000 Subject: [PATCH] gcc.old: PR port-vax/57646 patch provided by Kalvis Duckmanton [9/21] A reload for the address of an operand's address should not use the same register as a reload of an operand's address if the two reloads are for different operands XXXRO: Hidden within ``#ifdef NB_FIX_VAX_BACKEND'' and enabled only for vax at the moment. --- external/gpl3/gcc.old/dist/gcc/reload.c | 44 +++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/external/gpl3/gcc.old/dist/gcc/reload.c b/external/gpl3/gcc.old/dist/gcc/reload.c index 2274f0985369..3a5b415fd9d4 100644 --- a/external/gpl3/gcc.old/dist/gcc/reload.c +++ b/external/gpl3/gcc.old/dist/gcc/reload.c @@ -4529,6 +4529,50 @@ find_reloads (rtx_insn *insn, int replace, int ind_levels, int live_known, } } +#if NB_FIX_VAX_BACKEND + /* + * Scan the reloads again looking for a case where there is + * precisely one RELOAD_FOR_OPERAND_ADDRESS reload and one + * RELOAD_FOR_OPADDR_ADDR reload BUT they are for different + * operands. choose_reload_regs assumes that the + * RELOAD_FOR_OPADDR_ADDR and RELOAD_FOR_OPERAND_ADDRESS reloads are + * a pair operating on the same operand and will choose the same + * register for both, which is not what is wanted. + */ + { + int n_operand_address_reloads = 0, + n_opaddr_addr_reloads = 0; + int reloadnum_for_operand_address_reload = -1, + reloadnum_for_opaddr_addr_reload = -1; + + for (i = 0; i < n_reloads; i++) + { + switch (rld[i].when_needed) + { + case RELOAD_FOR_OPADDR_ADDR: + n_opaddr_addr_reloads++; + reloadnum_for_opaddr_addr_reload = i; + break; + case RELOAD_FOR_OPERAND_ADDRESS: + n_operand_address_reloads++; + reloadnum_for_operand_address_reload = i; + break; + default: + break; + } + } + + if (n_operand_address_reloads == 1 + && n_opaddr_addr_reloads == 1 + && rld[reloadnum_for_opaddr_addr_reload].opnum + != rld[reloadnum_for_operand_address_reload].opnum) + { + rld[reloadnum_for_opaddr_addr_reload].when_needed + = RELOAD_FOR_OPERAND_ADDRESS; + } + } +#endif + /* See if we have any reloads that are now allowed to be merged because we've changed when the reload is needed to RELOAD_FOR_OPERAND_ADDRESS or RELOAD_FOR_OTHER_ADDRESS. Only