https://gcc.gnu.org/g:f845b6995580f7de03b43fef1ad864e3ae28d590
commit r16-7282-gf845b6995580f7de03b43fef1ad864e3ae28d590 Author: Richard Biener <[email protected]> Date: Wed Feb 4 14:44:51 2026 +0100 middle-end/49330 - add testcases for fixed bug Fixed with r14-8796. PR middle-end/49330 * gcc.dg/torture/pr49330-1.c: New testcase. * gcc.dg/torture/pr49330-2.c: Likewise. Diff: --- gcc/testsuite/gcc.dg/torture/pr49330-1.c | 22 ++++++++++++++++++++++ gcc/testsuite/gcc.dg/torture/pr49330-2.c | 22 ++++++++++++++++++++++ 2 files changed, 44 insertions(+) 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 000000000000..3b612a1635d8 --- /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 000000000000..61cd00dd52e1 --- /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; +}
