summaryrefslogtreecommitdiff
path: root/testsuite/tests
diff options
context:
space:
mode:
authorSylvain Henry <sylvain@haskus.fr>2022-09-08 23:34:04 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2023-04-13 08:50:33 -0400
commit593218794199e23cdfc1a94200cbb9f404e28720 (patch)
tree651804996b6133e146ab08d2721fd1b04d4f7a8c /testsuite/tests
parent690d0225d297a8c5c423ec4e63ee709df9d96d47 (diff)
downloadhaskell-593218794199e23cdfc1a94200cbb9f404e28720.tar.gz
Add quotRem rules (#22152)
case quotRemInt# x y of (# q, _ #) -> body ====> case quotInt# x y of q -> body case quotRemInt# x y of (# _, r #) -> body ====> case remInt# x y of r -> body
Diffstat (limited to 'testsuite/tests')
-rw-r--r--testsuite/tests/primops/should_compile/T22152.hs16
-rw-r--r--testsuite/tests/primops/should_compile/T22152.stderr10
-rw-r--r--testsuite/tests/primops/should_compile/all.T1
3 files changed, 27 insertions, 0 deletions
diff --git a/testsuite/tests/primops/should_compile/T22152.hs b/testsuite/tests/primops/should_compile/T22152.hs
new file mode 100644
index 0000000000..177c9a136d
--- /dev/null
+++ b/testsuite/tests/primops/should_compile/T22152.hs
@@ -0,0 +1,16 @@
+{-# OPTIONS_GHC -O2 -ddump-simpl -dno-typeable-binds -dsuppress-all -dsuppress-uniques #-}
+module T22152 (toHours) where
+
+{-# INLINE toHoursMinutesSeconds #-}
+toHoursMinutesSeconds :: Int -> (Int, Int, Int)
+toHoursMinutesSeconds t = (h, m', s)
+ where
+ (h, m') = m `quotRem` 60
+ (m, s) = toMinutesSeconds t
+
+toMinutesSeconds :: Int -> (Int, Int)
+toMinutesSeconds t = t `quotRem` 60
+
+toHours t = h
+ where
+ (h, _, _) = toHoursMinutesSeconds t
diff --git a/testsuite/tests/primops/should_compile/T22152.stderr b/testsuite/tests/primops/should_compile/T22152.stderr
new file mode 100644
index 0000000000..505bca04a7
--- /dev/null
+++ b/testsuite/tests/primops/should_compile/T22152.stderr
@@ -0,0 +1,10 @@
+
+==================== Tidy Core ====================
+Result size of Tidy Core
+ = {terms: 11, types: 5, coercions: 0, joins: 0/0}
+
+toHours
+ = \ t -> case t of { I# x -> I# (quotInt# (quotInt# x 60#) 60#) }
+
+
+
diff --git a/testsuite/tests/primops/should_compile/all.T b/testsuite/tests/primops/should_compile/all.T
index 82fa474c8b..94ef2b5c4f 100644
--- a/testsuite/tests/primops/should_compile/all.T
+++ b/testsuite/tests/primops/should_compile/all.T
@@ -6,3 +6,4 @@ test('LevAddrToAny', normal, compile, [''])
test('UnliftedMutVar_Comp', normal, compile, [''])
test('UnliftedStableName', normal, compile, [''])
test('KeepAliveWrapper', normal, compile, ['-O'])
+test('T22152', normal, compile, [''])