diff options
author | Jakub Jelinek <jakub@redhat.com> | 2025-02-15 16:45:21 -0700 |
---|---|---|
committer | Jeff Law <jlaw@ventanamicro.com> | 2025-02-15 16:49:12 -0700 |
commit | 42a22b801d4ad654e420495fafc4d29d113f00eb (patch) | |
tree | ce25a334b9275c7bbe1625da960650cb728849bb /gcc/fortran | |
parent | 8859dce9037bcb242819305f02e16edbea38923c (diff) | |
download | gcc-42a22b801d4ad654e420495fafc4d29d113f00eb.zip gcc-42a22b801d4ad654e420495fafc4d29d113f00eb.tar.gz gcc-42a22b801d4ad654e420495fafc4d29d113f00eb.tar.bz2 |
[PR tree-optimization/98028] Use relationship between operands to simplify SUB_OVERFLOW
So this is a fairly old regression, but with all the ranger work that's been
done, it's become easy to resolve.
The basic idea here is to use known relationships between two operands of a
SUB_OVERFLOW IFN to statically compute the overflow state and ultimately allow
turning the IFN into simple arithmetic (or for the tests in this BZ elide the
arithmetic entirely).
The regression example is when the two inputs are known equal. In that case
the subtraction will never overflow. But there's a few other cases we can
handle as well.
a == b -> never overflows
a > b -> never overflows when A and B are unsigned
a >= b -> never overflows when A and B are unsigned
a < b -> always overflows when A and B are unsigned
Bootstrapped and regression tested on x86, and regression tested on the usual
cross platforms.
This is Jakub's version of the vr-values.cc fix rather than Jeff's.
PR tree-optimization/98028
gcc/
* vr-values.cc (check_for_binary_op_overflow): Try to use a known
relationship betwen op0/op1 to statically determine overflow state.
gcc/testsuite
* gcc.dg/tree-ssa/pr98028.c: New test.
Diffstat (limited to 'gcc/fortran')
0 files changed, 0 insertions, 0 deletions