From 593218794199e23cdfc1a94200cbb9f404e28720 Mon Sep 17 00:00:00 2001 From: Sylvain Henry Date: Thu, 8 Sep 2022 23:34:04 +0200 Subject: 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 --- testsuite/tests/primops/should_compile/T22152.hs | 16 ++++++++++++++++ testsuite/tests/primops/should_compile/T22152.stderr | 10 ++++++++++ testsuite/tests/primops/should_compile/all.T | 1 + 3 files changed, 27 insertions(+) create mode 100644 testsuite/tests/primops/should_compile/T22152.hs create mode 100644 testsuite/tests/primops/should_compile/T22152.stderr (limited to 'testsuite/tests') 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, ['']) -- cgit v1.2.1