]> git.ipfire.org Git - thirdparty/gcc.git/commit
Improve factor_out_conditional_operation for conversions and constants
authorAndrew Pinski <pinskia@gmail.com>
Sun, 15 Oct 2023 19:15:38 +0000 (19:15 +0000)
committerAndrew Pinski <pinskia@gmail.com>
Tue, 24 Oct 2023 11:18:12 +0000 (11:18 +0000)
commit0fc13e8c0e39c51e82deb93f324d9d86ad8d7460
tree721e75dd8d73907e3da3fcffe07571304d783644
parent452c4f32373feb6b2c1c1d91b5ec6fe7e7ce0000
Improve factor_out_conditional_operation for conversions and constants

In the case of a NOP conversion (precisions of the 2 types are equal),
factoring out the conversion can be done even if int_fits_type_p returns
false and even when the conversion is defined by a statement inside the
conditional. Since it is a NOP conversion there is no zero/sign extending
happening which is why it is ok to be done here; we were trying to prevent
an extra sign/zero extend from being moved away from definition which no-op
conversions are not.

Bootstrapped and tested on x86_64-linux-gnu with no regressions.

gcc/ChangeLog:

PR tree-optimization/104376
PR tree-optimization/101541
* tree-ssa-phiopt.cc (factor_out_conditional_operation):
Allow nop conversions even if it is defined by a statement
inside the conditional.

gcc/testsuite/ChangeLog:

PR tree-optimization/101541
* gcc.dg/tree-ssa/phi-opt-39.c: New test.
gcc/testsuite/gcc.dg/tree-ssa/phi-opt-39.c [new file with mode: 0644]
gcc/tree-ssa-phiopt.cc