(== <literal>) not matching in rules
Donald Bruce Stewart
dons at cse.unsw.edu.au
Thu Aug 24 02:45:42 EDT 2006
With the new liberalised rule syntax, I can write:
{-# RULES
"FPS specialise break (x==)" forall x.
break (x==) = breakByte x
"FPS specialise break (==x)" forall x.
break (==x) = breakByte x
#-}
Which is very useful (Data.ByteString can detect these an substitute in a
memchr, must faster). The following works nicely:
import qualified Data.ByteString as P
main = do
ps <- P.getContents
print $ P.break (==c) ps
c = 50
3 RuleFired
1 FPS specialise break (==x)
1 int2Word#
1 narrow8Word#
However, if I inline the constant, the rule refuses to fire:
import qualified Data.ByteString as P
main = do
ps <- P.getContents
print $ P.break (==50) ps
2 RuleFired
1 int2Word#
1 narrow8Word#
Rewriting without sections and it still fails:
import qualified Data.ByteString as P
main = do
ps <- P.getContents
print $ P.break ((==) 50) ps
The Core looks like:
print_a13O (Data.ByteString.break (==_a1tG lit_a1tF) ps_aBu))
==_a1tG :: GHC.Word.Word8 -> GHC.Word.Word8 -> GHC.Base.Bool
==_a1tG = GHC.Base.== @ GHC.Word.Word8 (GHC.Num.$p1Num @ GHC.Word.Word8 GHC.Word.$f37)
Could this funny ==_a1tG be getting in the way?
This is with today's HEAD including the ByteString patches I just pushed:
Thu Aug 24 11:26:11 EST 2006 Don Stewart <dons at cse.unsw.edu.au>
* Add spec rules for sections in Data.ByteString
-- Don
More information about the Cvs-ghc
mailing list