summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/tree-ssa/negate.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/gcc.dg/tree-ssa/negate.c')
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/negate.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/negate.c b/gcc/testsuite/gcc.dg/tree-ssa/negate.c
new file mode 100644
index 000000000..12e2cdf71
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/negate.c
@@ -0,0 +1,27 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-reassoc1" } */
+
+int f (int a, int b)
+{
+ int x = -a;
+ int y = b - x;
+ return y;
+}
+
+/* We tested for reassociation to -(a + b) on the following which
+ isn't a transform that makes things cheaper. With reassoc
+ no longer applying to types with undefined overflow we lost
+ this transform.
+
+int g (int a, int b)
+{
+ int x = -a;
+ int y = x - b;
+ return y;
+}
+
+*/
+
+/* There should be an addition now. */
+/* { dg-final { scan-tree-dump-times "\\+" 1 "reassoc1"} } */
+/* { dg-final { cleanup-tree-dump "reassoc1" } } */