]> git.ipfire.org Git - thirdparty/gcc.git/commit
rtlanal: Fix set_noop_p for volatile loads or stores [PR114768]
authorJakub Jelinek <jakub@redhat.com>
Fri, 19 Apr 2024 06:47:53 +0000 (08:47 +0200)
committerJakub Jelinek <jakub@redhat.com>
Thu, 20 Jun 2024 13:07:41 +0000 (15:07 +0200)
commit1fc4a915c797d3a98a327dfc546948c5879336e0
treef7135af16f26711731bd091caa72f063bf0b0d1d
parent2e932260ca4f2ba2549eb42d60e701d2244dab74
rtlanal: Fix set_noop_p for volatile loads or stores [PR114768]

On the following testcase, combine propagates the mem/v load into mem store
with the same address and then removes it, because noop_move_p says it is a
no-op move.  If it was the other way around, i.e. mem/v store and mem load,
or both would be mem/v, it would be kept.
The problem is that rtx_equal_p never checks any kind of flags on the rtxes
(and I think it would be quite dangerous to change it at this point), and
set_noop_p checks side_effects_p on just one of the operands, not both.
In the MEM <- MEM set, it only checks it on the destination, in
store to ZERO_EXTRACT only checks it on the source.

The following patch adds the missing side_effects_p checks.

2024-04-19  Jakub Jelinek  <jakub@redhat.com>

PR rtl-optimization/114768
* rtlanal.c (set_noop_p): Don't return true for MEM <- MEM
sets if src has side-effects or for stores into ZERO_EXTRACT
if ZERO_EXTRACT operand has side-effects.

* gcc.dg/pr114768.c: New test.

(cherry picked from commit 9f295847a9c32081bdd0fe908ffba58e830a24fb)
gcc/rtlanal.c
gcc/testsuite/gcc.dg/pr114768.c [new file with mode: 0644]