[GHC] #8311: suboptimal code generated for even :: Int -> Bool by NCG (x86, x86_64)

#8311: suboptimal code generated for even :: Int -> Bool by NCG (x86, x86_64)
------------------------------------+-------------------------------------
Reporter: rwbarton | Owner:
Type: feature request | Status: new
Priority: normal | Milestone:
Component: Compiler (NCG) | Version: 7.7
Keywords: | Operating System: Unknown/Multiple
Architecture: Unknown/Multiple | Type of failure: None/Unknown
Difficulty: Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: |
------------------------------------+-------------------------------------
This appears to be the x86 assembly for a specialization for `even :: Int
-> Bool` that's produced by a SPECIALISE pragma for `(^) :: Int -> Int ->
Int` in GHC.Real. The relevant bit is offsets `0x2c` through `0x3b`.
{{{
0000000c

#8311: suboptimal code generated for even :: Int -> Bool by NCG (x86, x86_64) -------------------------------------+------------------------------------ Reporter: rwbarton | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler (NCG) | Version: 7.7 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------ Changes (by simonpj): * cc: simonmar (added) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8311#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8311: suboptimal code generated for even :: Int -> Bool by NCG (x86, x86_64) -------------------------------------+------------------------------------ Reporter: rwbarton | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler (NCG) | Version: 7.7 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------ Comment (by simonpj): Could you give us the source Haskell code, and how you compiled it, that gives this sub-optimal result? Thanks! Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8311#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8311: suboptimal code generated for even :: Int -> Bool by NCG (x86, x86_64) -------------------------------------+------------------------------------ Reporter: rwbarton | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler (NCG) | Version: 7.7 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------ Comment (by rwbarton): The source of that code is in GHC.Real in base, but for reproducing, use this: {{{ module Even where myEven :: Int -> Bool myEven n = n `rem` 2 == 0 }}} compiled with `ghc -O2 -o Even.o -c Even.hs`. The LLVM backend (`ghc -O2 -fllvm -o Even.o -c Even.hs`) does produce a `testb $0x1,0x3(%esi)` instruction. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8311#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8311: suboptimal code generated for even :: Int -> Bool by NCG (x86, x86_64) -------------------------------------+------------------------------------ Reporter: rwbarton | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler (NCG) | Version: 7.7 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------ Changes (by carter): * cc: carter.schonwald@… (added) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8311#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8311: suboptimal code generated for even :: Int -> Bool by NCG (x86, x86_64) -------------------------------------+------------------------------------ Reporter: rwbarton | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler (NCG) | Version: 7.7 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: #9188 -------------------------------------+------------------------------------ Changes (by rwbarton): * related: => #9188 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8311#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8311: suboptimal code generated for even :: Int -> Bool by NCG (x86, x86_64) -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: Type: feature | Status: new request | Milestone: Priority: normal | Version: 7.7 Component: Compiler | Keywords: (NCG) | Architecture: Unknown/Multiple Resolution: | Difficulty: Unknown Operating System: | Blocked By: Unknown/Multiple | Related Tickets: #5615 Type of failure: Runtime | performance bug | Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Changes (by thomie): * failure: None/Unknown => Runtime performance bug * related: #9188 => #5615 Comment: #9188 was closed as a duplicate of #5615. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8311#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC