]> git.ipfire.org Git - thirdparty/gcc.git/commit
tree-optimization/118521 - bogus diagnostic from unreachable code
authorRichard Biener <rguenther@suse.de>
Thu, 20 Feb 2025 12:37:05 +0000 (13:37 +0100)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 20 Feb 2025 14:18:11 +0000 (15:18 +0100)
commita2755339c6c9832467c573d956e91565943ecdc1
treee5bbee2e13959e0464ba6f73daa3ea9bd832630d
parenta42374b60884d9ac4ff47e7787b32142526ac666
tree-optimization/118521 - bogus diagnostic from unreachable code

When SCCP does final value replacement we end up with unfolded IL like

__result_274 = _150 + 1;
...
__new_finish_106 = __result_274 + 3;  <-- from SCCP
_115 = _150 + 4;
if (__new_finish_106 != _115)

this does only get rectified by the next full folding which happens
in forwprop4 which is after the strlen pass emitting the unwanted
diagnostic.  The following mitigates this case in a similar way as
r15-7472 did for PR118817 - by ensuring we have the IL folded.
This is done by simply folding all immediate uses of the former
PHI def that SCCP replaces.  All other more general approaches have
too much fallout at this point.

PR tree-optimization/118521
* tree-scalar-evolution.cc (final_value_replacement_loop):
Fold uses of the replaced PHI def.

* g++.dg/torture/pr118521.C: New testcase.
gcc/testsuite/g++.dg/torture/pr118521.C [new file with mode: 0644]
gcc/tree-scalar-evolution.cc