}
/* If &X->a is equal to X, the range of X is the result. */
if (off_cst && known_eq (off, 0))
- return true;
+ return true;
else if (flag_delete_null_pointer_checks
&& !TYPE_OVERFLOW_WRAPS (TREE_TYPE (expr)))
{
- /* For -fdelete-null-pointer-checks -fno-wrapv-pointer we don't
- allow going from non-NULL pointer to NULL. */
- if(!range_includes_zero_p (&r))
- return true;
+ /* For -fdelete-null-pointer-checks -fno-wrapv-pointer we don't
+ allow going from non-NULL pointer to NULL. */
+ if (!range_includes_zero_p (&r))
+ {
+ /* We could here instead adjust r by off >> LOG2_BITS_PER_UNIT
+ using POINTER_PLUS_EXPR if off_cst and just fall back to
+ this. */
+ r = range_nonzero (TREE_TYPE (gimple_assign_rhs1 (stmt)));
+ return true;
+ }
}
/* If MEM_REF has a "positive" offset, consider it non-NULL
always, for -fdelete-null-pointer-checks also "negative"
--- /dev/null
+/* PR tree-optimization/103255 */
+
+struct H
+{
+ unsigned a;
+ unsigned b;
+ unsigned c;
+};
+
+#if __SIZEOF_POINTER__ >= 4
+#define ADDR 0x400000
+#else
+#define ADDR 0x4000
+#endif
+#define OFF 0x20
+
+int
+main ()
+{
+ struct H *h = 0;
+ unsigned long o;
+ volatile int t = 1;
+
+ for (o = OFF; o <= OFF; o += 0x1000)
+ {
+ struct H *u;
+ u = (struct H *) (ADDR + o);
+ if (t)
+ {
+ h = u;
+ break;
+ }
+ }
+
+ if (h == 0)
+ return 0;
+ unsigned *tt = &h->b;
+ if ((__SIZE_TYPE__) tt != (ADDR + OFF + __builtin_offsetof (struct H, b)))
+ __builtin_abort ();
+ return 0;
+}