Skip to content

slightly silly assembly for testing whether a Word# is 0##

{-# LANGUAGE MagicHash #-}

module Zero where

import GHC.Exts

f :: Word# -> Word#
f 0## = 1##
f x## = x##

in HEAD produces

0000000000000018 <ZZero_f_info>:
  18:	49 83 fe 01          	cmp    $0x1,%r14
  1c:	72 06                	jb     24 <ZZero_f_info+0xc>
  1e:	4c 89 f3             	mov    %r14,%rbx
  21:	ff 65 00             	jmpq   *0x0(%rbp)
  24:	bb 01 00 00 00       	mov    $0x1,%ebx
  29:	ff 65 00             	jmpq   *0x0(%rbp)

Well, cmp $0x1,%r14/jb isn't wrong. But it's a byte longer than test %r14,%r14/je, so the latter should be preferred.

GHC 7.10 produced the test/je version, so I'm guessing this is a side effect of nomeata's work on #10137 (closed).

Trac metadata
Trac field Value
Version 7.11
Type Bug
TypeOfFailure OtherFailure
Priority low
Resolution Unresolved
Component Compiler (CodeGen)
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information