[llvm] ef4df27 - [LV] Modernize some runtime check tests a bit.

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 7 04:09:18 PST 2022


Author: Florian Hahn
Date: 2022-02-07T12:08:56Z
New Revision: ef4df27940fc725428b1d0b0447848f876164801

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

LOG: [LV] Modernize some runtime check tests a bit.

Update tests to check runtime checks a bit more precisely.

Added: 
    

Modified: 
    llvm/test/Transforms/LoopVectorize/runtime-check-readonly.ll
    llvm/test/Transforms/LoopVectorize/tbaa-nodep.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/LoopVectorize/runtime-check-readonly.ll b/llvm/test/Transforms/LoopVectorize/runtime-check-readonly.ll
index b37d94c0c328c..aff3b5cf75e42 100644
--- a/llvm/test/Transforms/LoopVectorize/runtime-check-readonly.ll
+++ b/llvm/test/Transforms/LoopVectorize/runtime-check-readonly.ll
@@ -2,19 +2,24 @@
 
 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
 
-;CHECK-LABEL: @add_ints(
-;CHECK: br
-;CHECK: getelementptr
-;CHECK-DAG: getelementptr
-;CHECK-DAG: icmp ugt
-;CHECK-DAG: icmp ugt
-;CHECK-DAG: icmp ugt
-;CHECK-DAG: icmp ugt
-;CHECK-DAG: and
-;CHECK-DAG: and
-;CHECK: br
-;CHECK: ret
 define void @add_ints(i32* nocapture %A, i32* nocapture %B, i32* nocapture %C) {
+; CHECK-LABEL: @add_ints(
+; CHECK-LABEL: vector.memcheck:
+; CHECK-NEXT:    [[SCEVGEP:%.*]] = getelementptr i32, i32* [[A:%.*]], i64 200
+; CHECK-NEXT:    [[SCEVGEP4:%.*]] = getelementptr i32, i32* [[B:%.*]], i64 200
+; CHECK-NEXT:    [[SCEVGEP7:%.*]] = getelementptr i32, i32* [[C:%.*]], i64 200
+; CHECK-NEXT:    [[BOUND0:%.*]] = icmp ugt i32* [[SCEVGEP4]], [[A]]
+; CHECK-NEXT:    [[BOUND1:%.*]] = icmp ugt i32* [[SCEVGEP]], [[B]]
+; CHECK-NEXT:    [[FOUND_CONFLICT:%.*]] = and i1 [[BOUND0]], [[BOUND1]]
+; CHECK-NEXT:    [[BOUND09:%.*]] = icmp ugt i32* [[SCEVGEP7]], [[A]]
+; CHECK-NEXT:    [[BOUND110:%.*]] = icmp ugt i32* [[SCEVGEP]], [[C]]
+; CHECK-NEXT:    [[FOUND_CONFLICT11:%.*]] = and i1 [[BOUND09]], [[BOUND110]]
+; CHECK-NEXT:    [[CONFLICT_RDX:%.*]] = or i1 [[FOUND_CONFLICT]], [[FOUND_CONFLICT11]]
+; CHECK-NEXT:    br i1 [[CONFLICT_RDX]], label %scalar.ph, label %vector.ph
+; CHECK:       vector.ph:
+; CHECK-NEXT:    br label %vector.body
+; CHECK:       vector.body:
+;
 entry:
   br label %for.body
 

diff  --git a/llvm/test/Transforms/LoopVectorize/tbaa-nodep.ll b/llvm/test/Transforms/LoopVectorize/tbaa-nodep.ll
index 7b5835e34f327..638d094a6ff1a 100644
--- a/llvm/test/Transforms/LoopVectorize/tbaa-nodep.ll
+++ b/llvm/test/Transforms/LoopVectorize/tbaa-nodep.ll
@@ -2,28 +2,9 @@
 ; RUN: opt < %s  -basic-aa -loop-vectorize -force-vector-interleave=1 -force-vector-width=4 -dce -instcombine -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -S | FileCheck %s --check-prefix=CHECK-NOTBAA
 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
 
-; Function Attrs: nounwind uwtable
-define i32 @test1(i32* nocapture %a, float* nocapture readonly %b) #0 {
-entry:
-  br label %for.body
-
-for.body:                                         ; preds = %for.body, %entry
-  %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
-  %arrayidx = getelementptr inbounds float, float* %b, i64 %indvars.iv
-  %0 = load float, float* %arrayidx, align 4, !tbaa !0
-  %conv = fptosi float %0 to i32
-  %arrayidx2 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
-  store i32 %conv, i32* %arrayidx2, align 4, !tbaa !4
-  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
-  %exitcond = icmp eq i64 %indvars.iv.next, 1600
-  br i1 %exitcond, label %for.end, label %for.body
-
-for.end:                                          ; preds = %for.body
-  ret i32 0
-
 ; TBAA partitions the accesses in this loop, so it can be vectorized without
 ; runtime checks.
-
+define i32 @test1(i32* nocapture %a, float* nocapture readonly %b) {
 ; CHECK-LABEL: @test1
 ; CHECK: entry:
 ; CHECK-NEXT: br label %vector.body
@@ -35,16 +16,17 @@ for.end:                                          ; preds = %for.body
 ; CHECK: ret i32 0
 
 ; CHECK-NOTBAA-LABEL: @test1
+; CHECK-NOTBAA: entry:
 ; CHECK-NOTBAA: icmp ugt i32*
+; CHECK-NOTBAA: icmp ugt float*
+; CHECK-NOTBAA-NOT: icmp
+; CHECK-NOTBAA: br i1 {{.+}}, label %for.body, label %vector.body
 
 ; CHECK-NOTBAA: load <4 x float>, <4 x float>* %{{.*}}, align 4, !tbaa
 ; CHECK-NOTBAA: store <4 x i32> %{{.*}}, <4 x i32>* %{{.*}}, align 4, !tbaa
 
 ; CHECK-NOTBAA: ret i32 0
-}
 
-; Function Attrs: nounwind uwtable
-define i32 @test2(i32* nocapture readonly %a, float* nocapture readonly %b, float* nocapture %c) #0 {
 entry:
   br label %for.body
 
@@ -52,26 +34,26 @@ for.body:                                         ; preds = %for.body, %entry
   %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
   %arrayidx = getelementptr inbounds float, float* %b, i64 %indvars.iv
   %0 = load float, float* %arrayidx, align 4, !tbaa !0
+  %conv = fptosi float %0 to i32
   %arrayidx2 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
-  %1 = load i32, i32* %arrayidx2, align 4, !tbaa !4
-  %conv = sitofp i32 %1 to float
-  %mul = fmul float %0, %conv
-  %arrayidx4 = getelementptr inbounds float, float* %c, i64 %indvars.iv
-  store float %mul, float* %arrayidx4, align 4, !tbaa !0
+  store i32 %conv, i32* %arrayidx2, align 4, !tbaa !4
   %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
   %exitcond = icmp eq i64 %indvars.iv.next, 1600
   br i1 %exitcond, label %for.end, label %for.body
 
 for.end:                                          ; preds = %for.body
   ret i32 0
+}
 
 ; This test is like the first, except here there is still one runtime check
 ; required. Without TBAA, however, two checks are required.
-
+define i32 @test2(i32* nocapture readonly %a, float* nocapture readonly %b, float* nocapture %c) {
 ; CHECK-LABEL: @test2
+; CHECK: entry:
 ; CHECK: icmp ugt float*
 ; CHECK: icmp ugt float*
 ; CHECK-NOT: icmp uge i32*
+; CHECK: br i1 {{.+}}, label %for.body, label %vector.body
 
 ; CHECK: load <4 x float>, <4 x float>* %{{.*}}, align 4, !tbaa
 ; CHECK: store <4 x float> %{{.*}}, <4 x float>* %{{.*}}, align 4, !tbaa
@@ -79,18 +61,39 @@ for.end:                                          ; preds = %for.body
 ; CHECK: ret i32 0
 
 ; CHECK-NOTBAA-LABEL: @test2
+; CHECK-NOTBAA: entry:
 ; CHECK-NOTBAA: icmp ugt float*
 ; CHECK-NOTBAA: icmp ugt float*
 ; CHECK-NOTBAA-DAG: icmp ugt float*
 ; CHECK-NOTBAA-DAG: icmp ugt i32*
+; CHECK-NOTBAA-NOT: icmp
+; CHECK-NOTBAA: br i1 {{.+}}, label %for.body, label %vector.body
 
 ; CHECK-NOTBAA: load <4 x float>, <4 x float>* %{{.*}}, align 4, !tbaa
 ; CHECK-NOTBAA: store <4 x float> %{{.*}}, <4 x float>* %{{.*}}, align 4, !tbaa
 
 ; CHECK-NOTBAA: ret i32 0
-}
 
-attributes #0 = { nounwind uwtable }
+entry:
+  br label %for.body
+
+for.body:                                         ; preds = %for.body, %entry
+  %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
+  %arrayidx = getelementptr inbounds float, float* %b, i64 %indvars.iv
+  %0 = load float, float* %arrayidx, align 4, !tbaa !0
+  %arrayidx2 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
+  %1 = load i32, i32* %arrayidx2, align 4, !tbaa !4
+  %conv = sitofp i32 %1 to float
+  %mul = fmul float %0, %conv
+  %arrayidx4 = getelementptr inbounds float, float* %c, i64 %indvars.iv
+  store float %mul, float* %arrayidx4, align 4, !tbaa !0
+  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
+  %exitcond = icmp eq i64 %indvars.iv.next, 1600
+  br i1 %exitcond, label %for.end, label %for.body
+
+for.end:                                          ; preds = %for.body
+  ret i32 0
+}
 
 !0 = !{!1, !1, i64 0}
 !1 = !{!"float", !2, i64 0}
@@ -98,4 +101,3 @@ attributes #0 = { nounwind uwtable }
 !3 = !{!"Simple C/C++ TBAA"}
 !4 = !{!5, !5, i64 0}
 !5 = !{!"int", !2, i64 0}
-


        


More information about the llvm-commits mailing list