From 9d83a26b8eef6c1e075b89804947b15b1851c30a Mon Sep 17 00:00:00 2001 From: Ben Gamari Date: Wed, 25 Sep 2019 16:58:20 -0400 Subject: nativeGen: Try fixing popcnt on i386 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. --- compiler/nativeGen/X86/CodeGen.hs | 4 +++- testsuite/tests/codeGen/should_run/all.T | 3 +-- 2 files changed, 4 insertions(+), 3 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) diff --git a/testsuite/tests/codeGen/should_run/all.T b/testsuite/tests/codeGen/should_run/all.T index 7e5ed24a7d..2a777f4c9d 100644 --- a/testsuite/tests/codeGen/should_run/all.T +++ b/testsuite/tests/codeGen/should_run/all.T @@ -79,8 +79,7 @@ test('cgrun069', ['cgrun069', [('cgrun069_cmm.cmm', '')], '']) test('cgrun070', normal, compile_and_run, ['']) test('cgrun071', - [when(have_cpu_feature('sse4_2'), extra_hc_opts('-msse4.2')), - when(arch('i386'), expect_broken(17247))], + [when(have_cpu_feature('sse4_2'), extra_hc_opts('-msse4.2'))], compile_and_run, ['']) test('cgrun072', normal, compile_and_run, ['']) test('cgrun075', normal, compile_and_run, ['']) -- cgit v1.2.1