]> git.ipfire.org Git - thirdparty/gcc.git/commit
phiopt: Fix VCE moving by rewriting it into cast [PR116098]
authorAndrew Pinski <quic_apinski@quicinc.com>
Tue, 1 Oct 2024 18:34:00 +0000 (18:34 +0000)
committerAndrew Pinski <quic_apinski@quicinc.com>
Wed, 2 Oct 2024 17:16:01 +0000 (17:16 +0000)
commit1f619fe25925a5f79b9c33962e7a72e1f9fa4444
treefb81f4c957a59b18a60d81fa1f4d300f97359ae6
parent77c3ef08e946306329070ea6415abe7d9e328cd6
phiopt: Fix VCE moving by rewriting it into cast [PR116098]

Phiopt match_and_simplify might move a well defined VCE assign statement
from being conditional to being uncondtitional; that VCE might no longer
being defined. It will need a rewrite into a cast instead.

This adds the rewriting code to move_stmt for the VCE case.
This is enough to fix the issue at hand. It should also be using rewrite_to_defined_overflow
but first I need to move the check to see a rewrite is needed into its own function
and that is causing issues (see https://gcc.gnu.org/pipermail/gcc-patches/2024-September/663938.html).
Plus this version is easiest to backport.

Bootstrapped and tested on x86_64-linux-gnu.

PR tree-optimization/116098

gcc/ChangeLog:

* tree-ssa-phiopt.cc (move_stmt): Rewrite VCEs from integer to integer
types to case.

gcc/testsuite/ChangeLog:

* c-c++-common/torture/pr116098-2.c: New test.
* g++.dg/torture/pr116098-1.C: New test.

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