Fix 101256: Wrong code due to range incorrect from PHI-OPT
authorAndrew Pinski <apinski@marvell.com>
Tue, 29 Jun 2021 21:30:34 +0000 (14:30 -0700)
committerAndrew Pinski <apinski@marvell.com>
Tue, 6 Jul 2021 07:32:40 +0000 (00:32 -0700)
commit51abfb6a893c87dbf84a33009b6cd6dbd25d66f1
tree3ba29867c6a85c8d476306977787785c5f2ffb70
parentd7e3855d5dd8c001bb65dc7da1cda0249bfc2986
Fix 101256: Wrong code due to range incorrect from PHI-OPT

So the problem here is that replace_phi_edge_with_variable
will copy range information to a already (not newly) defined
ssa name.  This causes wrong code later on.
This fixes the problem by require the new ssa name to
be defined in the same bb as the conditional that is
about to be deleted.

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

Changes from v1:
* this is a simplification of what was trying to be done before.

gcc/ChangeLog:

PR tree-optimization/101256
* dbgcnt.def (phiopt_edge_range): New counter.
* tree-ssa-phiopt.c (replace_phi_edge_with_variable):
Check to make sure the new name is defined in the same
bb as the conditional before duplicating range info.
Also add debug counter.

gcc/testsuite/ChangeLog:

PR tree-optimization/101256
* g++.dg/torture/pr101256.C: New test.
gcc/dbgcnt.def
gcc/testsuite/g++.dg/torture/pr101256.C [new file with mode: 0644]
gcc/tree-ssa-phiopt.c