]> git.ipfire.org Git - thirdparty/gcc.git/commit
[committed][PR rtl-optimization/116488] Fix SIGN_EXTEND source handling in ext-dce
authorJeff Law <jlaw@ventanamicro.com>
Mon, 21 Oct 2024 19:37:21 +0000 (13:37 -0600)
committerJeff Law <jlaw@ventanamicro.com>
Mon, 21 Oct 2024 19:37:21 +0000 (13:37 -0600)
commit36e91df7716d34aa5694533837551593ec28f22b
tree7822e0df179b0a439afdd5715af1b6044ad159b1
parentcb131a401b7489cc17e2d70420cf9a916515b3f6
[committed][PR rtl-optimization/116488] Fix SIGN_EXTEND source handling in ext-dce

A while back I noticed that the code to call carry_backpropagate was being
called after the optimization step.  Which seemed wrong, but at the time I
didn't have a testcase showing it as a problem.  Now I have 4 :-)

The way things used to work, the extension would be stripped away before
calling carry_backpropagte, meaning carry_backpropagate would never see a
SIGN_EXTENSION.  Thus the code trying to account for the sign extended bit was
never reached.

Getting that bit marked live is what's needed to fix these testcases. Fallout
is minor with just an adjustment needed to sensibly deal with vector modes in a
place where we didn't have them before.

I'm still somewhat concerned about this code.  Specifically whether or not we
can get in here with arbitrarily complex RTL, and if so do we need to recurse
down and look at those sub-expressions.

So while this patch fixes the most pressing issue, I wouldn't be terribly
surprised if we're back inside this code at some point.

Bootstrapped and regression tested on x86_64, ppc64le, riscv64, s390x, mips64,
loongarch, aarch64, m68k, alpha, hppa, sh4, sh4eb, perhaps something else that
I've forgotten...  Also tested on all the crosses in my tester.

PR rtl-optimization/116488
PR rtl-optimization/116579
PR rtl-optimization/116915
PR rtl-optimization/117226
gcc/
* ext-dce.cc (carry_backpropagate): Properly handle SIGN_EXTEND, add
ZERO_EXTEND handling as well.
(ext_dce_process_uses): Call carry_backpropagate before the optimization
step.

gcc/testsuite/
* gcc.dg/torture/pr116488.c: New test.
* gcc.dg/torture/pr116579.c: New test.
* gcc.dg/torture/pr116915.c: New test.
* gcc.dg/torture/pr117226.c: New test.
gcc/ext-dce.cc
gcc/testsuite/gcc.dg/torture/pr116488.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/torture/pr116579.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/torture/pr116915.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/torture/pr117226.c [new file with mode: 0644]