[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.