diff --git a/gcc/match.pd b/gcc/match.pd index a405c9ff6f82fa2c440f3ee61fab8bab90179468..bef513aaa3f0acbe55565e5efc232a042b456d26 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -2183,8 +2183,11 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) /* (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 */ diff --git a/gcc/testsuite/gcc.c-torture/compile/pr111442-1.c b/gcc/testsuite/gcc.c-torture/compile/pr111442-1.c new file mode 100644 index 0000000000000000000000000000000000000000..5814ee938de022a34ef4ef979b3cd87a3429e619 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr111442-1.c @@ -0,0 +1,13 @@ + +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; +}