[llvm] 35b0b1a - [test] Prcommit tests for D108651

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 24 14:19:02 PDT 2021


Author: Philip Reames
Date: 2021-08-24T14:18:58-07:00
New Revision: 35b0b1a64af58f25fc8467d3348703439be19f29

URL: https://github.com/llvm/llvm-project/commit/35b0b1a64af58f25fc8467d3348703439be19f29
DIFF: https://github.com/llvm/llvm-project/commit/35b0b1a64af58f25fc8467d3348703439be19f29.diff

LOG: [test] Prcommit tests for D108651

Added: 
    llvm/test/Analysis/ScalarEvolution/trip-count-implied-addrec.ll

Modified: 
    

Removed: 
    


################################################################################
diff  --git a/llvm/test/Analysis/ScalarEvolution/trip-count-implied-addrec.ll b/llvm/test/Analysis/ScalarEvolution/trip-count-implied-addrec.ll
new file mode 100644
index 0000000000000..78655485af9aa
--- /dev/null
+++ b/llvm/test/Analysis/ScalarEvolution/trip-count-implied-addrec.ll
@@ -0,0 +1,69 @@
+; RUN: opt < %s -analyze -enable-new-pm=0 -scalar-evolution -scalar-evolution-classify-expressions=0 | FileCheck %s
+; RUN: opt < %s -disable-output "-passes=print<scalar-evolution>"  -scalar-evolution-classify-expressions=0 2>&1 | FileCheck %s
+
+; A collection of tests that show we can use facts about an exit test to
+; infer tighter bounds on an IV, and thus refine an IV into an addrec. The
+; basic tactic being used is proving NW from exit structure and then
+; implying NUW/NSW.  Once NSW/NUW is inferred, we can derive addrecs from
+; the zext/sext cases that we couldn't at initial SCEV construction.
+
+ at G = external global i8
+
+; CHECK-LABEL: Determining loop execution counts for: @nw_implies_nuw
+; CHECK: Loop %for.body: Unpredictable backedge-taken count
+; CHECK: Loop %for.body: Unpredictable max backedge-taken count
+define void @nw_implies_nuw(i16 %n) mustprogress {
+entry:
+  br label %for.body
+
+for.body:                                         ; preds = %entry, %for.body
+  %iv = phi i8 [ %iv.next, %for.body ], [ 0, %entry ]
+  %iv.next = add i8 %iv, 1
+  %zext = zext i8 %iv to i16
+  %cmp = icmp ult i16 %zext, %n
+  br i1 %cmp, label %for.body, label %for.end
+
+for.end:                                          ; preds = %for.body, %entry
+  ret void
+}
+
+; CHECK-LABEL: Determining loop execution counts for: @nw_implies_nsw
+; CHECK: Loop %for.body: Unpredictable backedge-taken count
+; CHECK: Loop %for.body: Unpredictable max backedge-taken count
+define void @nw_implies_nsw(i16 %n) mustprogress {
+entry:
+  br label %for.body
+
+for.body:                                         ; preds = %entry, %for.body
+  %iv = phi i8 [ %iv.next, %for.body ], [ -128, %entry ]
+  %iv.next = add i8 %iv, 1
+  %zext = sext i8 %iv to i16
+  %cmp = icmp slt i16 %zext, %n
+  br i1 %cmp, label %for.body, label %for.end
+
+for.end:                                          ; preds = %for.body, %entry
+  ret void
+}
+
+
+; CHECK-LABEL: Determining loop execution counts for: @actually_infinite
+; CHECK: Loop %for.body: Unpredictable backedge-taken count
+; CHECK: Loop %for.body: Unpredictable max backedge-taken count
+define void @actually_infinite() {
+entry:
+  br label %for.body
+
+for.body:                                         ; preds = %entry, %for.body
+  %iv = phi i8 [ %iv.next, %for.body ], [ 0, %entry ]
+  store volatile i8 %iv, i8* @G
+  %iv.next = add i8 %iv, 1
+  %zext = zext i8 %iv to i16
+  %cmp = icmp ult i16 %zext, 257
+  br i1 %cmp, label %for.body, label %for.end
+
+for.end:                                          ; preds = %for.body, %entry
+  ret void
+}
+
+declare void @llvm.assume(i1)
+


        


More information about the llvm-commits mailing list