From e9d4bb43f8432c58d87ff6c725f4b92db084d650 Mon Sep 17 00:00:00 2001 From: Philip Reames Date: Fri, 23 Jul 2021 17:19:34 -0700 Subject: [PATCH] [tests] SCEV trip count w/ neg step and varying rhs --- .../trip-count-negative-stride.ll | 81 +++++++++++++++++++ 1 file changed, 81 insertions(+) diff --git a/llvm/test/Analysis/ScalarEvolution/trip-count-negative-stride.ll b/llvm/test/Analysis/ScalarEvolution/trip-count-negative-stride.ll index adc6dcc3fa12..aeeafdceb3ef 100644 --- a/llvm/test/Analysis/ScalarEvolution/trip-count-negative-stride.ll +++ b/llvm/test/Analysis/ScalarEvolution/trip-count-negative-stride.ll @@ -206,6 +206,47 @@ for.end: ; preds = %for.body, %entry ret void } +; CHECK-LABEL: Determining loop execution counts for: @ult_129_varying_rhs +; CHECK: Loop %for.body: Unpredictable backedge-taken count. +; CHECK: Loop %for.body: Unpredictable max backedge-taken count + +define void @ult_129_varying_rhs(i8* %n_p) { +entry: + br label %for.body + +for.body: ; preds = %entry, %for.body + %i.05 = phi i8 [ %add, %for.body ], [ 0, %entry ] + %add = add nuw i8 %i.05, 129 + %n = load i8, i8* %n_p + %cmp = icmp ult i8 %add, %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: @ult_symbolic_varying_rhs +; CHECK: Loop %for.body: Unpredictable backedge-taken count. +; CHECK: Loop %for.body: Unpredictable max backedge-taken count + +define void @ult_symbolic_varying_rhs(i8* %n_p, i8 %step) { +entry: + %assume = icmp ult i8 128, %step + call void @llvm.assume(i1 %assume) + br label %for.body + +for.body: ; preds = %entry, %for.body + %i.05 = phi i8 [ %add, %for.body ], [ 0, %entry ] + %add = add nuw i8 %i.05, %step + %n = load i8, i8* %n_p + %cmp = icmp ult i8 %add, %n + br i1 %cmp, label %for.body, label %for.end + +for.end: ; preds = %for.body, %entry + ret void +} + + ; Signed Comparisons ; ------------------ @@ -406,6 +447,46 @@ for.end: ; preds = %for.body, %entry ret void } +; CHECK-LABEL: Determining loop execution counts for: @slt_129_varying_rhs +; CHECK: Loop %for.body: Unpredictable backedge-taken count. +; CHECK: Loop %for.body: Unpredictable max backedge-taken count + +define void @slt_129_varying_rhs(i8* %n_p) { +entry: + br label %for.body + +for.body: ; preds = %entry, %for.body + %i.05 = phi i8 [ %add, %for.body ], [ -128, %entry ] + %add = add nsw i8 %i.05, 129 + %n = load i8, i8* %n_p + %cmp = icmp slt i8 %add, %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: @slt_symbolic_varying_rhs +; CHECK: Loop %for.body: Unpredictable backedge-taken count. +; CHECK: Loop %for.body: Unpredictable max backedge-taken count + +define void @slt_symbolic_varying_rhs(i8* %n_p, i8 %step) { +entry: + %assume = icmp ult i8 128, %step + call void @llvm.assume(i1 %assume) + br label %for.body + +for.body: ; preds = %entry, %for.body + %i.05 = phi i8 [ %add, %for.body ], [ -128, %entry ] + %add = add nsw i8 %i.05, %step + %n = load i8, i8* %n_p + %cmp = icmp slt i8 %add, %n + br i1 %cmp, label %for.body, label %for.end + +for.end: ; preds = %for.body, %entry + ret void +} + declare void @llvm.assume(i1)