+2019-09-03 Jakub Jelinek <jakub@redhat.com>
+
+ PR tree-optimization/91597
+ * tree-vrp.c (extract_range_from_binary_expr): Remove unsafe
+ BIT_AND_EXPR optimization for pointers, even if both operand
+ ranges don't include NULL, the result can be NULL.
+
2019-09-02 Martin Liska <mliska@suse.cz>
Backport from mainline
+2019-09-03 Jakub Jelinek <jakub@redhat.com>
+
+ PR tree-optimization/91597
+ * gcc.c-torture/execute/pr91597.c: New test.
+
2019-09-02 Steven G. Kargl <kargl@gc.gnu.org>
PR fortran/91552
--- /dev/null
+/* PR tree-optimization/91597 */
+
+enum E { A, B, C };
+struct __attribute__((aligned (4))) S { enum E e; };
+
+enum E
+foo (struct S *o)
+{
+ if (((__UINTPTR_TYPE__) (o) & 1) == 0)
+ return o->e;
+ else
+ return A;
+}
+
+int
+bar (struct S *o)
+{
+ return foo (o) == B || foo (o) == C;
+}
+
+static inline void
+baz (struct S *o, int d)
+{
+ if (__builtin_expect (!bar (o), 0))
+ __builtin_abort ();
+ if (d > 2) return;
+ baz (o, d + 1);
+}
+
+void
+qux (struct S *o)
+{
+ switch (o->e)
+ {
+ case A: return;
+ case B: baz (o, 0); break;
+ case C: baz (o, 0); break;
+ }
+}
+
+struct S s = { C };
+
+int
+main ()
+{
+ qux (&s);
+ return 0;
+}
{
/* For pointer types, we are really only interested in asserting
whether the expression evaluates to non-NULL. */
- if (!range_includes_zero_p (&vr0) && !range_includes_zero_p (&vr1))
- vr->set_nonnull (expr_type);
- else if (range_is_null (&vr0) || range_is_null (&vr1))
+ if (range_is_null (&vr0) || range_is_null (&vr1))
vr->set_null (expr_type);
else
vr->set_varying ();