]> git.ipfire.org Git - thirdparty/gcc.git/commit
Rewrite VCEs of integral types [PR116939]
authorAndrew Pinski <quic_apinski@quicinc.com>
Thu, 17 Oct 2024 05:18:36 +0000 (05:18 +0000)
committerAndrew Pinski <quic_apinski@quicinc.com>
Thu, 8 May 2025 07:23:28 +0000 (07:23 +0000)
commitf2bb7ffe84840d8f4ba6c0e5acdbbad8ca9d3603
treef5832246ca1ac02d8060eafbd90a26c0c196e649
parentb38e3a7196d25bc8bcb1fe55da7663745cea9470
Rewrite VCEs of integral types [PR116939]

Like the patch to phiopt (r15-4033-g1f619fe25925a5f7), this adds rewriting
of VCE to gimple_with_undefined_signed_overflow/rewrite_to_defined_overflow.
In the case of moving VCE of a bool from being conditional to unconditional,
it needs to be rewritten to not to use VCE but a normal cast. pr120122-1.c is
an example of where LIM needs this rewriting. The precision of the outer type
needs to be less then the inner one.

This also renames gimple_with_undefined_signed_overflow to gimple_needing_rewrite_undefined
and rewrite_to_defined_overflow to rewrite_to_defined_unconditional as they will be doing
more than just handling signed overflow.

Changes since v1:
* v2: rename the functions.
* v3: Add check for precision to be smaller.

Bootstrappd and tested on x86_64-linux-gnu.

PR tree-optimization/120122
PR tree-optimization/116939

gcc/ChangeLog:

* gimple-fold.h (gimple_with_undefined_signed_overflow): Rename to ..
(rewrite_to_defined_overflow): This.
(gimple_needing_rewrite_undefined): Rename to ...
(rewrite_to_defined_unconditional): this.
* gimple-fold.cc (gimple_with_undefined_signed_overflow): Rename to ...
(gimple_needing_rewrite_undefined): This. Return true for VCE with integral
types of smaller precision.
(rewrite_to_defined_overflow): Rename to ...
(rewrite_to_defined_unconditional): This. Handle VCE rewriting to a cast.
* tree-if-conv.cc: s/gimple_with_undefined_signed_overflow/gimple_needing_rewrite_undefined/
s/rewrite_to_defined_overflow/rewrite_to_defined_unconditional.
* tree-scalar-evolution.cc: Likewise
* tree-ssa-ifcombine.cc: Likewise.
* tree-ssa-loop-im.cc: Likewise.
* tree-ssa-loop-split.cc: Likewise.
* tree-ssa-reassoc.cc: Likewise.

gcc/testsuite/ChangeLog:

* gcc.dg/torture/pr120122-1.c: New test.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
gcc/gimple-fold.cc
gcc/gimple-fold.h
gcc/testsuite/gcc.dg/torture/pr120122-1.c [new file with mode: 0644]
gcc/tree-if-conv.cc
gcc/tree-scalar-evolution.cc
gcc/tree-ssa-ifcombine.cc
gcc/tree-ssa-loop-im.cc
gcc/tree-ssa-loop-split.cc
gcc/tree-ssa-reassoc.cc