[GHC] #9661: Branchless ==# is compiled to branchy code
GHC
ghc-devs at haskell.org
Fri Oct 3 06:21:28 UTC 2014
#9661: Branchless ==# is compiled to branchy code
-------------------------------------+-------------------------------------
Reporter: dfeuer | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 7.9
Keywords: | Operating System:
Architecture: Unknown/Multiple | Unknown/Multiple
Difficulty: Unknown | Type of failure: Runtime
Blocked By: | performance bug
Related Tickets: | Test Case:
| Blocking:
| Differential Revisions:
-------------------------------------+-------------------------------------
This started as a comment on #6135, but Jan Stolarek requested that I file
a separate report. The branchless tests `<#`, `>#`, `<=#`, and `>=#`, and
their wordy cousins, seem to work properly, but `==#` and `eqWord#` don't.
If I write
{{{#!hs
foo x = tagToEnum# ((x <# 3#) `orI#` (x ># 100#) `orI#`
(x ==# 12#) `orI#` (x ==# 15#))
}}}
I get (in 7.8.3 and in 7.9)
{{{#!hs
IsDigit.foo :: GHC.Prim.Int# -> GHC.Types.Bool
[GblId,
Arity=1,
Caf=NoCafRefs,
Str=DmdType <S,1*U>,
Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True,
WorkFree=True, Expandable=True,
Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=False)
Tmpl= \ (x3_a2if [Occ=Once!] :: GHC.Prim.Int#) ->
case x3_a2if of wild_Xe {
__DEFAULT ->
GHC.Prim.tagToEnum#
@ GHC.Types.Bool
(GHC.Prim.orI# (GHC.Prim.<# wild_Xe 3) (GHC.Prim.>#
wild_Xe 100));
12 -> GHC.Types.True;
15 -> GHC.Types.True
}}]
IsDigit.foo =
\ (x3_a2if :: GHC.Prim.Int#) ->
case x3_a2if of wild_Xe {
__DEFAULT ->
GHC.Prim.tagToEnum#
@ GHC.Types.Bool
(GHC.Prim.orI# (GHC.Prim.<# wild_Xe 3) (GHC.Prim.># wild_Xe
100));
12 -> GHC.Types.True;
15 -> GHC.Types.True
}}}
and branching assembly to match. Jan Stolarek indicates this is probably a
problem with constant folding.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9661>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list