summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/tree-ssa/ssa-ccp-12.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/gcc.dg/tree-ssa/ssa-ccp-12.c')
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/ssa-ccp-12.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-ccp-12.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-ccp-12.c
new file mode 100644
index 00000000000..8ee9eb8d0e4
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-ccp-12.c
@@ -0,0 +1,32 @@
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+
+struct A
+{
+ int a;
+ int b;
+};
+
+struct A a;
+const int B = 42;
+
+void foo (int i)
+{
+ if (i > 10)
+ a.a = 42;
+ else
+ {
+ a.b = 21;
+ a.a = a.b + 21;
+ }
+
+ /* This should be folded to 'if (0)' as a.a and B are both 42. */
+ if (a.a != B)
+ link_error ();
+}
+
+main ()
+{
+ foo (3);
+ return 0;
+}