[GHC] #10677: slightly silly assembly for testing whether a Word# is 0##

#10677: slightly silly assembly for testing whether a Word# is 0##
-------------------------------------+-------------------------------------
Reporter: rwbarton | Owner:
Type: bug | Status: new
Priority: low | Milestone:
Component: Compiler | Version: 7.11
(CodeGen) |
Keywords: | Operating System: Unknown/Multiple
Architecture: x86_64 | Type of failure: Runtime
(amd64) | performance bug
Test Case: | Blocked By:
Blocking: | Related Tickets:
Differential Revisions: |
-------------------------------------+-------------------------------------
{{{
{-# LANGUAGE MagicHash #-}
module Zero where
import GHC.Exts
f :: Word# -> Word#
f 0## = 1##
f x## = x##
}}}
in HEAD produces
{{{
0000000000000018

#10677: slightly silly assembly for testing whether a Word# is 0## -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: Type: bug | Status: new Priority: low | Milestone: Component: Compiler | Version: 7.11 (CodeGen) | Resolution: | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: x86_64 Type of failure: Runtime | (amd64) performance bug | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by rwbarton): * keywords: => newcomer Comment: This is probably pretty easy to fix as a special case in the Cmm switch->branches code. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10677#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10677: slightly silly assembly for testing whether a Word# is 0## -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: Type: bug | Status: new Priority: low | Milestone: Component: Compiler | Version: 7.11 (CodeGen) | Resolution: | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: x86_64 Type of failure: Runtime | (amd64) performance bug | Test Case: Blocked By: | Blocking: Related Tickets: #10750 | Differential Revisions: -------------------------------------+------------------------------------- Changes (by rwbarton): * related: => #10750 Comment: See also #10750 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10677#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10677: slightly silly assembly for testing whether a Word# is 0## -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: Type: bug | Status: new Priority: low | Milestone: Component: Compiler | Version: 7.11 (CodeGen) | Resolution: | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: x86_64 Type of failure: Runtime | (amd64) performance bug | Test Case: Blocked By: | Blocking: Related Tickets: #10750 | Differential Revisions: -------------------------------------+------------------------------------- Comment (by nomeata): Is there a good way to have test cases for these issues? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10677#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10677: slightly silly assembly for testing whether a Word# is 0## -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: Type: bug | Status: new Priority: low | Milestone: Component: Compiler | Version: 7.11 (CodeGen) | Resolution: | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: x86_64 Type of failure: Runtime | (amd64) performance bug | Test Case: Blocked By: | Blocking: Related Tickets: #10750 | Differential Revisions: -------------------------------------+------------------------------------- Comment (by nomeata): I tried to fix this, but now (presumably due to a later optimization) it produces {{{ testq %r14,%r14 jne _cQl }}} I hope that is ok as well. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10677#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10677: slightly silly assembly for testing whether a Word# is 0## -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: Type: bug | Status: patch Priority: low | Milestone: Component: Compiler | Version: 7.11 (CodeGen) | Resolution: | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: x86_64 Type of failure: Runtime | (amd64) performance bug | Test Case: Blocked By: | Blocking: Related Tickets: #10750 | Differential Revisions: Phab:D1137 -------------------------------------+------------------------------------- Changes (by nomeata): * status: new => patch * differential: => Phab:D1137 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10677#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10677: slightly silly assembly for testing whether a Word# is 0## -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: Type: bug | Status: patch Priority: low | Milestone: Component: Compiler | Version: 7.11 (CodeGen) | Resolution: | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: x86_64 Type of failure: Runtime | (amd64) performance bug | Test Case: Blocked By: | Blocking: Related Tickets: #10750 | Differential Revisions: Phab:D1137 -------------------------------------+------------------------------------- Comment (by rwbarton): Replying to [comment:3 nomeata]:
Is there a good way to have test cases for these issues?
I tried to fix this, but now (presumably due to a later optimization) it
Maybe grep `-ddump-opt-cmm` output for the condition `if (%MO_F_Gt_W64(...` and check that it compares something to 0, not 1? Replying to [comment:4 nomeata]: produces
{{{ testq %r14,%r14 jne _cQl }}}
I hope that is ok as well.
Yes, that's just as good (generally speaking, in any particular case one may be better than the other because they imply different basic block layouts, but understanding that is a whole separate issue). -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10677#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10677: slightly silly assembly for testing whether a Word# is 0##
-------------------------------------+-------------------------------------
Reporter: rwbarton | Owner:
Type: bug | Status: patch
Priority: low | Milestone:
Component: Compiler | Version: 7.11
(CodeGen) |
Resolution: | Keywords: newcomer
Operating System: Unknown/Multiple | Architecture: x86_64
Type of failure: Runtime | (amd64)
performance bug | Test Case:
Blocked By: | Blocking:
Related Tickets: #10750 | Differential Revisions: Phab:D1137
-------------------------------------+-------------------------------------
Comment (by Joachim Breitner

#10677: slightly silly assembly for testing whether a Word# is 0## -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: Type: bug | Status: closed Priority: low | Milestone: Component: Compiler | Version: 7.11 (CodeGen) | Resolution: fixed | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: x86_64 Type of failure: Runtime | (amd64) performance bug | Test Case: Blocked By: | Blocking: Related Tickets: #10750 | Differential Revisions: Phab:D1137 -------------------------------------+------------------------------------- Changes (by nomeata): * status: patch => closed * resolution: => fixed -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10677#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10677: slightly silly assembly for testing whether a Word# is 0## -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: Type: bug | Status: closed Priority: low | Milestone: Component: Compiler | Version: 7.11 (CodeGen) | Resolution: fixed | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: x86_64 Type of failure: Runtime | (amd64) performance bug | Test Case: Blocked By: | Blocking: Related Tickets: #10750 | Differential Revisions: Phab:D1137 -------------------------------------+------------------------------------- Comment (by nomeata): This causes a `+ 15.08%` runtime regression in fannkuch-redux: https://perf.haskell.org/ghc/#graph/nofib/time/fannkuch- redux;hl=92f35cd9829db7555397aa3dc8cd243d17694fee This is a bit strange... is this just a possible reordering of basic blocks? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10677#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10677: slightly silly assembly for testing whether a Word# is 0## -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: Type: bug | Status: closed Priority: low | Milestone: Component: Compiler | Version: 7.11 (CodeGen) | Resolution: fixed | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: x86_64 Type of failure: Runtime | (amd64) performance bug | Test Case: Blocked By: | Blocking: Related Tickets: #10750 | Differential Revisions: Phab:D1137 -------------------------------------+------------------------------------- Comment (by rwbarton): I would guess so. Maybe worth further investigation though. Another possible cause is #8279. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10677#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC