diff options
author | Jeff Law <law@redhat.com> | 2014-01-15 11:13:52 -0700 |
---|---|---|
committer | Jeff Law <law@gcc.gnu.org> | 2014-01-15 11:13:52 -0700 |
commit | a6a2d67b0adf891b823b2b492a9d1cc98e09835a (patch) | |
tree | e0f2de4b26fbea16dedfb92ad4e491726101c7f8 /gcc/ree.c | |
parent | aefe4056bbf86cd0065d8c6bfcf22dad15536b20 (diff) | |
download | gcc-a6a2d67b0adf891b823b2b492a9d1cc98e09835a.zip gcc-a6a2d67b0adf891b823b2b492a9d1cc98e09835a.tar.gz gcc-a6a2d67b0adf891b823b2b492a9d1cc98e09835a.tar.bz2 |
re PR tree-optimization/59747 (wrong code at -Os and above on x86_64-linux-gnu in 64-bit mode)
PR tree-optimization/59747
* ree.c (find_and_remove_re): Properly handle case where a second
eliminated extension requires widening a copy created for elimination
of a prior extension.
(combine_set_extension): Ensure that the number of hard regs needed
for a destination register does not change when we widen it.
PR tree-optimization/59747
* gcc.c-torture/execute/pr59747.c: New test.
From-SVN: r206638
Diffstat (limited to 'gcc/ree.c')
-rw-r--r-- | gcc/ree.c | 21 |
1 files changed, 18 insertions, 3 deletions
@@ -297,6 +297,12 @@ combine_set_extension (ext_cand *cand, rtx curr_insn, rtx *orig_set) else new_reg = gen_rtx_REG (cand->mode, REGNO (SET_DEST (*orig_set))); + /* We're going to be widening the result of DEF_INSN, ensure that doing so + doesn't change the number of hard registers needed for the result. */ + if (HARD_REGNO_NREGS (REGNO (new_reg), cand->mode) + != HARD_REGNO_NREGS (REGNO (orig_src), GET_MODE (SET_DEST (*orig_set)))) + return false; + /* Merge constants by directly moving the constant into the register under some conditions. Recall that RTL constants are sign-extended. */ if (GET_CODE (orig_src) == CONST_INT @@ -1017,11 +1023,20 @@ find_and_remove_re (void) for (unsigned int i = 0; i < reinsn_copy_list.length (); i += 2) { rtx curr_insn = reinsn_copy_list[i]; + rtx def_insn = reinsn_copy_list[i + 1]; + + /* Use the mode of the destination of the defining insn + for the mode of the copy. This is necessary if the + defining insn was used to eliminate a second extension + that was wider than the first. */ + rtx sub_rtx = *get_sub_rtx (def_insn); rtx pat = PATTERN (curr_insn); - rtx new_reg = gen_rtx_REG (GET_MODE (SET_DEST (pat)), + rtx new_dst = gen_rtx_REG (GET_MODE (SET_DEST (sub_rtx)), REGNO (XEXP (SET_SRC (pat), 0))); - rtx set = gen_rtx_SET (VOIDmode, new_reg, SET_DEST (pat)); - emit_insn_after (set, reinsn_copy_list[i + 1]); + rtx new_src = gen_rtx_REG (GET_MODE (SET_DEST (sub_rtx)), + REGNO (SET_DEST (pat))); + rtx set = gen_rtx_SET (VOIDmode, new_dst, new_src); + emit_insn_after (set, def_insn); } /* Delete all useless extensions here in one sweep. */ |