So it turns out VN can't handle any kind of recursion for match. In this
case we have `b = a & -1` and we try to match a as being zero_one_valued_p
and VN returns b as being the value and we just go into an infinite loop at
this point.
OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.
Note genmatch should warn (or error out) if this gets detected so I filed PR 111446
which I will be looking into next week or the week after so we don't run into
this issue again.
PR tree-optimization/111442
gcc/ChangeLog:
* match.pd (zero_one_valued_p): Have the bit_and match not be
recursive.
gcc/testsuite/ChangeLog:
* gcc.c-torture/compile/pr111442-1.c: New test.
/* (a&1) is always [0,1] too. This is useful again when
the range is not known. */
+/* Note this can't be recursive due to VN handling of equivalents,
+ VN and would cause an infinite recursion. */
(match zero_one_valued_p
- (bit_and:c@0 @1 zero_one_valued_p))
+ (bit_and:c@0 @1 integer_onep)
+ (if (INTEGRAL_TYPE_P (type))))
/* A conversion from an zero_one_valued_p is still a [0,1].
This is useful when the range of a variable is not known */
--- /dev/null
+
+int *a, b;
+int main() {
+ int d = 1, e;
+ if (d)
+ e = a ? 0 % 0 : 0;
+ if (d)
+ a = &d;
+ d = -1;
+ b = d & e;
+ b = 2 * e ^ 1;
+ return 0;
+}