]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
testsuite: Add phiopt factoring testcase for restrict
authorAndrea Pinski <andrew.pinski@oss.qualcomm.com>
Sat, 1 Aug 2026 23:25:22 +0000 (16:25 -0700)
committerAndrea Pinski <andrew.pinski@oss.qualcomm.com>
Sun, 2 Aug 2026 05:36:31 +0000 (22:36 -0700)
I missed this testcase when factoring of loads was added.
I thought it would be a good thing to add just to make sure
it is handled correctly.

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/factor_op_phi-restrict-1.c: New test.

Signed-off-by: Andrea Pinski <andrew.pinski@oss.qualcomm.com>
gcc/testsuite/gcc.dg/tree-ssa/factor_op_phi-restrict-1.c [new file with mode: 0644]

diff --git a/gcc/testsuite/gcc.dg/tree-ssa/factor_op_phi-restrict-1.c b/gcc/testsuite/gcc.dg/tree-ssa/factor_op_phi-restrict-1.c
new file mode 100644 (file)
index 0000000..67baf8b
--- /dev/null
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-phiopt-details-alias" } */
+/* Testcase to make sure restrict works correctly by zeroing out clique/base. */
+
+int
+f (int c, int * __restrict fp, int *q)
+{
+  int r;
+  if (c)
+    r = *fp;
+  else
+    r = *q;
+  return r + 1;
+}
+/* { dg-final { scan-tree-dump-times "changed to factor out load from" 1 "phiopt2" } } */
+/* { dg-final { scan-tree-dump-not "clique " "phiopt2" } } */