diff options
author | Jakub Jelinek <jakub@redhat.com> | 2010-08-25 19:50:59 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2010-08-25 19:50:59 +0200 |
commit | ea9f1d6fe5de833116b1e34300c17082ba8e1704 (patch) | |
tree | d6f4d31331a09fc64f3ac667fefc9464a3dba946 /gcc/combine.c | |
parent | 932c9bffa0224eb16e061da1802f6f95fb23e7d3 (diff) | |
download | gcc-ea9f1d6fe5de833116b1e34300c17082ba8e1704.zip gcc-ea9f1d6fe5de833116b1e34300c17082ba8e1704.tar.gz gcc-ea9f1d6fe5de833116b1e34300c17082ba8e1704.tar.bz2 |
re PR rtl-optimization/44858 (likely integer wrong code bug)
PR rtl-optimization/44858
* combine.c (try_combine): If recog_for_combine added CLOBBERs to
newi2pat, make sure they don't affect newpat.
* gcc.c-torture/execute/pr44858.c: New test.
From-SVN: r163552
Diffstat (limited to 'gcc/combine.c')
-rw-r--r-- | gcc/combine.c | 53 |
1 files changed, 52 insertions, 1 deletions
diff --git a/gcc/combine.c b/gcc/combine.c index acff541..273a982 100644 --- a/gcc/combine.c +++ b/gcc/combine.c @@ -3725,7 +3725,58 @@ try_combine (rtx i3, rtx i2, rtx i1, rtx i0, int *new_direct_jump_p) i2_code_number = recog_for_combine (&newi2pat, i2, &new_i2_notes); if (i2_code_number >= 0) - insn_code_number = recog_for_combine (&newpat, i3, &new_i3_notes); + { + /* recog_for_combine might have added CLOBBERs to newi2pat. + Make sure NEWPAT does not depend on the clobbered regs. */ + if (GET_CODE (newi2pat) == PARALLEL) + { + for (i = XVECLEN (newi2pat, 0) - 1; i >= 0; i--) + if (GET_CODE (XVECEXP (newi2pat, 0, i)) == CLOBBER) + { + rtx reg = XEXP (XVECEXP (newi2pat, 0, i), 0); + if (reg_overlap_mentioned_p (reg, newpat)) + break; + } + + if (i >= 0) + { + /* CLOBBERs on newi2pat prevent it going first. + Try the other order of the insns if possible. */ + temp = newpat; + newpat = XVECEXP (newi2pat, 0, 0); + newi2pat = temp; +#ifdef HAVE_cc0 + if (reg_referenced_p (cc0_rtx, newpat)) + { + undo_all (); + return 0; + } +#endif + + i2_code_number = recog_for_combine (&newi2pat, i2, + &new_i2_notes); + if (i2_code_number < 0) + { + undo_all (); + return 0; + } + + if (GET_CODE (newi2pat) == PARALLEL) + for (i = XVECLEN (newi2pat, 0) - 1; i >= 0; i--) + if (GET_CODE (XVECEXP (newi2pat, 0, i)) == CLOBBER) + { + rtx reg = XEXP (XVECEXP (newi2pat, 0, i), 0); + if (reg_overlap_mentioned_p (reg, newpat)) + { + undo_all (); + return 0; + } + } + } + } + + insn_code_number = recog_for_combine (&newpat, i3, &new_i3_notes); + } } /* If it still isn't recognized, fail and change things back the way they |