Inlining of `any @[]` vs `elem @[]`

Simon Peyton Jones simonpj at microsoft.com
Fri Mar 12 10:40:55 UTC 2021


|  I wonder why that is? What changed between GHC 8.10.3 and 9.0.1? Was
|  the definition of `elem` changed in `base`?

I'm not sure... you could investigate, but I'm inclined just to declare victory!

S

|  -----Original Message-----
|  From: ÉRDI Gergő <gergo at erdi.hu>
|  Sent: 12 March 2021 10:02
|  To: Simon Peyton Jones <simonpj at microsoft.com>
|  Cc: GHC Devs <ghc-devs at haskell.org>
|  Subject: RE: Inlining of `any @[]` vs `elem @[]`
|  
|  On Thu, 11 Mar 2021, Simon Peyton Jones wrote:
|  
|  > With HEAD, and -O, I get the exact same (good code) for these two
|  functions:
|  >
|  > 	f x = any (x ==) [1, 5, 7::Int]
|  >
|  > 	g x = elem x [2, 6, 9 :: Int]
|  >
|  > Maybe this is fixed?  If you think not, maybe open a ticket?
|  
|  OK, so initially I tried it on GHC 8.10.3, which is where `elem @[]`
|  is not optimized. I have now tried on GHC 9.0.1, where, just like you
|  see on HEAD, indeed it gets it right.
|  
|  I wonder why that is? What changed between GHC 8.10.3 and 9.0.1? Was
|  the definition of `elem` changed in `base`?
|  
|  Thanks,
|   	Gergo


More information about the ghc-devs mailing list