[llvm-bugs] [Bug 28620] New: [indvars] Redundant loop increment after IV widening

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Jul 19 14:55:22 PDT 2016


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

            Bug ID: 28620
           Summary: [indvars] Redundant loop increment after IV widening
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: apilipenko at azulsystems.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

Created attachment 16770
  --> https://llvm.org/bugs/attachment.cgi?id=16770&action=edit
Reproducer

On the following loop indvars creates a wider IV but fails to eliminate a
narrow type increment leading to an extra computation inside of the loop:

 loop:
  %i = phi i32 [ %i.next, %loop ], [ %i.entry, %entry ]

  %guard.cond = icmp ult i32 %i, %guard.1.limit
  call void (i1, ...) @llvm.experimental.guard(i1 %guard.cond, i32 9) [
"deopt"(i32 1) ]

  %i.zext = zext i32 %i to i64
  call void @consume(i64 %i.zext)

  %i.next = add i32 %i, 1
  %go.next = icmp slt i32 %i.next, %n
  br i1 %go.next, label %loop, label %exit

After indvars:

 loop:
  %indvars.iv = phi i64 [ %indvars.iv.next, %loop ], [ %0, %entry ]
  %guard.cond = icmp ult i64 %indvars.iv, %1
  call void (i1, ...) @llvm.experimental.guard(i1 %guard.cond, i32 9) [
"deopt"(i32 1) ]
  call void @consume(i64 %indvars.iv)
  %2 = trunc i64 %indvars.iv to i32
  %i.next = add i32 %2, 1
  %go.next = icmp slt i32 %i.next, %n
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  br i1 %go.next, label %loop, label %exit

The problem is not specific to guards, lowering it before indvars leads to the
same result.

-- 
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/20160719/4c45af4d/attachment.html>


More information about the llvm-bugs mailing list