summaryrefslogtreecommitdiffstats
path: root/contrib/gcc
diff options
context:
space:
mode:
authorpfg <pfg@FreeBSD.org>2014-01-06 00:52:39 +0000
committerpfg <pfg@FreeBSD.org>2014-01-06 00:52:39 +0000
commit9f411e6c042b772d5211d26218d08a70dd6ee217 (patch)
treead1dd94c99579a9ae59ccd5dfdde56e6437c09b9 /contrib/gcc
parent0d91dd56df43f981ecb8d8430e9461f290541756 (diff)
downloadFreeBSD-src-9f411e6c042b772d5211d26218d08a70dd6ee217.zip
FreeBSD-src-9f411e6c042b772d5211d26218d08a70dd6ee217.tar.gz
Fix optimization bug.
GCC-PR rtl-optimization/34628 * combine.c (try_combine): Stop and undo after the first combination if an autoincrement side-effect on the first insn has effectively been lost. The issue was detected in OpenBSD but their fix was not very good. Huge thanks to the upstream author, Eric Botcazou, for permitting the use of this patch under GPLv2. MFC after: 5 days
Diffstat (limited to 'contrib/gcc')
-rw-r--r--contrib/gcc/combine.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/contrib/gcc/combine.c b/contrib/gcc/combine.c
index f44b246..2053381 100644
--- a/contrib/gcc/combine.c
+++ b/contrib/gcc/combine.c
@@ -2370,12 +2370,17 @@ try_combine (rtx i3, rtx i2, rtx i1, int *new_direct_jump_p)
if (i1 && GET_CODE (newpat) != CLOBBER)
{
- /* Before we can do this substitution, we must redo the test done
- above (see detailed comments there) that ensures that I1DEST
- isn't mentioned in any SETs in NEWPAT that are field assignments. */
-
- if (! combinable_i3pat (NULL_RTX, &newpat, i1dest, NULL_RTX,
- 0, (rtx*) 0))
+ /* Check that an autoincrement side-effect on I1 has not been lost.
+ This happens if I1DEST is mentioned in I2 and dies there, and
+ has disappeared from the new pattern. */
+ if ((FIND_REG_INC_NOTE (i1, NULL_RTX) != 0
+ && !i1_feeds_i3
+ && dead_or_set_p (i2, i1dest)
+ && !reg_overlap_mentioned_p (i1dest, newpat))
+ /* Before we can do this substitution, we must redo the test done
+ above (see detailed comments there) that ensures that I1DEST
+ isn't mentioned in any SETs in NEWPAT that are field assignments. */
+ || !combinable_i3pat (NULL_RTX, &newpat, i1dest, NULL_RTX, 0, 0))
{
undo_all ();
return 0;
OpenPOWER on IntegriCloud