summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKrzysztof Gogolewski <krzysztof.gogolewski@tweag.io>2020-12-18 01:37:23 +0100
committerBen Gamari <ben@smart-cactus.org>2021-01-26 09:49:54 -0500
commit9030120eeb13c10eb03ff542ce96246a936e5b03 (patch)
tree91cd29c56152c6eca54ac84c7ee54bec5266346c
parente94c57addafa01a8dfeb7cd17a9e6dabd1d4d85a (diff)
downloadhaskell-9030120eeb13c10eb03ff542ce96246a936e5b03.tar.gz
Fix printing in -ddump-rule-rewrites (#18668)
The unapplied arguments were not printed out. (cherry picked from commit 5eb22fa2e80a1f07ca8c1bd6af093490a7a72bbb)
-rw-r--r--compiler/GHC/Core/Opt/Simplify.hs3
-rw-r--r--testsuite/tests/simplCore/should_compile/T18668.hs11
-rw-r--r--testsuite/tests/simplCore/should_compile/T18668.stderr24
-rw-r--r--testsuite/tests/simplCore/should_compile/all.T2
4 files changed, 39 insertions, 1 deletions
diff --git a/compiler/GHC/Core/Opt/Simplify.hs b/compiler/GHC/Core/Opt/Simplify.hs
index 90f43d22bc..d6d49a37df 100644
--- a/compiler/GHC/Core/Opt/Simplify.hs
+++ b/compiler/GHC/Core/Opt/Simplify.hs
@@ -2173,7 +2173,8 @@ tryRules env rules fn args call_cont
[ text "Rule:" <+> ftext (ruleName rule)
, text "Module:" <+> printRuleModule rule
, text "Before:" <+> hang (ppr fn) 2 (sep (map ppr args))
- , text "After: " <+> pprCoreExpr rule_rhs
+ , text "After: " <+> hang (pprCoreExpr rule_rhs) 2
+ (sep $ map ppr $ drop (ruleArity rule) args)
, text "Cont: " <+> ppr call_cont ]
| dopt Opt_D_dump_rule_firings dflags
diff --git a/testsuite/tests/simplCore/should_compile/T18668.hs b/testsuite/tests/simplCore/should_compile/T18668.hs
new file mode 100644
index 0000000000..5e5ddb44df
--- /dev/null
+++ b/testsuite/tests/simplCore/should_compile/T18668.hs
@@ -0,0 +1,11 @@
+{-# OPTIONS_GHC -O -ddump-rule-rewrites #-}
+{-# LANGUAGE MagicHash #-}
+
+module T18668 where
+
+import GHC.Exts
+
+{-# RULES "funky" (+#) = (*#) #-}
+{-# RULES "flip" forall x. (>#) x = (<#) x #-}
+
+x = (I# (2# +# 3#), I# (1# ># 0#))
diff --git a/testsuite/tests/simplCore/should_compile/T18668.stderr b/testsuite/tests/simplCore/should_compile/T18668.stderr
new file mode 100644
index 0000000000..16e632d64d
--- /dev/null
+++ b/testsuite/tests/simplCore/should_compile/T18668.stderr
@@ -0,0 +1,24 @@
+Rule fired
+ Rule: funky
+ Module: (T18668)
+ Before: GHC.Prim.+# ValArg 2# ValArg 3#
+ After: (GHC.Prim.*#) ValArg 2# ValArg 3#
+ Cont: Stop[BoringCtxt] GHC.Prim.Int#
+Rule fired
+ Rule: *#
+ Module: (BUILTIN)
+ Before: GHC.Prim.*# ValArg 2# ValArg 3#
+ After: 6#
+ Cont: Stop[BoringCtxt] GHC.Prim.Int#
+Rule fired
+ Rule: flip
+ Module: (T18668)
+ Before: GHC.Prim.># ValArg 1# ValArg 0#
+ After: (\ (x :: GHC.Prim.Int#) -> GHC.Prim.<# x) 1# ValArg 0#
+ Cont: Stop[BoringCtxt] GHC.Prim.Int#
+Rule fired
+ Rule: <#
+ Module: (BUILTIN)
+ Before: GHC.Prim.<# ValArg 1# ValArg 0#
+ After: 0#
+ Cont: Stop[BoringCtxt] GHC.Prim.Int#
diff --git a/testsuite/tests/simplCore/should_compile/all.T b/testsuite/tests/simplCore/should_compile/all.T
index d04005e183..4657cf746e 100644
--- a/testsuite/tests/simplCore/should_compile/all.T
+++ b/testsuite/tests/simplCore/should_compile/all.T
@@ -341,3 +341,5 @@ test('T18747B', normal, compile, [''])
test('T18649', normal, compile, ['-O -ddump-rules -Wno-simplifiable-class-constraints'])
test('T19168', normal, compile, [''])
+
+test('T18668', normal, compile, ['-dsuppress-uniques'])