[llvm-bugs] [Bug 36990] New: LLVM is missing loop splitting

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Apr 3 12:49:12 PDT 2018


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

            Bug ID: 36990
           Summary: LLVM is missing loop splitting
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: evstupac at gmail.com
                CC: llvm-bugs at lists.llvm.org

Even for a very simple case:

int foo(int *a, int n, int m) { 
  int s = 0; 
  int i; 
  for (i = 0; i < 1024; i++) 
    if (i != 512) 
      s += a[i]; 
  return s; 
} 

llvm is unable to split loop into 2:

int foo(int *a, int n, int m) { 
  int s = 0; 
  int i; 
  for (i = 0; i < 512; i++) 
    s += a[i]; 
  for (i = 513; i < 1024; i++) 
    s += a[i]; 
  return s; 
}

Generated IR:

; <label>:4:                                      ; preds = %12, %3 
  %5 = phi i64 [ 0, %3 ], [ %14, %12 ] 
  %6 = phi i32 [ 0, %3 ], [ %13, %12 ] 
  %7 = icmp eq i64 %5, 512 
  br i1 %7, label %12, label %8 

; <label>:8:                                      ; preds = %4 
  %9 = getelementptr inbounds i32, i32* %0, i64 %5 
  %10 = load i32, i32* %9, align 4, !tbaa !2 
  %11 = add nsw i32 %10, %6 
  br label %12 

; <label>:12:                                     ; preds = %4, %8 
  %13 = phi i32 [ %11, %8 ], [ %6, %4 ] 
  %14 = add nuw nsw i64 %5, 1 
  %15 = icmp eq i64 %14, 1024 
  br i1 %15, label %16, label %4, !llvm.loop !6 

; <label>:16:                                     ; preds = %12 
  ret i32 %13

-- 
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/20180403/e1dc97cb/attachment.html>


More information about the llvm-bugs mailing list