Fixed with r14-8796.
PR middle-end/49330
* gcc.dg/torture/pr49330-1.c: New testcase.
* gcc.dg/torture/pr49330-2.c: Likewise.
--- /dev/null
+/* { dg-do run } */
+
+#include <stdint.h>
+
+int x, y;
+int __attribute__((noipa)) foo()
+{
+ uintptr_t px = (uintptr_t) &x;
+ uintptr_t py = (uintptr_t) &y;
+ volatile uintptr_t d = px - py;
+ uintptr_t p = py + d;
+ x = 1;
+ *(int *) p = 2;
+ return x;
+}
+
+int main()
+{
+ if (foo () != 2)
+ __builtin_abort ();
+ return 0;
+}
--- /dev/null
+/* { dg-do run } */
+
+#include <stdio.h>
+
+int a;
+
+void __attribute__((noipa))
+foo()
+{
+ unsigned long b = (unsigned long) &a - 134518548;
+ volatile unsigned long c = b;
+ if (c == 0) {
+ if (b != 0) __builtin_abort ();
+ }
+ a = c;
+}
+
+int main()
+{
+ foo ();
+ return 0;
+}