[llvm-bugs] [Bug 35131] New: [LoopIdiomRecognize] Incorrectly recognizes CTLZ

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Oct 30 07:03:33 PDT 2017


            Bug ID: 35131
           Summary: [LoopIdiomRecognize] Incorrectly recognizes CTLZ
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: igor at azulsystems.com
                CC: llvm-bugs at lists.llvm.org

On the following test case loop is recognized as CTLZ, but in fact it is not:

define i32 @ctlz(i32 %n) {
  br label %while.cond

while.cond:                                       ; preds = %while.cond, %entry
  %n.addr.0 = phi i32 [ %n, %entry ], [ %shr, %while.cond ]
  %i.0 = phi i32 [ 0, %entry ], [ %inc, %while.cond ]
  %shr = ashr i32 %n.addr.0, %i.0
  %tobool = icmp eq i32 %shr, 0
  %inc = add nsw i32 %i.0, 1
  br i1 %tobool, label %while.end, label %while.cond

while.end:                                        ; preds = %while.cond
  ret i32 %i.0

Problem here happens because "ashr i32 %n.addr.0, %i.0" is treated as if it was
"ashr i32 %n.addr.0, which is not true.

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/20171030/42efe9c8/attachment.html>

More information about the llvm-bugs mailing list