aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/fold-div-1.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/gcc.dg/fold-div-1.c')
-rw-r--r--gcc/testsuite/gcc.dg/fold-div-1.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/fold-div-1.c b/gcc/testsuite/gcc.dg/fold-div-1.c
new file mode 100644
index 00000000000..533908c300c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/fold-div-1.c
@@ -0,0 +1,30 @@
+/* { dg-do compile } */
+/* { dg-options "-funsafe-math-optimizations -fdump-tree-gimple" } */
+
+float f(float x)
+{
+ return x/2 + x/3;
+}
+
+float g(float x)
+{
+ return 2/x + 3/x;
+}
+
+float h(float x)
+{
+ return x/2 - x/3;
+}
+
+float i(float x)
+{
+ return 2/x - 3/x;
+}
+
+/* f and h should be turned into multiplications,
+ the divisions in g and i should be grouped together. */
+
+/* { dg-final { scan-tree-dump-times " \\* " 2 "gimple" } } */
+/* { dg-final { scan-tree-dump-times " / " 2 "gimple" } } */
+/* { dg-final { cleanup-tree-dump "gimple" } } */
+