Simon Jakobi pushed to branch wip/sjakobi/elem-tests at Glasgow Haskell Compiler / GHC
Commits:
-
595f5c40
by Simon Jakobi at 2026-03-28T01:05:08+01:00
13 changed files:
- + libraries/base/tests/perf/ElemFusionUnknownList.hs
- + libraries/base/tests/perf/ElemFusionUnknownList_O1.stderr
- + libraries/base/tests/perf/ElemFusionUnknownList_O2.stderr
- + libraries/base/tests/perf/ElemNoFusion.hs
- + libraries/base/tests/perf/ElemNoFusion_O1.stderr
- + libraries/base/tests/perf/ElemNoFusion_O2.stderr
- โ libraries/base/tests/perf/Makefile
- libraries/base/tests/perf/T17752.hs
- โ libraries/base/tests/perf/T17752.stdout
- + libraries/base/tests/perf/T17752_O0.stderr
- + libraries/base/tests/perf/T17752_O1.stderr
- + libraries/base/tests/perf/T17752_O2.stderr
- libraries/base/tests/perf/all.T
Changes:
| 1 | +-- We expect `elem` to fuse with good producers such as `map` and `concatMap`.
|
|
| 2 | +module ElemFusionUnknownList where
|
|
| 3 | + |
|
| 4 | +fusionElemMap :: Int -> [Int] -> Bool
|
|
| 5 | +fusionElemMap x = elem x . map (+1)
|
|
| 6 | + |
|
| 7 | +fusionNotElemMap :: Int -> [Int] -> Bool
|
|
| 8 | +fusionNotElemMap x = notElem x . map (+1)
|
|
| 9 | + |
|
| 10 | +fusionElemConcatMap :: Int -> [Int] -> Bool
|
|
| 11 | +fusionElemConcatMap x = elem x . concatMap (\y -> [y + 1, y + 2])
|
|
| 12 | + |
|
| 13 | +fusionNotElemConcatMap :: Int -> [Int] -> Bool
|
|
| 14 | +fusionNotElemConcatMap x = notElem x . concatMap (\y -> [y + 1, y + 2]) |
| 1 | +fusionNotElemConcatMap
|
|
| 2 | + = \ x x1 ->
|
|
| 3 | + joinrec {
|
|
| 4 | + go1 ds
|
|
| 5 | + = case ds of {
|
|
| 6 | + [] -> True;
|
|
| 7 | + : y ys ->
|
|
| 8 | + case y of { I# x2 ->
|
|
| 9 | + case x of { I# x3 ->
|
|
| 10 | + case ==# x3 (+# x2 1#) of {
|
|
| 11 | + __DEFAULT ->
|
|
| 12 | + case ==# x3 (+# x2 2#) of {
|
|
| 13 | + __DEFAULT -> jump go1 ys;
|
|
| 14 | + 1# -> False
|
|
| 15 | + };
|
|
| 16 | + 1# -> False
|
|
| 17 | + }
|
|
| 18 | + }
|
|
| 19 | + }
|
|
| 20 | + }; } in
|
|
| 21 | + jump go1 x1
|
|
| 22 | + |
|
| 23 | +fusionElemConcatMap
|
|
| 24 | + = \ x x1 ->
|
|
| 25 | + joinrec {
|
|
| 26 | + go1 ds
|
|
| 27 | + = case ds of {
|
|
| 28 | + [] -> False;
|
|
| 29 | + : y ys ->
|
|
| 30 | + case y of { I# x2 ->
|
|
| 31 | + case x of { I# x3 ->
|
|
| 32 | + case ==# x3 (+# x2 1#) of {
|
|
| 33 | + __DEFAULT ->
|
|
| 34 | + case ==# x3 (+# x2 2#) of {
|
|
| 35 | + __DEFAULT -> jump go1 ys;
|
|
| 36 | + 1# -> True
|
|
| 37 | + };
|
|
| 38 | + 1# -> True
|
|
| 39 | + }
|
|
| 40 | + }
|
|
| 41 | + }
|
|
| 42 | + }; } in
|
|
| 43 | + jump go1 x1
|
|
| 44 | + |
|
| 45 | +fusionNotElemMap
|
|
| 46 | + = \ x eta ->
|
|
| 47 | + joinrec {
|
|
| 48 | + go1 ds
|
|
| 49 | + = case ds of {
|
|
| 50 | + [] -> True;
|
|
| 51 | + : y ys ->
|
|
| 52 | + case x of { I# x1 ->
|
|
| 53 | + case y of { I# x2 ->
|
|
| 54 | + case ==# x1 (+# x2 1#) of {
|
|
| 55 | + __DEFAULT -> jump go1 ys;
|
|
| 56 | + 1# -> False
|
|
| 57 | + }
|
|
| 58 | + }
|
|
| 59 | + }
|
|
| 60 | + }; } in
|
|
| 61 | + jump go1 eta
|
|
| 62 | + |
|
| 63 | +fusionElemMap
|
|
| 64 | + = \ x eta ->
|
|
| 65 | + joinrec {
|
|
| 66 | + go1 ds
|
|
| 67 | + = case ds of {
|
|
| 68 | + [] -> False;
|
|
| 69 | + : y ys ->
|
|
| 70 | + case x of { I# x1 ->
|
|
| 71 | + case y of { I# x2 ->
|
|
| 72 | + case ==# x1 (+# x2 1#) of {
|
|
| 73 | + __DEFAULT -> jump go1 ys;
|
|
| 74 | + 1# -> True
|
|
| 75 | + }
|
|
| 76 | + }
|
|
| 77 | + }
|
|
| 78 | + }; } in
|
|
| 79 | + jump go1 eta
|
|
| 80 | + |
| 1 | +fusionNotElemConcatMap
|
|
| 2 | + = \ x x1 ->
|
|
| 3 | + case x1 of {
|
|
| 4 | + [] -> True;
|
|
| 5 | + : y ys ->
|
|
| 6 | + case y of { I# x2 ->
|
|
| 7 | + case x of { I# x3 ->
|
|
| 8 | + case ==# x3 (+# x2 1#) of {
|
|
| 9 | + __DEFAULT ->
|
|
| 10 | + case ==# x3 (+# x2 2#) of {
|
|
| 11 | + __DEFAULT ->
|
|
| 12 | + joinrec {
|
|
| 13 | + go1 ds
|
|
| 14 | + = case ds of {
|
|
| 15 | + [] -> True;
|
|
| 16 | + : y1 ys1 ->
|
|
| 17 | + case y1 of { I# x4 ->
|
|
| 18 | + case ==# x3 (+# x4 1#) of {
|
|
| 19 | + __DEFAULT ->
|
|
| 20 | + case ==# x3 (+# x4 2#) of {
|
|
| 21 | + __DEFAULT -> jump go1 ys1;
|
|
| 22 | + 1# -> False
|
|
| 23 | + };
|
|
| 24 | + 1# -> False
|
|
| 25 | + }
|
|
| 26 | + }
|
|
| 27 | + }; } in
|
|
| 28 | + jump go1 ys;
|
|
| 29 | + 1# -> False
|
|
| 30 | + };
|
|
| 31 | + 1# -> False
|
|
| 32 | + }
|
|
| 33 | + }
|
|
| 34 | + }
|
|
| 35 | + }
|
|
| 36 | + |
|
| 37 | +fusionElemConcatMap
|
|
| 38 | + = \ x x1 ->
|
|
| 39 | + case x1 of {
|
|
| 40 | + [] -> False;
|
|
| 41 | + : y ys ->
|
|
| 42 | + case y of { I# x2 ->
|
|
| 43 | + case x of { I# x3 ->
|
|
| 44 | + case ==# x3 (+# x2 1#) of {
|
|
| 45 | + __DEFAULT ->
|
|
| 46 | + case ==# x3 (+# x2 2#) of {
|
|
| 47 | + __DEFAULT ->
|
|
| 48 | + joinrec {
|
|
| 49 | + go1 ds
|
|
| 50 | + = case ds of {
|
|
| 51 | + [] -> False;
|
|
| 52 | + : y1 ys1 ->
|
|
| 53 | + case y1 of { I# x4 ->
|
|
| 54 | + case ==# x3 (+# x4 1#) of {
|
|
| 55 | + __DEFAULT ->
|
|
| 56 | + case ==# x3 (+# x4 2#) of {
|
|
| 57 | + __DEFAULT -> jump go1 ys1;
|
|
| 58 | + 1# -> True
|
|
| 59 | + };
|
|
| 60 | + 1# -> True
|
|
| 61 | + }
|
|
| 62 | + }
|
|
| 63 | + }; } in
|
|
| 64 | + jump go1 ys;
|
|
| 65 | + 1# -> True
|
|
| 66 | + };
|
|
| 67 | + 1# -> True
|
|
| 68 | + }
|
|
| 69 | + }
|
|
| 70 | + }
|
|
| 71 | + }
|
|
| 72 | + |
|
| 73 | +fusionNotElemMap
|
|
| 74 | + = \ x eta ->
|
|
| 75 | + case eta of {
|
|
| 76 | + [] -> True;
|
|
| 77 | + : y ys ->
|
|
| 78 | + case x of { I# x1 ->
|
|
| 79 | + case y of { I# x2 ->
|
|
| 80 | + case ==# x1 (+# x2 1#) of {
|
|
| 81 | + __DEFAULT ->
|
|
| 82 | + joinrec {
|
|
| 83 | + go1 ds
|
|
| 84 | + = case ds of {
|
|
| 85 | + [] -> True;
|
|
| 86 | + : y1 ys1 ->
|
|
| 87 | + case y1 of { I# x3 ->
|
|
| 88 | + case ==# x1 (+# x3 1#) of {
|
|
| 89 | + __DEFAULT -> jump go1 ys1;
|
|
| 90 | + 1# -> False
|
|
| 91 | + }
|
|
| 92 | + }
|
|
| 93 | + }; } in
|
|
| 94 | + jump go1 ys;
|
|
| 95 | + 1# -> False
|
|
| 96 | + }
|
|
| 97 | + }
|
|
| 98 | + }
|
|
| 99 | + }
|
|
| 100 | + |
|
| 101 | +fusionElemMap
|
|
| 102 | + = \ x eta ->
|
|
| 103 | + case eta of {
|
|
| 104 | + [] -> False;
|
|
| 105 | + : y ys ->
|
|
| 106 | + case x of { I# x1 ->
|
|
| 107 | + case y of { I# x2 ->
|
|
| 108 | + case ==# x1 (+# x2 1#) of {
|
|
| 109 | + __DEFAULT ->
|
|
| 110 | + joinrec {
|
|
| 111 | + go1 ds
|
|
| 112 | + = case ds of {
|
|
| 113 | + [] -> False;
|
|
| 114 | + : y1 ys1 ->
|
|
| 115 | + case y1 of { I# x3 ->
|
|
| 116 | + case ==# x1 (+# x3 1#) of {
|
|
| 117 | + __DEFAULT -> jump go1 ys1;
|
|
| 118 | + 1# -> True
|
|
| 119 | + }
|
|
| 120 | + }
|
|
| 121 | + }; } in
|
|
| 122 | + jump go1 ys;
|
|
| 123 | + 1# -> True
|
|
| 124 | + }
|
|
| 125 | + }
|
|
| 126 | + }
|
|
| 127 | + }
|
|
| 128 | + |
| 1 | +-- As of March 2026, we don't expect `elem` to fuse with `sort` or `NonEmpty.toList`.
|
|
| 2 | +-- `elem` isn't even specialized, and performs dictionary-passing, but that may
|
|
| 3 | +-- change: #27096
|
|
| 4 | +module ElemNoFusion where
|
|
| 5 | + |
|
| 6 | +import Data.List (sort)
|
|
| 7 | +import Data.List.NonEmpty (NonEmpty)
|
|
| 8 | +import qualified Data.List.NonEmpty as NonEmpty
|
|
| 9 | + |
|
| 10 | +noFusionElemNonEmptyToList :: Int -> NonEmpty Int -> Bool
|
|
| 11 | +noFusionElemNonEmptyToList x = elem x . NonEmpty.toList
|
|
| 12 | + |
|
| 13 | +noFusionElemSort :: Int -> [Int] -> Bool
|
|
| 14 | +noFusionElemSort x = elem x . sort |
| 1 | +noFusionElemSort = \ x x1 -> elem $fEqInt x (actualSort gtInt x1)
|
|
| 2 | + |
|
| 3 | +noFusionElemNonEmptyToList
|
|
| 4 | + = \ x x1 -> case x1 of { :| a1 as -> elem $fEqInt x (: a1 as) }
|
|
| 5 | + |
| 1 | +noFusionElemSort = \ x x1 -> elem $fEqInt x (actualSort gtInt x1)
|
|
| 2 | + |
|
| 3 | +noFusionElemNonEmptyToList
|
|
| 4 | + = \ x x1 -> case x1 of { :| a1 as -> elem $fEqInt x (: a1 as) }
|
|
| 5 | + |
| 1 | -# This Makefile runs the tests using GHC's testsuite framework. It
|
|
| 2 | -# assumes the package is part of a GHC build tree with the testsuite
|
|
| 3 | -# installed in ../../../testsuite.
|
|
| 4 | - |
|
| 5 | -TOP=../../../../testsuite
|
|
| 6 | -include $(TOP)/mk/boilerplate.mk
|
|
| 7 | -include $(TOP)/mk/test.mk
|
|
| 8 | - |
|
| 9 | - |
|
| 10 | -T17752:
|
|
| 11 | - '$(TEST_HC)' $(TEST_HC_OPTS) -O --make T17752 -rtsopts -ddump-simpl -ddump-to-file -dsuppress-uniques -dsuppress-all
|
|
| 12 | - # All occurrences of elem should be optimized away.
|
|
| 13 | - # For strings these should result in loops after inlining foldCString.
|
|
| 14 | - # For lists it should result in a case expression.
|
|
| 15 | - echo $$(grep -A4 "elem" T17752.dump-simpl) |
| ... | ... | @@ -6,7 +6,7 @@ module T17752 where |
| 6 | 6 | |
| 7 | 7 | -- Should compile to a pattern match if the rules fire
|
| 8 | 8 | isElemList x = x `elem` ['a','b','c']
|
| 9 | -isNotElemList x = x `elem` ['x','y','z']
|
|
| 9 | +isNotElemList x = x `notElem` ['x','y','z']
|
|
| 10 | 10 | |
| 11 | 11 | isOneOfThese x = x `elem` [1,2,3,4,5::Int]
|
| 12 | 12 | isNotOneOfThese x = x `notElem` [1,2,3,4,5::Int]
|
| 1 | -[1 of 1] Compiling T17752 ( T17752.hs, T17752.o )
|
|
| 2 | - |
| 1 | +isElemList
|
|
| 2 | + = \ x ->
|
|
| 3 | + elem
|
|
| 4 | + $fFoldableList
|
|
| 5 | + $fEqChar
|
|
| 6 | + x
|
|
| 7 | + (: (C# 'a'#) (: (C# 'b'#) (: (C# 'c'#) [])))
|
|
| 8 | + |
|
| 9 | +isNotElemList
|
|
| 10 | + = \ x ->
|
|
| 11 | + notElem
|
|
| 12 | + $fFoldableList
|
|
| 13 | + $fEqChar
|
|
| 14 | + x
|
|
| 15 | + (: (C# 'x'#) (: (C# 'y'#) (: (C# 'z'#) [])))
|
|
| 16 | + |
|
| 17 | +isOneOfThese
|
|
| 18 | + = \ x ->
|
|
| 19 | + elem
|
|
| 20 | + $fFoldableList
|
|
| 21 | + $fEqInt
|
|
| 22 | + x
|
|
| 23 | + (: (I# 1#) (: (I# 2#) (: (I# 3#) (: (I# 4#) (: (I# 5#) [])))))
|
|
| 24 | + |
|
| 25 | +isNotOneOfThese
|
|
| 26 | + = \ x ->
|
|
| 27 | + notElem
|
|
| 28 | + $fFoldableList
|
|
| 29 | + $fEqInt
|
|
| 30 | + x
|
|
| 31 | + (: (I# 1#) (: (I# 2#) (: (I# 3#) (: (I# 4#) (: (I# 5#) [])))))
|
|
| 32 | + |
|
| 33 | +isElemString
|
|
| 34 | + = \ x -> elem $fFoldableList $fEqChar x (unpackCString# "foo"#)
|
|
| 35 | + |
|
| 36 | +isNotElemString
|
|
| 37 | + = \ x -> notElem $fFoldableList $fEqChar x (unpackCString# "bar"#)
|
|
| 38 | + |
|
| 39 | +isElemStringUtf
|
|
| 40 | + = \ x ->
|
|
| 41 | + elem $fFoldableList $fEqChar x (unpackCStringUtf8# "fo\\195\\182"#)
|
|
| 42 | + |
|
| 43 | +isNotElemStringUtf
|
|
| 44 | + = \ x ->
|
|
| 45 | + notElem
|
|
| 46 | + $fFoldableList $fEqChar x (unpackCStringUtf8# "b\\195\\164r"#)
|
|
| 47 | + |
| 1 | +isElemList
|
|
| 2 | + = \ x ->
|
|
| 3 | + case x of { C# x1 ->
|
|
| 4 | + case x1 of {
|
|
| 5 | + __DEFAULT -> False;
|
|
| 6 | + 'a'# -> True;
|
|
| 7 | + 'b'# -> True;
|
|
| 8 | + 'c'# -> True
|
|
| 9 | + }
|
|
| 10 | + }
|
|
| 11 | + |
|
| 12 | +isNotElemList
|
|
| 13 | + = \ x ->
|
|
| 14 | + case x of { C# x1 ->
|
|
| 15 | + case x1 of {
|
|
| 16 | + __DEFAULT -> True;
|
|
| 17 | + 'x'# -> False;
|
|
| 18 | + 'y'# -> False;
|
|
| 19 | + 'z'# -> False
|
|
| 20 | + }
|
|
| 21 | + }
|
|
| 22 | + |
|
| 23 | +isOneOfThese
|
|
| 24 | + = \ x ->
|
|
| 25 | + case x of { I# x1 ->
|
|
| 26 | + case x1 of {
|
|
| 27 | + __DEFAULT -> False;
|
|
| 28 | + 1# -> True;
|
|
| 29 | + 2# -> True;
|
|
| 30 | + 3# -> True;
|
|
| 31 | + 4# -> True;
|
|
| 32 | + 5# -> True
|
|
| 33 | + }
|
|
| 34 | + }
|
|
| 35 | + |
|
| 36 | +isNotOneOfThese
|
|
| 37 | + = \ x ->
|
|
| 38 | + case x of { I# x1 ->
|
|
| 39 | + case x1 of {
|
|
| 40 | + __DEFAULT -> True;
|
|
| 41 | + 1# -> False;
|
|
| 42 | + 2# -> False;
|
|
| 43 | + 3# -> False;
|
|
| 44 | + 4# -> False;
|
|
| 45 | + 5# -> False
|
|
| 46 | + }
|
|
| 47 | + }
|
|
| 48 | + |
|
| 49 | +isElemString
|
|
| 50 | + = \ x ->
|
|
| 51 | + joinrec {
|
|
| 52 | + go addr z
|
|
| 53 | + = case indexCharOffAddr# addr 0# of ch {
|
|
| 54 | + __DEFAULT ->
|
|
| 55 | + case x of { C# x1 ->
|
|
| 56 | + case eqChar# x1 ch of {
|
|
| 57 | + __DEFAULT -> jump go (plusAddr# addr 1#) z;
|
|
| 58 | + 1# -> True
|
|
| 59 | + }
|
|
| 60 | + };
|
|
| 61 | + '\NUL'# -> z
|
|
| 62 | + }; } in
|
|
| 63 | + jump go isElemString1 False
|
|
| 64 | + |
|
| 65 | +isNotElemString
|
|
| 66 | + = \ x ->
|
|
| 67 | + joinrec {
|
|
| 68 | + go addr z
|
|
| 69 | + = case indexCharOffAddr# addr 0# of ch {
|
|
| 70 | + __DEFAULT ->
|
|
| 71 | + case x of { C# x1 ->
|
|
| 72 | + case eqChar# x1 ch of {
|
|
| 73 | + __DEFAULT -> jump go (plusAddr# addr 1#) z;
|
|
| 74 | + 1# -> False
|
|
| 75 | + }
|
|
| 76 | + };
|
|
| 77 | + '\NUL'# ->
|
|
| 78 | + case z of {
|
|
| 79 | + False -> True;
|
|
| 80 | + True -> False
|
|
| 81 | + }
|
|
| 82 | + }; } in
|
|
| 83 | + jump go isNotElemString1 False
|
|
| 84 | + |
|
| 85 | +isElemStringUtf
|
|
| 86 | + = \ x ->
|
|
| 87 | + unpackFoldrCStringUtf8#
|
|
| 88 | + isElemStringUtf1
|
|
| 89 | + (\ y r ->
|
|
| 90 | + case x of { C# x1 ->
|
|
| 91 | + case y of { C# y1 ->
|
|
| 92 | + case eqChar# x1 y1 of {
|
|
| 93 | + __DEFAULT -> r;
|
|
| 94 | + 1# -> True
|
|
| 95 | + }
|
|
| 96 | + }
|
|
| 97 | + })
|
|
| 98 | + False
|
|
| 99 | + |
|
| 100 | +isNotElemStringUtf
|
|
| 101 | + = \ x ->
|
|
| 102 | + case unpackFoldrCStringUtf8#
|
|
| 103 | + isNotElemStringUtf1
|
|
| 104 | + (\ y r ->
|
|
| 105 | + case x of { C# x1 ->
|
|
| 106 | + case y of { C# y1 ->
|
|
| 107 | + case eqChar# x1 y1 of {
|
|
| 108 | + __DEFAULT -> r;
|
|
| 109 | + 1# -> True
|
|
| 110 | + }
|
|
| 111 | + }
|
|
| 112 | + })
|
|
| 113 | + False
|
|
| 114 | + of {
|
|
| 115 | + False -> True;
|
|
| 116 | + True -> False
|
|
| 117 | + }
|
|
| 118 | + |
| 1 | +isElemList
|
|
| 2 | + = \ x ->
|
|
| 3 | + case x of { C# x1 ->
|
|
| 4 | + case x1 of {
|
|
| 5 | + __DEFAULT -> False;
|
|
| 6 | + 'a'# -> True;
|
|
| 7 | + 'b'# -> True;
|
|
| 8 | + 'c'# -> True
|
|
| 9 | + }
|
|
| 10 | + }
|
|
| 11 | + |
|
| 12 | +isNotElemList
|
|
| 13 | + = \ x ->
|
|
| 14 | + case x of { C# x1 ->
|
|
| 15 | + case x1 of {
|
|
| 16 | + __DEFAULT -> True;
|
|
| 17 | + 'x'# -> False;
|
|
| 18 | + 'y'# -> False;
|
|
| 19 | + 'z'# -> False
|
|
| 20 | + }
|
|
| 21 | + }
|
|
| 22 | + |
|
| 23 | +isOneOfThese
|
|
| 24 | + = \ x ->
|
|
| 25 | + case x of { I# x1 ->
|
|
| 26 | + case x1 of {
|
|
| 27 | + __DEFAULT -> False;
|
|
| 28 | + 1# -> True;
|
|
| 29 | + 2# -> True;
|
|
| 30 | + 3# -> True;
|
|
| 31 | + 4# -> True;
|
|
| 32 | + 5# -> True
|
|
| 33 | + }
|
|
| 34 | + }
|
|
| 35 | + |
|
| 36 | +isNotOneOfThese
|
|
| 37 | + = \ x ->
|
|
| 38 | + case x of { I# x1 ->
|
|
| 39 | + case x1 of {
|
|
| 40 | + __DEFAULT -> True;
|
|
| 41 | + 1# -> False;
|
|
| 42 | + 2# -> False;
|
|
| 43 | + 3# -> False;
|
|
| 44 | + 4# -> False;
|
|
| 45 | + 5# -> False
|
|
| 46 | + }
|
|
| 47 | + }
|
|
| 48 | + |
|
| 49 | +isElemString
|
|
| 50 | + = \ x ->
|
|
| 51 | + case indexCharOffAddr# isElemString1 0# of ch {
|
|
| 52 | + __DEFAULT ->
|
|
| 53 | + case x of { C# x1 ->
|
|
| 54 | + case eqChar# x1 ch of {
|
|
| 55 | + __DEFAULT ->
|
|
| 56 | + joinrec {
|
|
| 57 | + go addr z
|
|
| 58 | + = case indexCharOffAddr# addr 0# of ch1 {
|
|
| 59 | + __DEFAULT ->
|
|
| 60 | + case eqChar# x1 ch1 of {
|
|
| 61 | + __DEFAULT -> jump go (plusAddr# addr 1#) z;
|
|
| 62 | + 1# -> True
|
|
| 63 | + };
|
|
| 64 | + '\NUL'# -> z
|
|
| 65 | + }; } in
|
|
| 66 | + jump go (plusAddr# isElemString1 1#) False;
|
|
| 67 | + 1# -> True
|
|
| 68 | + }
|
|
| 69 | + };
|
|
| 70 | + '\NUL'# -> False
|
|
| 71 | + }
|
|
| 72 | + |
|
| 73 | +isNotElemString
|
|
| 74 | + = \ x ->
|
|
| 75 | + case indexCharOffAddr# isNotElemString1 0# of ch {
|
|
| 76 | + __DEFAULT ->
|
|
| 77 | + case x of { C# x1 ->
|
|
| 78 | + case eqChar# x1 ch of {
|
|
| 79 | + __DEFAULT ->
|
|
| 80 | + joinrec {
|
|
| 81 | + $sgo sc
|
|
| 82 | + = case indexCharOffAddr# sc 0# of ch1 {
|
|
| 83 | + __DEFAULT ->
|
|
| 84 | + case eqChar# x1 ch1 of {
|
|
| 85 | + __DEFAULT -> jump $sgo (plusAddr# sc 1#);
|
|
| 86 | + 1# -> False
|
|
| 87 | + };
|
|
| 88 | + '\NUL'# -> True
|
|
| 89 | + }; } in
|
|
| 90 | + jump $sgo (plusAddr# isNotElemString1 1#);
|
|
| 91 | + 1# -> False
|
|
| 92 | + }
|
|
| 93 | + };
|
|
| 94 | + '\NUL'# -> True
|
|
| 95 | + }
|
|
| 96 | + |
|
| 97 | +isElemStringUtf
|
|
| 98 | + = \ x ->
|
|
| 99 | + unpackFoldrCStringUtf8#
|
|
| 100 | + isElemStringUtf1
|
|
| 101 | + (\ y r ->
|
|
| 102 | + case x of { C# x1 ->
|
|
| 103 | + case y of { C# y1 ->
|
|
| 104 | + case eqChar# x1 y1 of {
|
|
| 105 | + __DEFAULT -> r;
|
|
| 106 | + 1# -> True
|
|
| 107 | + }
|
|
| 108 | + }
|
|
| 109 | + })
|
|
| 110 | + False
|
|
| 111 | + |
|
| 112 | +isNotElemStringUtf
|
|
| 113 | + = \ x ->
|
|
| 114 | + case unpackFoldrCStringUtf8#
|
|
| 115 | + isNotElemStringUtf1
|
|
| 116 | + (\ y r ->
|
|
| 117 | + case x of { C# x1 ->
|
|
| 118 | + case y of { C# y1 ->
|
|
| 119 | + case eqChar# x1 y1 of {
|
|
| 120 | + __DEFAULT -> r;
|
|
| 121 | + 1# -> True
|
|
| 122 | + }
|
|
| 123 | + }
|
|
| 124 | + })
|
|
| 125 | + False
|
|
| 126 | + of {
|
|
| 127 | + False -> True;
|
|
| 128 | + True -> False
|
|
| 129 | + }
|
|
| 130 | + |
| ... | ... | @@ -2,10 +2,26 @@ |
| 2 | 2 | setTestOpts(js_skip)
|
| 3 | 3 | |
| 4 | 4 | #--------------------------------------
|
| 5 | -# Check specialization of elem via rules
|
|
| 5 | +# Check optimization of `elem`
|
|
| 6 | 6 | #--------------------------------------
|
| 7 | 7 | |
| 8 | -test('T17752', [only_ways(['normal'])] , makefile_test, ['T17752'])
|
|
| 8 | +elemCoreFilter = "sed -En '/^(is|fusion|noFusion)[A-Za-z]*($| )/,/^$/p'"
|
|
| 9 | + |
|
| 10 | +def elemCoreTest(test_name, module_name, opt):
|
|
| 11 | + test(test_name,
|
|
| 12 | + [only_ways(['normal']), extra_files([module_name + '.hs'])],
|
|
| 13 | + multimod_compile_filter,
|
|
| 14 | + [module_name,
|
|
| 15 | + f'{opt} -ddump-simpl -dsuppress-all -dsuppress-uniques -dno-typeable-binds',
|
|
| 16 | + elemCoreFilter])
|
|
| 17 | + |
|
| 18 | +elemCoreTest('T17752_O0', 'T17752', '-O0')
|
|
| 19 | +elemCoreTest('T17752_O1', 'T17752', '-O1')
|
|
| 20 | +elemCoreTest('T17752_O2', 'T17752', '-O2')
|
|
| 21 | +elemCoreTest('ElemFusionUnknownList_O1', 'ElemFusionUnknownList', '-O1')
|
|
| 22 | +elemCoreTest('ElemFusionUnknownList_O2', 'ElemFusionUnknownList', '-O2')
|
|
| 23 | +elemCoreTest('ElemNoFusion_O1', 'ElemNoFusion', '-O1')
|
|
| 24 | +elemCoreTest('ElemNoFusion_O2', 'ElemNoFusion', '-O2')
|
|
| 9 | 25 | |
| 10 | 26 | #--------------------------------------
|
| 11 | 27 |