[GHC] #8256: adding locality levels to prefetch# and friends

GHC ghc-devs at haskell.org
Thu Sep 19 06:18:11 CEST 2013


#8256: adding locality levels to prefetch# and friends
-------------------------------------+------------------------------------
        Reporter:  carter            |            Owner:  carter
            Type:  task              |           Status:  patch
        Priority:  normal            |        Milestone:  7.8.1
       Component:  Compiler          |          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:  #8252 ,#8107
-------------------------------------+------------------------------------

Comment (by carter):

 I wrote some C code to see what the code gen in clang does for that asm

 {{{
 // void __builtin_prefetch (const void *addr, ...)


 void prefetchnta(const void *addr){

      __builtin_prefetch(addr, 0,0);
 }

 void prefetch2(const void *addr){

      __builtin_prefetch(addr, 0,1);
 }

 void prefetch1(const void *addr){

      __builtin_prefetch(addr, 0,2);
 }


 void prefetch0(const void *addr){

      __builtin_prefetch(addr, 0,3);
 }
 }}


 the asm generated is

 {{{

         .section        __TEXT,__text,regular,pure_instructions
         .globl  _prefetchnta
         .align  4, 0x90
 _prefetchnta:                           ## @prefetchnta
         .cfi_startproc
 ## BB#0:
         pushq   %rbp
 Ltmp2:
         .cfi_def_cfa_offset 16
 Ltmp3:
         .cfi_offset %rbp, -16
         movq    %rsp, %rbp
 Ltmp4:
         .cfi_def_cfa_register %rbp
         movq    %rdi, -8(%rbp)
         movq    -8(%rbp), %rdi
         prefetchnta     (%rdi)
         popq    %rbp
         ret
         .cfi_endproc

         .globl  _prefetch2
         .align  4, 0x90
 _prefetch2:                             ## @prefetch2
         .cfi_startproc
 ## BB#0:
         pushq   %rbp
 Ltmp7:
         .cfi_def_cfa_offset 16
 Ltmp8:
         .cfi_offset %rbp, -16
         movq    %rsp, %rbp
 Ltmp9:
         .cfi_def_cfa_register %rbp
         movq    %rdi, -8(%rbp)
         movq    -8(%rbp), %rdi
         prefetcht2      (%rdi)
         popq    %rbp
         ret
         .cfi_endproc

         .globl  _prefetch1
         .align  4, 0x90
 _prefetch1:                             ## @prefetch1
         .cfi_startproc
 ## BB#0:
         pushq   %rbp
 Ltmp12:
         .cfi_def_cfa_offset 16
 Ltmp13:
         .cfi_offset %rbp, -16
         movq    %rsp, %rbp
 Ltmp14:
         .cfi_def_cfa_register %rbp
         movq    %rdi, -8(%rbp)
         movq    -8(%rbp), %rdi
         prefetcht1      (%rdi)
         popq    %rbp
         ret
         .cfi_endproc

         .globl  _prefetch0
         .align  4, 0x90
 _prefetch0:                             ## @prefetch0
         .cfi_startproc
 ## BB#0:
         pushq   %rbp
 Ltmp17:
         .cfi_def_cfa_offset 16
 Ltmp18:
         .cfi_offset %rbp, -16
         movq    %rsp, %rbp
 Ltmp19:
         .cfi_def_cfa_register %rbp
         movq    %rdi, -8(%rbp)
         movq    -8(%rbp), %rdi
         prefetcht0      (%rdi)
         popq    %rbp
         ret
         .cfi_endproc


 .subsections_via_symbols


 }}}

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



More information about the ghc-tickets mailing list