[PR tree-optimization/107732] [range-ops] Handle attempt to abs() negatives.
authorAldy Hernandez <aldyh@redhat.com>
Thu, 17 Nov 2022 15:47:17 +0000 (16:47 +0100)
committerAldy Hernandez <aldyh@redhat.com>
Thu, 17 Nov 2022 17:42:56 +0000 (18:42 +0100)
commit4e306222f442f8d4c6fc6da997ab756a5e43e36e
tree7f97f1642131f7f6b94aba3359a887afa5482dc1
parentf9ed1d24ee46f5ca759c35a1f51fa163d7529ea6
[PR tree-optimization/107732] [range-ops] Handle attempt to abs() negatives.

The threader is creating a scenario where we are trying to solve:

[NEGATIVES] = abs(x)

While solving this we have an intermediate value of UNDEFINED because
we have no positive numbers.  But then we try to union the negative
pair to the final result by querying the bounds.  Since neither
UNDEFINED nor NAN have bounds, they need to be specially handled.

PR tree-optimization/107732

gcc/ChangeLog:

* range-op-float.cc (foperator_abs::op1_range): Early exit when
result is undefined.

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/pr107732.c: New test.
gcc/range-op-float.cc
gcc/testsuite/gcc.dg/tree-ssa/pr107732.c [new file with mode: 0644]