[gcc r17-2880] testsuite: Add phiopt factoring testcase for restrict

Andrea Pinski via Gcc-cvs <[email protected]> Sun, 2 Aug 2026 05:37:10 +0000 (GMT)
Newsgroups gmane.comp.gcc.cvs
Message-ID <[email protected]>
https://gcc.gnu.org/g:b3e78a17714908dbcd4b968a6c567ce75d424487

commit r17-2880-gb3e78a17714908dbcd4b968a6c567ce75d424487
Author: Andrea Pinski <[email protected]>
Date:   Sat Aug 1 16:25:22 2026 -0700

    testsuite: Add phiopt factoring testcase for restrict
    
    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 <[email protected]>

Diff:
---
 gcc/testsuite/gcc.dg/tree-ssa/factor_op_phi-restrict-1.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

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
index 000000000000..67baf8b2a4f0
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/factor_op_phi-restrict-1.c
@@ -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" } } */