fix range-ops equal/not_equal to not reuse the result range as intermediary.
value_query::value routines should pasa multi-range in as some other rangeop
routines build into this result, so we may need better precision.
gcc/
PR tree-optimization/97725
* range-op.cc (operator_equal::fold_range): Use new tmp value.
(operator_not_equal::fold_range): Ditto.
* value-query.cc (range_query::value_of_expr): Use int_range_max
not a value_range.
(range_query::value_on_edge): Ditto.
(range_query::value_of_stmt): Ditto.
gcc/testsuite/
* gcc.dg/pr97725.c: New.
{
// If ranges do not intersect, we know the range is not equal,
// otherwise we don't know anything for sure.
- r = op1;
- r.intersect (op2);
- if (r.undefined_p ())
+ int_range_max tmp = op1;
+ tmp.intersect (op2);
+ if (tmp.undefined_p ())
r = range_false (type);
else
r = range_true_and_false (type);
{
// If ranges do not intersect, we know the range is not equal,
// otherwise we don't know anything for sure.
- r = op1;
- r.intersect (op2);
- if (r.undefined_p ())
+ int_range_max tmp = op1;
+ tmp.intersect (op2);
+ if (tmp.undefined_p ())
r = range_true (type);
else
r = range_true_and_false (type);
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+int a;
+unsigned b;
+
+int main() {
+ if (a) {
+ goto L1;
+ while (1)
+ while (1) {
+ long e = -1L, g;
+ int f, h, i;
+ L1:
+ a = f;
+ L2:
+ g = e;
+ f = h || g;
+ e = ~(f & b);
+ if (i || g < -1L) {
+ ~(g || 0);
+ break;
+ }
+ goto L2;
+ }
+ }
+ return 0;
+}
range_query::value_of_expr (tree name, gimple *stmt)
{
tree t;
- value_range r;
+ int_range_max r;
if (!irange::supports_type_p (TREE_TYPE (name)))
return NULL_TREE;
range_query::value_on_edge (edge e, tree name)
{
tree t;
- value_range r;
+ int_range_max r;
if (!irange::supports_type_p (TREE_TYPE (name)))
return NULL_TREE;
range_query::value_of_stmt (gimple *stmt, tree name)
{
tree t;
- value_range r;
+ int_range_max r;
if (!name)
name = gimple_get_lhs (stmt);