Test for #7116 (strength reduction)
authorJan Stolarek <jan.stolarek@p.lodz.pl>
Wed, 31 Jul 2013 10:48:58 +0000 (11:48 +0100)
committerJan Stolarek <jan.stolarek@p.lodz.pl>
Wed, 31 Jul 2013 10:48:58 +0000 (11:48 +0100)
testsuite/tests/numeric/should_compile/Makefile [new file with mode: 0644]
testsuite/tests/numeric/should_compile/T7116.hs [new file with mode: 0644]
testsuite/tests/numeric/should_compile/T7116.stdout [new file with mode: 0644]
testsuite/tests/numeric/should_compile/all.T [new file with mode: 0644]

diff --git a/testsuite/tests/numeric/should_compile/Makefile b/testsuite/tests/numeric/should_compile/Makefile
new file mode 100644 (file)
index 0000000..12c3cf9
--- /dev/null
@@ -0,0 +1,7 @@
+TOP=../../..
+include $(TOP)/mk/boilerplate.mk
+include $(TOP)/mk/test.mk
+
+T7116:
+       $(RM) -f T7116.o T7116.hi
+       '$(TEST_HC)' $(TEST_HC_OPTS) -O2 -c -ddump-simpl T7116.hs
diff --git a/testsuite/tests/numeric/should_compile/T7116.hs b/testsuite/tests/numeric/should_compile/T7116.hs
new file mode 100644 (file)
index 0000000..cdaa432
--- /dev/null
@@ -0,0 +1,19 @@
+module T7116 where
+
+-- this module tests strength reduction, i.e. turning floating
+-- point multiplication by two into addition:
+--
+-- 2.0 * x -> x + x
+
+dl :: Double -> Double
+dl x = 2.0 * x
+
+dr :: Double -> Double
+dr x = x * 2.0
+
+fl :: Float -> Float
+fl x = 2.0 * x
+
+fr :: Float -> Float
+fr x = x * 2.0
+
diff --git a/testsuite/tests/numeric/should_compile/T7116.stdout b/testsuite/tests/numeric/should_compile/T7116.stdout
new file mode 100644 (file)
index 0000000..d696b91
--- /dev/null
@@ -0,0 +1,70 @@
+
+==================== Tidy Core ====================
+Result size of Tidy Core = {terms: 22, types: 14, coercions: 0}
+
+T7116.dl :: GHC.Types.Double -> GHC.Types.Double
+[GblId,
+ Arity=1,
+ Caf=NoCafRefs,
+ Str=DmdType <S,1*U(U)>m,
+ Unf=Unf{Src=InlineStable, TopLvl=True, Arity=1, Value=True,
+         ConLike=True, WorkFree=True, Expandable=True,
+         Guidance=ALWAYS_IF(unsat_ok=True,boring_ok=False)
+         Tmpl= \ (x_ae1 [Occ=Once!] :: GHC.Types.Double) ->
+                 case x_ae1 of _ { GHC.Types.D# y_afn ->
+                 GHC.Types.D# (GHC.Prim.+## y_afn y_afn)
+                 }}]
+T7116.dl =
+  \ (x_ae1 :: GHC.Types.Double) ->
+    case x_ae1 of _ { GHC.Types.D# y_afn ->
+    GHC.Types.D# (GHC.Prim.+## y_afn y_afn)
+    }
+
+T7116.dr :: GHC.Types.Double -> GHC.Types.Double
+[GblId,
+ Arity=1,
+ Caf=NoCafRefs,
+ Str=DmdType <S,1*U(U)>m,
+ Unf=Unf{Src=InlineStable, TopLvl=True, Arity=1, Value=True,
+         ConLike=True, WorkFree=True, Expandable=True,
+         Guidance=ALWAYS_IF(unsat_ok=True,boring_ok=False)
+         Tmpl= \ (x_aem [Occ=Once!] :: GHC.Types.Double) ->
+                 case x_aem of _ { GHC.Types.D# x1_afj ->
+                 GHC.Types.D# (GHC.Prim.+## x1_afj x1_afj)
+                 }}]
+T7116.dr = T7116.dl
+
+T7116.fl :: GHC.Types.Float -> GHC.Types.Float
+[GblId,
+ Arity=1,
+ Caf=NoCafRefs,
+ Str=DmdType <S,1*U(U)>m,
+ Unf=Unf{Src=InlineStable, TopLvl=True, Arity=1, Value=True,
+         ConLike=True, WorkFree=True, Expandable=True,
+         Guidance=ALWAYS_IF(unsat_ok=True,boring_ok=False)
+         Tmpl= \ (x_aen [Occ=Once!] :: GHC.Types.Float) ->
+                 case x_aen of _ { GHC.Types.F# y_afx ->
+                 GHC.Types.F# (GHC.Prim.plusFloat# y_afx y_afx)
+                 }}]
+T7116.fl =
+  \ (x_aen :: GHC.Types.Float) ->
+    case x_aen of _ { GHC.Types.F# y_afx ->
+    GHC.Types.F# (GHC.Prim.plusFloat# y_afx y_afx)
+    }
+
+T7116.fr :: GHC.Types.Float -> GHC.Types.Float
+[GblId,
+ Arity=1,
+ Caf=NoCafRefs,
+ Str=DmdType <S,1*U(U)>m,
+ Unf=Unf{Src=InlineStable, TopLvl=True, Arity=1, Value=True,
+         ConLike=True, WorkFree=True, Expandable=True,
+         Guidance=ALWAYS_IF(unsat_ok=True,boring_ok=False)
+         Tmpl= \ (x_aeo [Occ=Once!] :: GHC.Types.Float) ->
+                 case x_aeo of _ { GHC.Types.F# x1_aft ->
+                 GHC.Types.F# (GHC.Prim.plusFloat# x1_aft x1_aft)
+                 }}]
+T7116.fr = T7116.fl
+
+
+
diff --git a/testsuite/tests/numeric/should_compile/all.T b/testsuite/tests/numeric/should_compile/all.T
new file mode 100644 (file)
index 0000000..3e8d4d3
--- /dev/null
@@ -0,0 +1 @@
+test('T7116', normal, run_command, ['$MAKE -s --no-print-directory T7116'])