diff options
author | Georg-Johann Lay <avr@gjlay.de> | 2012-02-01 11:35:34 +0000 |
---|---|---|
committer | Georg-Johann Lay <gjl@gcc.gnu.org> | 2012-02-01 11:35:34 +0000 |
commit | 07ad5438a12e26c3d361462ea5e3e3163b2928e0 (patch) | |
tree | 157006ab69f61f15564411baac61ae0b1b51e9d3 /gcc/combine.c | |
parent | 76a3962fe967dfde16d1b16460149d42680651b0 (diff) | |
download | gcc-07ad5438a12e26c3d361462ea5e3e3163b2928e0.zip gcc-07ad5438a12e26c3d361462ea5e3e3163b2928e0.tar.gz gcc-07ad5438a12e26c3d361462ea5e3e3163b2928e0.tar.bz2 |
re PR rtl-optimization/51374 ([avr] insn combine reorders volatile memory accesses)
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.
From-SVN: r183796
Diffstat (limited to 'gcc/combine.c')
-rw-r--r-- | gcc/combine.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/gcc/combine.c b/gcc/combine.c index beb980b..582db1f 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 |