[PATCH] Fix for bug in indvars/ SCEV generating infinite loop (pr18886)

Dinesh Dwivedi dinesh.d at samsung.com
Mon May 26 23:52:07 PDT 2014


Closed by commit rL209645 (authored by dinesh).

http://reviews.llvm.org/D3837

Files:
  llvm/trunk/test/Analysis/ScalarEvolution/max-trip-count.ll

Index: llvm/trunk/test/Analysis/ScalarEvolution/max-trip-count.ll
===================================================================
--- llvm/trunk/test/Analysis/ScalarEvolution/max-trip-count.ll
+++ llvm/trunk/test/Analysis/ScalarEvolution/max-trip-count.ll
@@ -125,6 +125,33 @@
   ret i32 0
 }
 
+; PR18886: Indvars miscompile due to an incorrect max backedge taken count from SCEV.
+; CHECK-LABEL: @pr18886
+; CHECK: Loop %for.body: <multiple exits> Unpredictable backedge-taken count. 
+; CHECK: Loop %for.body: max backedge-taken count is 3
+ at aa = global i64 0, align 8
+
+define i32 @pr18886() {
+entry:
+  store i64 -21, i64* @aa, align 8
+  br label %for.body
+
+for.body:
+  %storemerge1 = phi i64 [ -21, %entry ], [ %add, %for.cond ]
+  %tobool = icmp eq i64 %storemerge1, 0
+  %add = add nsw i64 %storemerge1, 8
+  br i1 %tobool, label %return, label %for.cond
+
+for.cond:
+  store i64 %add, i64* @aa, align 8
+  %cmp = icmp slt i64 %add, 9
+  br i1 %cmp, label %for.body, label %return
+
+return:
+  %retval.0 = phi i32 [ 1, %for.body ], [ 0, %for.cond ]
+  ret i32 %retval.0
+}
+
 ; Here we have a must-exit loop latch that is not computable and a
 ; may-exit early exit that can only have one non-exiting iteration
 ; before the check is forever skipped.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D3837.9822.patch
Type: text/x-patch
Size: 1271 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140527/31af160f/attachment.bin>


More information about the llvm-commits mailing list