https://gcc.gnu.org/g:d1e7f3a6c149b6fa058ce3083c36b8a5c404af5c

commit r15-3871-gd1e7f3a6c149b6fa058ce3083c36b8a5c404af5c
Author: Andrew Pinski <quic_apin...@quicinc.com>
Date:   Mon Sep 23 19:17:42 2024 -0700

    Add an alternative testcase for PR 70740
    
    While looking into improving phiprop, I noticed that
    the current pr70740.c testcase was being optimized almost
    all the way before phiprop because the addresses were considered
    the same; the arrays were all zero in size.
    
    This adds an alternative testcase which changes the array sizes to be 1
    and phiprop can and will act on this testcase now and the fix which was
    being tested is actually tested now.
    
    Tested on x86_64-linux-gnu.
    
            PR tree-optimization/70740
    
    gcc/testsuite/ChangeLog:
    
            * gcc.dg/torture/pr70740-1.c: New test.
    
    Signed-off-by: Andrew Pinski <quic_apin...@quicinc.com>

Diff:
---
 gcc/testsuite/gcc.dg/torture/pr70740-1.c | 41 ++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/gcc/testsuite/gcc.dg/torture/pr70740-1.c 
b/gcc/testsuite/gcc.dg/torture/pr70740-1.c
new file mode 100644
index 000000000000..77e6a2d71876
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr70740-1.c
@@ -0,0 +1,41 @@
+/* { dg-do compile } */
+
+/* This is an alternative to the original pr70740.c testcase,
+   arrays are now 1 in size where they were 0 in the other testcase. */
+
+extern int foo (void);
+extern void *memcpy (void *, const void *, __SIZE_TYPE__);
+
+struct
+{
+  char a[6];
+} d;
+struct
+{
+  int a1[1];
+  int a2[1];
+  int a3[1];
+  int a4[1];
+} a, c;
+int b;
+
+int *
+bar ()
+{
+  if (b)
+    return a.a4;
+  return a.a2;
+}
+
+void
+baz ()
+{
+  int *e, *f;
+  if (foo ())
+    e = c.a3;
+  else
+    e = c.a1;
+  memcpy (d.a, e, 6);
+  f = bar ();
+  memcpy (d.a, f, 1);
+}

Reply via email to