summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/fold-plusmult-2.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/gcc.dg/fold-plusmult-2.c')
-rw-r--r--gcc/testsuite/gcc.dg/fold-plusmult-2.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/fold-plusmult-2.c b/gcc/testsuite/gcc.dg/fold-plusmult-2.c
new file mode 100644
index 000000000..fd5376220
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/fold-plusmult-2.c
@@ -0,0 +1,20 @@
+/* { dg-do compile } */
+/* { dg-options "-fdump-tree-original" } */
+
+int foo (int i)
+{
+ return 2 + i * 4;
+}
+
+/* We do _not_ want the above to be canonicalized to (i * 2 + 1) * 2. */
+
+int bar (int i)
+{
+ return 4 + i * 2;
+}
+
+/* But eventually this to be canonicalized to (i + 2) * 2. */
+
+/* { dg-final { scan-tree-dump "i \\\* 4 \\\+ 2" "original" } } */
+/* { dg-final { scan-tree-dump "\\\(i \\\+ 2\\\) \\\* 2" "original" } } */
+/* { dg-final { cleanup-tree-dump "original" } } */