-
- Downloads
phi-opt: Improve factor heurstic with constants and conversions from bool [PR116890]
Take:
```
if (t_3(D) != 0)
goto <bb 3>;
else
goto <bb 4>;
<bb 3>
_8 = c_4(D) != 0;
_9 = (int) _8;
<bb 4>
# e_2 = PHI <_9(3), 0(2)>
```
We should factor out the conversion here as that will allow a simplfication to
`(t_3 != 0) & (c_4 != 0)`. Unlike most other types; `a ? b : CST` will simplify
for boolean result type to either `a | b` or `a & b` so allowing this conversion
for all operations will be always profitable.
Bootstrapped and tested on x86_64-linux-gnu with no regressions.
Note on the phi-opt-7.c testcase change, we are now able to optimize this
and remove the if due to the factoring out now so this is an improvement.
PR tree-optimization/116890
gcc/ChangeLog:
* tree-ssa-phiopt.cc (factor_out_conditional_operation): Conversions
from bool is also should be considered as wanting to happen.
gcc/testsuite/ChangeLog:
* gcc.dg/tree-ssa/phi-opt-7.c: Update testcase for no ifs left.
* gcc.dg/tree-ssa/phi-opt-42.c: New test.
* gcc.dg/tree-ssa/phi-opt-43.c: New test.
Signed-off-by:
Andrew Pinski <quic_apinski@quicinc.com>
Showing
- gcc/testsuite/gcc.dg/tree-ssa/phi-opt-42.c 19 additions, 0 deletionsgcc/testsuite/gcc.dg/tree-ssa/phi-opt-42.c
- gcc/testsuite/gcc.dg/tree-ssa/phi-opt-43.c 19 additions, 0 deletionsgcc/testsuite/gcc.dg/tree-ssa/phi-opt-43.c
- gcc/testsuite/gcc.dg/tree-ssa/phi-opt-7.c 3 additions, 3 deletionsgcc/testsuite/gcc.dg/tree-ssa/phi-opt-7.c
- gcc/tree-ssa-phiopt.cc 9 additions, 1 deletiongcc/tree-ssa-phiopt.cc
Loading
Please register or sign in to comment