[GHC] #9435: x86 sse4.2 popCnt16# needs to zero-extend its result
#9435: x86 sse4.2 popCnt16# needs to zero-extend its result -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (NCG) | Version: 7.9 Keywords: | Operating System: Architecture: x86_64 (amd64) | Unknown/Multiple Difficulty: Unknown | Type of failure: Incorrect Blocked By: | result at runtime Related Tickets: | Test Case: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- `make TEST=cgrun071 EXTRA_HC_OPTS=-msse42` fails for me in all the non- ghci non-llvm ways. For `popCnt16#` we emit `popcnt %ax,%ax` which doesn't clear the high 48 bits of the result. Patch incoming. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9435> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#9435: x86 sse4.2 popCnt16# needs to zero-extend its result -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.9 (NCG) | Keywords: Resolution: | Architecture: x86_64 (amd64) Operating System: | Difficulty: Unknown Unknown/Multiple | Blocked By: Type of failure: Incorrect | Related Tickets: result at runtime | Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by rwbarton): `popCnt8#` is affected too, but (possibly by luck, possibly not) we reuse the source register as the destination register and we needed to zero- extend the source anyways as there is no 8-bit `popcnt` instruction. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9435#comment:1> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#9435: x86 sse4.2 popCnt16# needs to zero-extend its result -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.9 (NCG) | Keywords: Resolution: | Architecture: x86_64 (amd64) Operating System: | Difficulty: Unknown Unknown/Multiple | Blocked By: Type of failure: Incorrect | Related Tickets: result at runtime | Test Case: | Blocking: | Differential Revisions: Phab:D147 | -------------------------------------+------------------------------------- Changes (by rwbarton): * differential: => Phab:D147 -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9435#comment:2> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#9435: x86 sse4.2 popCnt16# needs to zero-extend its result -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.9 (NCG) | Keywords: Resolution: | Architecture: x86_64 (amd64) Operating System: | Difficulty: Unknown Unknown/Multiple | Blocked By: Type of failure: Incorrect | Related Tickets: result at runtime | Test Case: | Blocking: | Differential Revisions: Phab:D147 | -------------------------------------+------------------------------------- Comment (by Reid Barton <rwbarton@…>): In [changeset:"64151913f1ed32ecfe17fcc40f7adc6cbfbb0bc1/ghc"]: {{{ #!CommitTicketReference repository="ghc" revision="64151913f1ed32ecfe17fcc40f7adc6cbfbb0bc1" x86: zero extend the result of 16-bit popcnt instructions (#9435) Summary: The 'popcnt r16, r/m16' instruction only writes the low 16 bits of the destination register, so we have to zero-extend the result to a full word as popCnt16# is supposed to return a Word#. For popCnt8# we could instead zero-extend the input to 32 bits and then do a 32-bit popcnt, and not have to zero-extend the result. LLVM produces the 16-bit popcnt sequence with two zero extensions, though, and who am I to argue? Test Plan: - ran "make TEST=cgrun071 EXTRA_HC_OPTS=-msse42" - then ran again adding "WAY=optasm", and verified that the popcnt sequences we generate match the ones produced by LLVM for its @llvm.ctpop.* intrinsics Reviewers: austin, hvr, tibbe Reviewed By: austin, hvr, tibbe Subscribers: phaskell, hvr, simonmar, relrod, ezyang, carter Differential Revision: https://phabricator.haskell.org/D147 GHC Trac Issues: #9435 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9435#comment:3> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#9435: x86 sse4.2 popCnt16# needs to zero-extend its result -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: Type: bug | Status: merge Priority: normal | Milestone: Component: Compiler | Version: 7.9 (NCG) | Keywords: Resolution: | Architecture: x86_64 (amd64) Operating System: | Difficulty: Unknown Unknown/Multiple | Blocked By: Type of failure: Incorrect | Related Tickets: result at runtime | Test Case: | Blocking: | Differential Revisions: Phab:D147 | -------------------------------------+------------------------------------- Changes (by rwbarton): * status: new => merge Comment: Marking as "merge" per hvr's suggestion. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9435#comment:4> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#9435: x86 sse4.2 popCnt16# needs to zero-extend its result -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: Type: bug | Status: closed Priority: normal | Milestone: 7.8.4 Component: Compiler | Version: 7.9 (NCG) | Keywords: Resolution: fixed | Architecture: x86_64 (amd64) Operating System: | Difficulty: Unknown Unknown/Multiple | Blocked By: Type of failure: Incorrect | Related Tickets: result at runtime | Test Case: | Blocking: | Differential Revisions: Phab:D147 | -------------------------------------+------------------------------------- Changes (by thoughtpolice): * status: merge => closed * resolution: => fixed * milestone: => 7.8.4 Comment: Merged to 7.8.4. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9435#comment:5> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
participants (1)
-
GHC