From: gjl Date: Wed, 1 Feb 2012 11:35:34 +0000 (+0000) Subject: gcc/ X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5dcaa548b2384c5c5a7fe4dafefd4e61fa627ccf;p=thirdparty%2Fgcc.git gcc/ PR rtl-optimization/51374 * combine.c (can_combine_p): Don't allow volatile_refs_p insns to cross other volatile_refs_p insns. gcc/testsuite/ PR rtl-optimization/51374 * testsuite/gcc.target/avr/torture/pr51374-1.c: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@183796 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 32a86f0ea06a..60c43a61bc53 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2012-02-01 Georg-Johann Lay + + PR rtl-optimization/51374 + * combine.c (can_combine_p): Don't allow volatile_refs_p insns + to cross other volatile_refs_p insns. + 2012-02-01 Richard Guenther * doc/invoke.texi (fno-inline): Clarify documentation. diff --git a/gcc/combine.c b/gcc/combine.c index beb980b35705..582db1ffe0da 100644 --- a/gcc/combine.c +++ b/gcc/combine.c @@ -1700,6 +1700,7 @@ can_combine_p (rtx insn, rtx i3, rtx pred ATTRIBUTE_UNUSED, rtx link; #endif bool all_adjacent = true; + int (*is_volatile_p) (const_rtx); if (succ) { @@ -1948,11 +1949,17 @@ can_combine_p (rtx insn, rtx i3, rtx pred ATTRIBUTE_UNUSED, && REG_P (dest) && REGNO (dest) < FIRST_PSEUDO_REGISTER) return 0; - /* If there are any volatile insns between INSN and I3, reject, because - they might affect machine state. */ + /* If INSN contains volatile references (specifically volatile MEMs), + we cannot combine across any other volatile references. + Even if INSN doesn't contain volatile references, any intervening + volatile insn might affect machine state. */ + is_volatile_p = volatile_refs_p (PATTERN (insn)) + ? volatile_refs_p + : volatile_insn_p; + for (p = NEXT_INSN (insn); p != i3; p = NEXT_INSN (p)) - if (INSN_P (p) && p != succ && p != succ2 && volatile_insn_p (PATTERN (p))) + if (INSN_P (p) && p != succ && p != succ2 && is_volatile_p (PATTERN (p))) return 0; /* If INSN contains an autoincrement or autodecrement, make sure that diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 23a0ef48be6e..18a727699471 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2012-02-01 Georg-Johann Lay + + PR rtl-optimization/51374 + * testsuite/gcc.target/avr/torture/pr51374-1.c: New. + 2012-01-31 Tobias Burnus PR fortran/52024 diff --git a/gcc/testsuite/gcc.target/avr/torture/pr51374-1.c b/gcc/testsuite/gcc.target/avr/torture/pr51374-1.c new file mode 100644 index 000000000000..b31d17363cdf --- /dev/null +++ b/gcc/testsuite/gcc.target/avr/torture/pr51374-1.c @@ -0,0 +1,14 @@ +/* PR rtl-optimization/51374 */ +/* { dg-do compile } */ + +void vector_18 (void) +{ + extern char slot; + unsigned char status = (*(volatile unsigned char*) 0x2B); + unsigned char data = (*(volatile unsigned char*) 0x2C); + + if (status & 0x10) + slot = 0; +} + +/* { dg-final { scan-assembler-not "\tsbic " } } */