range-op: Handle op?.undefined_p () in op[12]_range of comparisons [PR108647]
authorJakub Jelinek <jakub@redhat.com>
Fri, 3 Feb 2023 20:39:16 +0000 (21:39 +0100)
committerJakub Jelinek <jakub@redhat.com>
Fri, 3 Feb 2023 20:39:16 +0000 (21:39 +0100)
commite753080ab8abd4021381699bc7e857f5b4a083c4
tree2dce453e7284aa14f77445f510f1ba1cd534cf45
parent76f7f0eddcb7c418d1ec3dea3e2341ca99097301
range-op: Handle op?.undefined_p () in op[12]_range of comparisons [PR108647]

As mentioned in the PR, we ICE because lhs is singleton [0, 0]
or [1, 1] but op2 (or in other cases op1) is undefined and op?.*_bound ()
ICEs on those because there are no pairs for UNDEFINED.

The following patch makes us set r to varying or return false in those
cases.

2023-02-03  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/108647
* range-op.cc (operator_equal::op1_range,
operator_not_equal::op1_range): Don't test op2 bound
equality if op2.undefined_p (), instead set_varying.
(operator_lt::op1_range, operator_le::op1_range,
operator_gt::op1_range, operator_ge::op1_range): Return false if
op2.undefined_p ().
(operator_lt::op2_range, operator_le::op2_range,
operator_gt::op2_range, operator_ge::op2_range): Return false if
op1.undefined_p ().

* g++.dg/torture/pr108647.C: New test.
gcc/range-op.cc
gcc/testsuite/g++.dg/torture/pr108647.C [new file with mode: 0644]