[Bug rtl-optimization/102306] Volatile pointer dereferenced twice

2021-09-14 Thread ebotcazou at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102306

--- Comment #5 from Eric Botcazou  ---
Created attachment 51460
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51460=edit
Tentative fix

To be tested.

[Bug rtl-optimization/102306] Volatile pointer dereferenced twice

2021-09-14 Thread ebotcazou at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102306

--- Comment #4 from Eric Botcazou  ---
There is substantial checking for volatile references in can_combine_p but it
implicitly assumes that the combination reduces the number of instructions.

[Bug rtl-optimization/102306] Volatile pointer dereferenced twice

2021-09-14 Thread ebotcazou at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102306

Eric Botcazou  changed:

   What|Removed |Added

 CC||ebotcazou at gcc dot gnu.org

--- Comment #3 from Eric Botcazou  ---
Trying 6 -> 7:
6: r109:QI=[%i0:SI]
  REG_DEAD %i0:SI
7: r112:SI=zero_extend(r109:QI)
Failed to match this instruction:
(parallel [
(set (reg:SI 112 [ _1+-3 ])
(zero_extend:SI (mem/v:QI (reg:SI 24 %i0 [ a ]) [0 *a_5(D)+0 S1
A8])))
(set (reg:QI 109 [ _1 ])
(mem/v:QI (reg:SI 24 %i0 [ a ]) [0 *a_5(D)+0 S1 A8]))
])
Failed to match this instruction:
(parallel [
(set (reg:SI 112 [ _1+-3 ])
(zero_extend:SI (mem/v:QI (reg:SI 24 %i0 [ a ]) [0 *a_5(D)+0 S1
A8])))
(set (reg:QI 109 [ _1 ])
(mem/v:QI (reg:SI 24 %i0 [ a ]) [0 *a_5(D)+0 S1 A8]))
])
Successfully matched this instruction:
(set (reg:QI 109 [ _1 ])
(mem/v:QI (reg:SI 24 %i0 [ a ]) [0 *a_5(D)+0 S1 A8]))
Successfully matched this instruction:
(set (reg:SI 112 [ _1+-3 ])
(zero_extend:SI (mem/v:QI (reg:SI 24 %i0 [ a ]) [0 *a_5(D)+0 S1 A8])))
allowing combination of insns 6 and 7
original costs 4 + 4 = 8
replacement costs 4 + 4 = 8
modifying insn i2 6: r109:QI=[%i0:SI]
deferring rescan insn with uid = 6.
modifying insn i3 7: r112:SI=zero_extend([%i0:SI])
  REG_DEAD %i0:SI
deferring rescan insn with uid = 7.

This should probably have been prevented in two different ways: 1) the volatile
load and 2) the equal cost for a 2->2 combination.

[Bug rtl-optimization/102306] Volatile pointer dereferenced twice

2021-09-13 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102306

Richard Biener  changed:

   What|Removed |Added

  Component|target  |rtl-optimization

--- Comment #2 from Richard Biener  ---
But it's definitely combine duplicating the volatile MEM:

-6: r109:QI=[r111:SI]
-  REG_DEAD r111:SI
-7: r112:SI=zero_extend(r109:QI)
+6: r109:QI=[%i0:SI]
+7: r112:SI=zero_extend([%i0:SI])
+  REG_DEAD %i0:SI