Skip to content
  • Benjamin Kramer's avatar
    Teach DAGCombine to fold fold (sra (trunc (sr x, c1)), c2) -> (trunc (sra x,... · 946e1522
    Benjamin Kramer authored
    Teach DAGCombine to fold fold (sra (trunc (sr x, c1)), c2) -> (trunc (sra x, c1+c2) when c1 equals the amount of bits that are truncated off.
    
    This happens all the time when a smul is promoted to a larger type.
    
    On x86-64 we now compile "int test(int x) { return x/10; }" into
      movslq  %edi, %rax
      imulq $1717986919, %rax, %rax
      movq  %rax, %rcx
      shrq  $63, %rcx
      sarq  $34, %rax <- used to be "shrq $32, %rax; sarl $2, %eax"
      addl  %ecx, %eax
    
    This fires 96 times in gcc.c on x86-64.
    
    llvm-svn: 124559
    946e1522
Loading