Fixed with r14-8796.
Tested on x86_64-unknown-linux-gnu, pushed.
PR middle-end/49330
* gcc.dg/torture/pr49330-1.c: New testcase.
* gcc.dg/torture/pr49330-2.c: Likewise.
---
gcc/testsuite/gcc.dg/torture/pr49330-1.c | 22 ++++++++++++++++++++++
gcc/testsuite/gcc.dg/torture/pr49330-2.c | 22 ++++++++++++++++++++++
2 files changed, 44 insertions(+)
create mode 100644 gcc/testsuite/gcc.dg/torture/pr49330-1.c
create mode 100644 gcc/testsuite/gcc.dg/torture/pr49330-2.c
diff --git a/gcc/testsuite/gcc.dg/torture/pr49330-1.c
b/gcc/testsuite/gcc.dg/torture/pr49330-1.c
new file mode 100644
index 00000000000..3b612a1635d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr49330-1.c
@@ -0,0 +1,22 @@
+/* { 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;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr49330-2.c
b/gcc/testsuite/gcc.dg/torture/pr49330-2.c
new file mode 100644
index 00000000000..61cd00dd52e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr49330-2.c
@@ -0,0 +1,22 @@
+/* { 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;
+}
--
2.51.0