]> git.ipfire.org Git - thirdparty/gcc.git/commit
phiopt: Ignore some nop statements in heursics [PR116098]
authorAndrew Pinski <quic_apinski@quicinc.com>
Fri, 30 Aug 2024 17:36:24 +0000 (10:36 -0700)
committerAndrew Pinski <quic_apinski@quicinc.com>
Sat, 31 Aug 2024 16:16:40 +0000 (09:16 -0700)
commitceda727dafba6e05b510b5f8f4ccacfb507dc023
tree9896f3538c5f7be3db4a9936faba20aa967e35fe
parent457805cf5969c8a9a04f0c6e626946d952163929
phiopt: Ignore some nop statements in heursics [PR116098]

The heurstics that was added for PR71016, try to search to see
if the conversion was being moved away from its definition. The problem
is the heurstics would stop if there was a non GIMPLE_ASSIGN (and already ignores
debug statements) and in this case we would have a GIMPLE_LABEL that was not
being ignored. So we should need to ignore GIMPLE_NOP, GIMPLE_LABEL and GIMPLE_PREDICT.
Note this is now similar to how gimple_empty_block_p behaves.

Note this fixes the wrong code that was reported by moving the VCE (conversion) out before
the phiopt/match could convert it into an bit_ior and move the VCE out with the VCE being
conditionally valid.

Bootstrapped and tested on x86_64-linux-gnu.
Also built and tested for aarch64-linux-gnu.

PR tree-optimization/116098

gcc/ChangeLog:

* tree-ssa-phiopt.cc (factor_out_conditional_operation): Ignore
nops, labels and predicts for heuristic for conversion with a constant.

gcc/testsuite/ChangeLog:

* c-c++-common/torture/pr116098-1.c: New test.
* gcc.target/aarch64/csel-1.c: New test.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
gcc/testsuite/c-c++-common/torture/pr116098-1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/csel-1.c [new file with mode: 0644]
gcc/tree-ssa-phiopt.cc