https://bugs.llvm.org/show_bug.cgi?id=39030

            Bug ID: 39030
           Summary: Inefficient codegen for and(not(shl(shr)))
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: AArch64
          Assignee: unassignedb...@nondot.org
          Reporter: eugeni.stepa...@gmail.com
                CC: llvm-bugs@lists.llvm.org

typedef unsigned long T;                                                        
// typedef long T;                                                              
T f(T a, T b) {                                                                 
  return b & ~((a >> 56) << 10);                                                
}

With T = long, the source above generates
  asr   x8, x0, #56
  bic   x0, x1, x8, lsl #10
  ret

With T = unsigned long, we produce much longer code
  lsr   x8, x0, #46
  mvn   w8, w8
  orr   x8, x8, #0xfffffffffffc03ff
  and   x0, x8, x1
  ret

A similar lsr + bic sequence is possible here too, but the BIC pattern does not
match because of the following generic transform (in DAGCombiner.cpp):
  // fold (shl (srl x, c1), c2) -> (and (shl x, (sub c2, c1), MASK) or          
  //                               (and (srl x, (sub c1, c2), MASK)             

Maybe this combine should not be used if it feeds into AND and TLI.hasAndNot()?

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to