[GHC] #14359: C-- pipeline/NCG fails to optimize simple repeated addition

GHC ghc-devs at haskell.org
Tue Oct 17 05:33:48 UTC 2017


#14359: C-- pipeline/NCG fails to optimize simple repeated addition
-------------------------------------+-------------------------------------
        Reporter:  bgamari           |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  low               |            Milestone:
       Component:  Compiler          |              Version:  8.2.1
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  Runtime           |  Unknown/Multiple
  performance bug                    |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by alexbiehl):

 Actually compiling `PrimOps.cmm` with `-O` already results in the desired
 constant folding:


 {{{
 $ ghc -ddump-asm -c rts/PrimOps.cmm | less
 ...
 stg_newPinnedByteArrayzh:
 _cv:
         movq 888(%r13),%rax
         cmpq $0,16(%rax)
         je _cl
 _cn:
         movq g0 at GOTPCREL(%rip),%rax
         movq (%rax),%rax
         movq 56(%rax),%rax
         movq large_alloc_lim at GOTPCREL(%rip),%rcx
         cmpq (%rcx),%rax
         jae _cl
 _co:
         subq $8,%rsp
         leaq -24(%r13),%rax
         leaq 38(%rbx),%rsi <- see here
         shrq $3,%rsi
         movq %rax,%rdi
         xorl %eax,%eax
         call allocatePinned
         addq $8,%rsp
         testq %rax,%rax
 ...
 }}}

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14359#comment:2>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list