summaryrefslogtreecommitdiff
path: root/compiler/nativeGen/X86/CodeGen.hs
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2019-09-25 16:58:20 -0400
committerBen Gamari <ben@smart-cactus.org>2019-09-25 16:58:20 -0400
commit9d83a26b8eef6c1e075b89804947b15b1851c30a (patch)
treee2e511d628e5389747e4c98f0cc4ac4196fbfa99 /compiler/nativeGen/X86/CodeGen.hs
parentc8f2cbe93590f0ee7ad3ec2b1b29f4b5d71c9440 (diff)
downloadhaskell-wip/T17247b.tar.gz
nativeGen: Try fixing popcnt on i386wip/T17247b
Just fall back to C case in the 64-bit case. Another approach would be to sum the population counts of the top and bottom 32-bits but this is more complexity than this case warrants. Fixes #17247.
Diffstat (limited to 'compiler/nativeGen/X86/CodeGen.hs')
-rw-r--r--compiler/nativeGen/X86/CodeGen.hs4
1 files changed, 3 insertions, 1 deletions
diff --git a/compiler/nativeGen/X86/CodeGen.hs b/compiler/nativeGen/X86/CodeGen.hs
index 9f0af9429d..8bbc9f5dfc 100644
--- a/compiler/nativeGen/X86/CodeGen.hs
+++ b/compiler/nativeGen/X86/CodeGen.hs
@@ -1940,7 +1940,9 @@ genCCall dflags is32Bit (PrimTarget (MO_PopCnt width)) dest_regs@[dst]
args@[src] bid = do
sse4_2 <- sse4_2Enabled
let platform = targetPlatform dflags
- if sse4_2
+ -- N.B. 64-bit population count is not supported on 32-bit platforms, even
+ -- with SSE4.2. Fall back to C implementation in this case
+ if sse4_2 && not (is32Bit && width == W64)
then do code_src <- getAnyReg src
src_r <- getNewRegNat format
let dst_r = getRegisterReg platform (CmmLocal dst)