summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/torture/reassoc-1.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/gcc.dg/torture/reassoc-1.c')
-rw-r--r--gcc/testsuite/gcc.dg/torture/reassoc-1.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/torture/reassoc-1.c b/gcc/testsuite/gcc.dg/torture/reassoc-1.c
new file mode 100644
index 000000000..f0c9014cc
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/reassoc-1.c
@@ -0,0 +1,24 @@
+/* { dg-do run } */
+
+int x;
+
+int __attribute__((noinline))
+foo(int a, int b, int w)
+{
+ int tmp1 = a * w;
+ int tmp2 = b * w;
+ x = tmp1;
+ return tmp1 + tmp2;
+}
+
+extern void abort (void);
+
+int main()
+{
+ if (foo(1, 2, 3) != 9)
+ abort ();
+ if (x != 3)
+ abort ();
+ return 0;
+}
+