Implement optimized NCG `MO_Ctz W64` op for i386 (#9340)
Implement optimized NCG `MO_Ctz W64` op for i386 (#9340)

Summary:
This is an optimization to the CTZ primops introduced for #9340

Previously we called out to `hs_ctz64`, but we can actually generate
better hand-tuned code while avoiding the FFI ccall.

With this patch, the code

  {-# LANGUAGE MagicHash #-}
  module TestClz0 where
  import GHC.Prim
  ctz64 :: Word64# -> Word#
  ctz64 x = ctz64# x

results in the following assembler generated by NCG on i386:

  TestClz.ctz64_info:
      movl (%ebp),%eax
      movl 4(%ebp),%ecx
      movl %ecx,%edx
      orl %eax,%edx
      movl $64,%edx
      je _nAO

      bsf %ecx,%ecx
      addl $32,%ecx
      bsf %eax,%eax
      cmovne %eax,%ecx
      movl %ecx,%edx
  _nAO:
      movl %edx,%esi
      addl $8,%ebp
      jmp *(%ebp)

For comparision, here's what LLVM 3.4 currently generates:

  000000fc <TestClzz_ctzz64_info>:
    fc:   0f bc 45 04             bsf    0x4(%ebp),%eax
   100:   b9 20 00 00 00          mov    $0x20,%ecx
   105:   0f 45 c8                cmovne %eax,%ecx
   108:   83 c1 20                add    $0x20,%ecx
   10b:   8b 45 00                mov    0x0(%ebp),%eax
   10e:   8b 55 08                mov    0x8(%ebp),%edx
   111:   0f bc f0                bsf    %eax,%esi
   114:   85 c0                   test   %eax,%eax
   116:   0f 44 f1                cmove  %ecx,%esi
   119:   83 c5 08                add    $0x8,%ebp
   11c:   ff e2                   jmp    *%edx

Reviewed By: austin

Auditors: simonmar

Differential Revision: https://phabricator.haskell.org/D163

siddhanathan/ghc,mcschroeder/ghc,vikraman/ghc,mfine/ghc,nathyong/microghc-ghc,mcschroeder/ghc,ml9951/ghc,forked-upstream-packages-for-ghcjs/ghc,olsner/ghc,forked-upstream-packages-for-ghcjs/ghc,TomMD/ghc,GaloisInc/halvm-ghc,nushio3/ghc,elieux/ghc,gcampax/ghc,gridaphobe/ghc,nushio3/ghc,acowley/ghc,olsner/ghc,urbanslug/ghc,siddhanathan/ghc,AlexanderPankiv/ghc,bitemyapp/ghc,vTurbine/ghc,snoyberg/ghc,vikraman/ghc,TomMD/ghc,nathyong/microghc-ghc,vikraman/ghc,sgillespie/ghc,urbanslug/ghc,ezyang/ghc,tjakway/ghcjvm,fmthoma/ghc,TomMD/ghc,nkaretnikov/ghc,ml9951/ghc,TomMD/ghc,shlevy/ghc,olsner/ghc,gcampax/ghc,wxwxwwxxx/ghc,green-haskell/ghc,vTurbine/ghc,oldmanmike/ghc,shlevy/ghc,forked-upstream-packages-for-ghcjs/ghc,GaloisInc/halvm-ghc,AlexanderPankiv/ghc,acowley/ghc,TomMD/ghc,mettekou/ghc,forked-upstream-packages-for-ghcjs/ghc,mettekou/ghc,sdiehl/ghc,christiaanb/ghc,anton-dessiatov/ghc,forked-upstream-packages-for-ghcjs/ghc,nushio3/ghc,wxwxwwxxx/ghc,mcschroeder/ghc,wxwxwwxxx/ghc,tjakway/ghcjvm,acowley/ghc,AlexanderPankiv/ghc,anton-dessiatov/ghc,GaloisInc/halvm-ghc,vTurbine/ghc,urbanslug/ghc,ml9951/ghc,nathyong/microghc-ghc,anton-dessiatov/ghc,gcampax/ghc,ghc-android/ghc,shlevy/ghc,sdiehl/ghc,nathyong/microghc-ghc,TomMD/ghc,elieux/ghc,ezyang/ghc,mcschroeder/ghc,tjakway/ghcjvm,anton-dessiatov/ghc,mfine/ghc,oldmanmike/ghc,tjakway/ghcjvm,fmthoma/ghc,vikraman/ghc,mettekou/ghc,sdiehl/ghc,nkaretnikov/ghc,ghc-android/ghc,nkaretnikov/ghc,ezyang/ghc,da-x/ghc,gcampax/ghc,christiaanb/ghc,oldmanmike/ghc,sgillespie/ghc,anton-dessiatov/ghc,nkaretnikov/ghc,tjakway/ghcjvm,green-haskell/ghc,ezyang/ghc,acowley/ghc,oldmanmike/ghc,sgillespie/ghc,jstolarek/ghc,ml9951/ghc,ezyang/ghc,oldmanmike/ghc,vikraman/ghc,da-x/ghc,wxwxwwxxx/ghc,nathyong/microghc-ghc,christiaanb/ghc,ml9951/ghc,vTurbine/ghc,nathyong/microghc-ghc,mfine/ghc,AlexanderPankiv/ghc,olsner/ghc,urbanslug/ghc,christiaanb/ghc,elieux/ghc,olsner/ghc,shlevy/ghc,tjakway/ghcjvm,mcschroeder/ghc,mettekou/ghc,olsner/ghc,AlexanderPankiv/ghc,elieux/ghc,bitemyapp/ghc,gcampax/ghc,olsner/ghc,urbanslug/ghc,urbanslug/ghc,acowley/ghc,anton-dessiatov/ghc,elieux/ghc,anton-dessiatov/ghc,siddhanathan/ghc,snoyberg/ghc,mettekou/ghc,da-x/ghc,mfine/ghc,vTurbine/ghc,gcampax/ghc,green-haskell/ghc,siddhanathan/ghc,ghc-android/ghc,snoyberg/ghc,vTurbine/ghc,ghc-android/ghc,snoyberg/ghc,ghc-android/ghc,forked-upstream-packages-for-ghcjs/ghc,snoyberg/ghc,snoyberg/ghc,wxwxwwxxx/ghc,jstolarek/ghc,shlevy/ghc,mcschroeder/ghc,nkaretnikov/ghc,nkaretnikov/ghc,mettekou/ghc,ghc-android/ghc,GaloisInc/halvm-ghc,nushio3/ghc,elieux/ghc,gridaphobe/ghc,nkaretnikov/ghc,siddhanathan/ghc,gcampax/ghc,da-x/ghc,mcschroeder/ghc,green-haskell/ghc,sgillespie/ghc,mfine/ghc,vikraman/ghc,acowley/ghc,christiaanb/ghc,nushio3/ghc,gridaphobe/ghc,oldmanmike/ghc,da-x/ghc,siddhanathan/ghc,GaloisInc/halvm-ghc,gridaphobe/ghc,jstolarek/ghc,nushio3/ghc,gridaphobe/ghc,fmthoma/ghc,vTurbine/ghc,vikraman/ghc,fmthoma/ghc,mettekou/ghc,christiaanb/ghc,fmthoma/ghc,acowley/ghc,shlevy/ghc,fmthoma/ghc,ml9951/ghc,AlexanderPankiv/ghc,sgillespie/ghc,bitemyapp/ghc,wxwxwwxxx/ghc,gridaphobe/ghc,sdiehl/ghc,siddhanathan/ghc,ezyang/ghc,ghc-android/ghc,jstolarek/ghc,sgillespie/ghc,mfine/ghc,ezyang/ghc,GaloisInc/halvm-ghc,forked-upstream-packages-for-ghcjs/ghc,mfine/ghc,elieux/ghc,sdiehl/ghc,snoyberg/ghc,fmthoma/ghc,AlexanderPankiv/ghc,nushio3/ghc,GaloisInc/halvm-ghc,TomMD/ghc,da-x/ghc,ml9951/ghc,shlevy/ghc,gridaphobe/ghc,tjakway/ghcjvm,da-x/ghc,nathyong/microghc-ghc,sdiehl/ghc,sgillespie/ghc,green-haskell/ghc,ml9951/ghc,jstolarek/ghc,oldmanmike/ghc,bitemyapp/ghc,christiaanb/ghc,bitemyapp/ghc,wxwxwwxxx/ghc,urbanslug/ghc,sdiehl/ghc