[llvm-bugs] [Bug 39030] New: Inefficient codegen for and(not(shl(shr)))

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Sep 20 16:02:14 PDT 2018


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: unassignedbugs at nondot.org
          Reporter: eugeni.stepanov at gmail.com
                CC: llvm-bugs at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180920/0e308c15/attachment.html>


More information about the llvm-bugs mailing list