[committed] [PR rtl-optimization/101188] Fix reload_cse_move2add ignoring clobbers
commitae193f9008e02683e27f3c87f3b06f38e103b1d0
authorJeff Law <jlaw@ventanamicro.com>
Mon, 12 Jun 2023 18:52:10 +0000 (12 12:52 -0600)
committerJeff Law <jlaw@ventanamicro.com>
Mon, 12 Jun 2023 18:52:10 +0000 (12 12:52 -0600)
treef1b3cfc1ef80d7bdb0ab7bbf00dcf983215dbe2c
parent9eb757d11746c006c044ff45538b956be7f5859c
[committed] [PR rtl-optimization/101188] Fix reload_cse_move2add ignoring clobbers

So as Georg-Johann discusses in the BZ, reload_cse_move2add can generate
 incorrect code when optimizing code with clobbers.  Specifically in the
case where we try to optimize a sequence of 4 operations down to 3
operations we can reset INSN to the next instruction and continue the loop.

That skips the code to invalidate objects based on things like REG_INC
nodes, stack pushes and most importantly clobbers attached to the current
insn.

This patch factors all of the invalidation code used by reload_cse_move2add
into a new function and calls it at the appropriate time.

Georg-Johann has confirmed this patch fixes his avr bug and I've had it in
my tester over the weekend.  It's bootstrapped and regression tested on
aarch64, m68k, sh4, alpha and hppa.  It's also regression tested successfully
on a wide variety of other targets.

gcc/
PR rtl-optimization/101188
* postreload.cc (reload_cse_move2add_invalidate): New function,
extracted from...
(reload_cse_move2add): Call reload_cse_move2add_invalidate.

gcc/testsuite
PR rtl-optimization/101188
* gcc.c-torture/execute/pr101188.c: New test
gcc/postreload.cc
gcc/testsuite/gcc.c-torture/execute/pr101188.c [new file with mode: 0644]