[llvm] 727a359 - [NFC][X86][LV] Improve costmodel test coverage for interleaved i8 load/store stride=3

Roman Lebedev via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 1 08:47:47 PDT 2021


Author: Roman Lebedev
Date: 2021-10-01T18:47:25+03:00
New Revision: 727a359979ece2da9b50ccacc682399e7c8287cc

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

LOG: [NFC][X86][LV] Improve costmodel test coverage for interleaved i8 load/store stride=3

Added: 
    llvm/test/Analysis/CostModel/X86/interleaved-load-i8-stride-3.ll
    llvm/test/Analysis/CostModel/X86/interleaved-store-i8-stride-3.ll

Modified: 
    llvm/test/Analysis/CostModel/X86/interleaved-load-i8.ll
    llvm/test/Analysis/CostModel/X86/interleaved-store-i8.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Analysis/CostModel/X86/interleaved-load-i8-stride-3.ll b/llvm/test/Analysis/CostModel/X86/interleaved-load-i8-stride-3.ll
new file mode 100644
index 000000000000..01ae3331458b
--- /dev/null
+++ b/llvm/test/Analysis/CostModel/X86/interleaved-load-i8-stride-3.ll
@@ -0,0 +1,76 @@
+; RUN: opt -loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+sse2 --debug-only=loop-vectorize < %s 2>&1 | FileCheck %s --check-prefixes=CHECK,SSE2
+; RUN: opt -loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx  --debug-only=loop-vectorize < %s 2>&1 | FileCheck %s --check-prefixes=CHECK,AVX1
+; RUN: opt -loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx2 --debug-only=loop-vectorize < %s 2>&1 | FileCheck %s --check-prefixes=CHECK,AVX2
+; RUN: opt -loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx512bw,+avx512vl --debug-only=loop-vectorize < %s 2>&1 | FileCheck %s --check-prefixes=CHECK,AVX512
+; REQUIRES: asserts
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+ at A = global [1024 x i8] zeroinitializer, align 128
+ at B = global [1024 x i8] zeroinitializer, align 128
+
+; CHECK: LV: Checking a loop in "test"
+;
+; SSE2: LV: Found an estimated cost of 1 for VF 1 For instruction:   %v0 = load i8, i8* %in0, align 1
+; SSE2: LV: Found an estimated cost of 23 for VF 2 For instruction:   %v0 = load i8, i8* %in0, align 1
+; SSE2: LV: Found an estimated cost of 50 for VF 4 For instruction:   %v0 = load i8, i8* %in0, align 1
+; SSE2: LV: Found an estimated cost of 93 for VF 8 For instruction:   %v0 = load i8, i8* %in0, align 1
+; SSE2: LV: Found an estimated cost of 189 for VF 16 For instruction:   %v0 = load i8, i8* %in0, align 1
+;
+; AVX1: LV: Found an estimated cost of 1 for VF 1 For instruction:   %v0 = load i8, i8* %in0, align 1
+; AVX1: LV: Found an estimated cost of 15 for VF 2 For instruction:   %v0 = load i8, i8* %in0, align 1
+; AVX1: LV: Found an estimated cost of 27 for VF 4 For instruction:   %v0 = load i8, i8* %in0, align 1
+; AVX1: LV: Found an estimated cost of 59 for VF 8 For instruction:   %v0 = load i8, i8* %in0, align 1
+; AVX1: LV: Found an estimated cost of 114 for VF 16 For instruction:   %v0 = load i8, i8* %in0, align 1
+; AVX1: LV: Found an estimated cost of 249 for VF 32 For instruction:   %v0 = load i8, i8* %in0, align 1
+;
+; AVX2: LV: Found an estimated cost of 1 for VF 1 For instruction:   %v0 = load i8, i8* %in0, align 1
+; AVX2: LV: Found an estimated cost of 13 for VF 2 For instruction:   %v0 = load i8, i8* %in0, align 1
+; AVX2: LV: Found an estimated cost of 7 for VF 4 For instruction:   %v0 = load i8, i8* %in0, align 1
+; AVX2: LV: Found an estimated cost of 12 for VF 8 For instruction:   %v0 = load i8, i8* %in0, align 1
+; AVX2: LV: Found an estimated cost of 13 for VF 16 For instruction:   %v0 = load i8, i8* %in0, align 1
+; AVX2: LV: Found an estimated cost of 16 for VF 32 For instruction:   %v0 = load i8, i8* %in0, align 1
+;
+; AVX512: LV: Found an estimated cost of 1 for VF 1 For instruction:   %v0 = load i8, i8* %in0, align 1
+; AVX512: LV: Found an estimated cost of 4 for VF 2 For instruction:   %v0 = load i8, i8* %in0, align 1
+; AVX512: LV: Found an estimated cost of 4 for VF 4 For instruction:   %v0 = load i8, i8* %in0, align 1
+; AVX512: LV: Found an estimated cost of 13 for VF 8 For instruction:   %v0 = load i8, i8* %in0, align 1
+; AVX512: LV: Found an estimated cost of 13 for VF 16 For instruction:   %v0 = load i8, i8* %in0, align 1
+; AVX512: LV: Found an estimated cost of 16 for VF 32 For instruction:   %v0 = load i8, i8* %in0, align 1
+; AVX512: LV: Found an estimated cost of 25 for VF 64 For instruction:   %v0 = load i8, i8* %in0, align 1
+;
+; CHECK-NOT: LV: Found an estimated cost of {{[0-9]+}} for VF {{[0-9]+}} For instruction:   %v0 = load i8, i8* %in0, align 1
+
+define void @test() {
+entry:
+  br label %for.body
+
+for.body:
+  %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]
+
+  %iv.0 = add nuw nsw i64 %iv, 0
+  %iv.1 = add nuw nsw i64 %iv, 1
+  %iv.2 = add nuw nsw i64 %iv, 2
+
+  %in0 = getelementptr inbounds [1024 x i8], [1024 x i8]* @A, i64 0, i64 %iv.0
+  %in1 = getelementptr inbounds [1024 x i8], [1024 x i8]* @A, i64 0, i64 %iv.1
+  %in2 = getelementptr inbounds [1024 x i8], [1024 x i8]* @A, i64 0, i64 %iv.2
+
+  %v0 = load i8, i8* %in0
+  %v1 = load i8, i8* %in1
+  %v2 = load i8, i8* %in2
+
+  %reduce.add.0 = add i8 %v0, %v1
+  %reduce.add.1 = add i8 %reduce.add.0, %v2
+
+  %out = getelementptr inbounds [1024 x i8], [1024 x i8]* @B, i64 0, i64 %iv.0
+  store i8 %reduce.add.1, i8* %out
+
+  %iv.next = add nuw nsw i64 %iv.0, 3
+  %cmp = icmp ult i64 %iv.next, 1024
+  br i1 %cmp, label %for.body, label %for.cond.cleanup
+
+for.cond.cleanup:
+  ret void
+}

diff  --git a/llvm/test/Analysis/CostModel/X86/interleaved-load-i8.ll b/llvm/test/Analysis/CostModel/X86/interleaved-load-i8.ll
index d20745080981..78bca8ef753d 100644
--- a/llvm/test/Analysis/CostModel/X86/interleaved-load-i8.ll
+++ b/llvm/test/Analysis/CostModel/X86/interleaved-load-i8.ll
@@ -4,50 +4,6 @@
 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-unknown-linux-gnu"
 
-; Function Attrs: norecurse nounwind readonly uwtable
-define i32 @doit_stride3(i8* nocapture readonly %Ptr, i32 %Nels)  {
-;CHECK: LV: Found an estimated cost of 1 for VF 1 For instruction:   %0 = load i8
-;CHECK: LV: Found an estimated cost of 13 for VF 2 For instruction:   %0 = load i8
-;CHECK: LV: Found an estimated cost of 7 for VF 4 For instruction:   %0 = load i8
-;CHECK: LV: Found an estimated cost of 12 for VF 8 For instruction:   %0 = load i8
-;CHECK: LV: Found an estimated cost of 13 for VF 16 For instruction:   %0 = load i8
-;CHECK: LV: Found an estimated cost of 16 for VF 32 For instruction:   %0 = load i8
-entry:
-  %cmp13 = icmp sgt i32 %Nels, 0
-  br i1 %cmp13, label %for.body.preheader, label %for.end
-
-for.body.preheader:
-  br label %for.body
-
-for.body:
-  %Ptr.addr.016 = phi i8* [ %incdec.ptr2, %for.body ], [ %Ptr, %for.body.preheader ]
-  %i.015 = phi i32 [ %inc, %for.body ], [ 0, %for.body.preheader ]
-  %s.014 = phi i32 [ %add6, %for.body ], [ 0, %for.body.preheader ]
-  %incdec.ptr = getelementptr inbounds i8, i8* %Ptr.addr.016, i64 1
-  %0 = load i8, i8* %Ptr.addr.016, align 1
-  %incdec.ptr1 = getelementptr inbounds i8, i8* %Ptr.addr.016, i64 2
-  %1 = load i8, i8* %incdec.ptr, align 1
-  %incdec.ptr2 = getelementptr inbounds i8, i8* %Ptr.addr.016, i64 3
-  %2 = load i8, i8* %incdec.ptr1, align 1
-  %conv = zext i8 %0 to i32
-  %conv3 = zext i8 %1 to i32
-  %conv4 = zext i8 %2 to i32
-  %add = add i32 %s.014, %conv
-  %add5 = add i32 %add, %conv3
-  %add6 = add i32 %add5, %conv4
-  %inc = add nuw nsw i32 %i.015, 1
-  %exitcond = icmp eq i32 %inc, %Nels
-  br i1 %exitcond, label %for.end.loopexit, label %for.body
-
-for.end.loopexit:
-  %add6.lcssa = phi i32 [ %add6, %for.body ]
-  br label %for.end
-
-for.end:
-  %s.0.lcssa = phi i32 [ 0, %entry ], [ %add6.lcssa, %for.end.loopexit ]
-  ret i32 %s.0.lcssa
-}
-
 ; Function Attrs: norecurse nounwind readonly uwtable
 define i32 @doit_stride4(i8* nocapture readonly %Ptr, i32 %Nels) local_unnamed_addr {
 ;CHECK: LV: Found an estimated cost of 1 for VF 1 For instruction:   %0 = load i8
@@ -88,7 +44,7 @@ for.body:                                         ; preds = %for.body.preheader,
   %exitcond = icmp eq i32 %inc, %Nels
   br i1 %exitcond, label %for.end.loopexit, label %for.body
 
-for.end.loopexit: 
+for.end.loopexit:
   %cond39.lcssa = phi i32 [ %cond39, %for.body ]
   br label %for.end
 

diff  --git a/llvm/test/Analysis/CostModel/X86/interleaved-store-i8-stride-3.ll b/llvm/test/Analysis/CostModel/X86/interleaved-store-i8-stride-3.ll
new file mode 100644
index 000000000000..4712d2525534
--- /dev/null
+++ b/llvm/test/Analysis/CostModel/X86/interleaved-store-i8-stride-3.ll
@@ -0,0 +1,77 @@
+; RUN: opt -loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+sse2 --debug-only=loop-vectorize < %s 2>&1 | FileCheck %s --check-prefixes=CHECK,SSE2
+; RUN: opt -loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx  --debug-only=loop-vectorize < %s 2>&1 | FileCheck %s --check-prefixes=CHECK,AVX1
+; RUN: opt -loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx2 --debug-only=loop-vectorize < %s 2>&1 | FileCheck %s --check-prefixes=CHECK,AVX2
+; RUN: opt -loop-vectorize -vectorizer-maximize-bandwidth -S -mattr=+avx512bw,+avx512vl --debug-only=loop-vectorize < %s 2>&1 | FileCheck %s --check-prefixes=CHECK,AVX512
+; REQUIRES: asserts
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+ at A = global [1024 x i8] zeroinitializer, align 128
+ at B = global [1024 x i8] zeroinitializer, align 128
+
+; CHECK: LV: Checking a loop in "test"
+;
+; SSE2: LV: Found an estimated cost of 1 for VF 1 For instruction:   store i8 %v2, i8* %out2, align 1
+; SSE2: LV: Found an estimated cost of 25 for VF 2 For instruction:   store i8 %v2, i8* %out2, align 1
+; SSE2: LV: Found an estimated cost of 52 for VF 4 For instruction:   store i8 %v2, i8* %out2, align 1
+; SSE2: LV: Found an estimated cost of 101 for VF 8 For instruction:   store i8 %v2, i8* %out2, align 1
+; SSE2: LV: Found an estimated cost of 204 for VF 16 For instruction:   store i8 %v2, i8* %out2, align 1
+;
+; AVX1: LV: Found an estimated cost of 1 for VF 1 For instruction:   store i8 %v2, i8* %out2, align 1
+; AVX1: LV: Found an estimated cost of 15 for VF 2 For instruction:   store i8 %v2, i8* %out2, align 1
+; AVX1: LV: Found an estimated cost of 27 for VF 4 For instruction:   store i8 %v2, i8* %out2, align 1
+; AVX1: LV: Found an estimated cost of 54 for VF 8 For instruction:   store i8 %v2, i8* %out2, align 1
+; AVX1: LV: Found an estimated cost of 101 for VF 16 For instruction:   store i8 %v2, i8* %out2, align 1
+; AVX1: LV: Found an estimated cost of 249 for VF 32 For instruction:   store i8 %v2, i8* %out2, align 1
+;
+; AVX2: LV: Found an estimated cost of 1 for VF 1 For instruction:   store i8 %v2, i8* %out2, align 1
+; AVX2: LV: Found an estimated cost of 10 for VF 2 For instruction:   store i8 %v2, i8* %out2, align 1
+; AVX2: LV: Found an estimated cost of 11 for VF 4 For instruction:   store i8 %v2, i8* %out2, align 1
+; AVX2: LV: Found an estimated cost of 14 for VF 8 For instruction:   store i8 %v2, i8* %out2, align 1
+; AVX2: LV: Found an estimated cost of 13 for VF 16 For instruction:   store i8 %v2, i8* %out2, align 1
+; AVX2: LV: Found an estimated cost of 16 for VF 32 For instruction:   store i8 %v2, i8* %out2, align 1
+;
+; AVX512: LV: Found an estimated cost of 1 for VF 1 For instruction:   store i8 %v2, i8* %out2, align 1
+; AVX512: LV: Found an estimated cost of 8 for VF 2 For instruction:   store i8 %v2, i8* %out2, align 1
+; AVX512: LV: Found an estimated cost of 8 for VF 4 For instruction:   store i8 %v2, i8* %out2, align 1
+; AVX512: LV: Found an estimated cost of 16 for VF 8 For instruction:   store i8 %v2, i8* %out2, align 1
+; AVX512: LV: Found an estimated cost of 13 for VF 16 For instruction:   store i8 %v2, i8* %out2, align 1
+; AVX512: LV: Found an estimated cost of 16 for VF 32 For instruction:   store i8 %v2, i8* %out2, align 1
+; AVX512: LV: Found an estimated cost of 29 for VF 64 For instruction:   store i8 %v2, i8* %out2, align 1
+;
+; CHECK-NOT: LV: Found an estimated cost of {{[0-9]+}} for VF {{[0-9]+}} For instruction:   store i8 %v2, i8* %out2, align 2
+
+define void @test() {
+entry:
+  br label %for.body
+
+for.body:
+  %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]
+
+  %iv.0 = add nuw nsw i64 %iv, 0
+  %iv.1 = add nuw nsw i64 %iv, 1
+  %iv.2 = add nuw nsw i64 %iv, 2
+
+  %in = getelementptr inbounds [1024 x i8], [1024 x i8]* @A, i64 0, i64 %iv.0
+  %v = load i8, i8* %in
+
+  %v0 = add i8 %v, 0
+  %v1 = add i8 %v, 1
+  %v2 = add i8 %v, 2
+
+  %out0 = getelementptr inbounds [1024 x i8], [1024 x i8]* @B, i64 0, i64 %iv.0
+  %out1 = getelementptr inbounds [1024 x i8], [1024 x i8]* @B, i64 0, i64 %iv.1
+  %out2 = getelementptr inbounds [1024 x i8], [1024 x i8]* @B, i64 0, i64 %iv.2
+
+  store i8 %v0, i8* %out0
+  store i8 %v1, i8* %out1
+  store i8 %v2, i8* %out2
+
+  %iv.next = add nuw nsw i64 %iv.0, 3
+  %cmp = icmp ult i64 %iv.next, 1024
+  br i1 %cmp, label %for.body, label %for.cond.cleanup
+
+for.cond.cleanup:
+  ret void
+}

diff  --git a/llvm/test/Analysis/CostModel/X86/interleaved-store-i8.ll b/llvm/test/Analysis/CostModel/X86/interleaved-store-i8.ll
index 349f5ad21a6f..3d0890ee1a31 100644
--- a/llvm/test/Analysis/CostModel/X86/interleaved-store-i8.ll
+++ b/llvm/test/Analysis/CostModel/X86/interleaved-store-i8.ll
@@ -4,44 +4,6 @@
 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-unknown-linux-gnu"
 
-; Function Attrs: norecurse nounwind uwtable
-define void @doit_stride3(i8* nocapture %Ptr, i32 %Nels) local_unnamed_addr {
-;CHECK: LV: Found an estimated cost of 1 for VF 1 For instruction:   store i8 %conv4
-;CHECK: LV: Found an estimated cost of 10 for VF 2 For instruction:   store i8 %conv4
-;CHECK: LV: Found an estimated cost of 11 for VF 4 For instruction:   store i8 %conv4
-;CHECK: LV: Found an estimated cost of 14 for VF 8 For instruction:   store i8 %conv4
-;CHECK: LV: Found an estimated cost of 13 for VF 16 For instruction:   store i8 %conv4
-;CHECK: LV: Found an estimated cost of 16 for VF 32 For instruction:   store i8 %conv4
-entry:
-  %cmp14 = icmp sgt i32 %Nels, 0
-  br i1 %cmp14, label %for.body.lr.ph, label %for.end
-
-for.body.lr.ph:
-  %conv = trunc i32 %Nels to i8
-  %conv1 = shl i8 %conv, 1
-  %conv4 = shl i8 %conv, 2
-  br label %for.body
-
-for.body:
-  %i.016 = phi i32 [ 0, %for.body.lr.ph ], [ %inc, %for.body ]
-  %Ptr.addr.015 = phi i8* [ %Ptr, %for.body.lr.ph ], [ %incdec.ptr5, %for.body ]
-  %incdec.ptr = getelementptr inbounds i8, i8* %Ptr.addr.015, i64 1
-  store i8 %conv, i8* %Ptr.addr.015, align 1
-  %incdec.ptr2 = getelementptr inbounds i8, i8* %Ptr.addr.015, i64 2
-  store i8 %conv1, i8* %incdec.ptr, align 1
-  %incdec.ptr5 = getelementptr inbounds i8, i8* %Ptr.addr.015, i64 3
-  store i8 %conv4, i8* %incdec.ptr2, align 1
-  %inc = add nuw nsw i32 %i.016, 1
-  %exitcond = icmp eq i32 %inc, %Nels
-  br i1 %exitcond, label %for.end.loopexit, label %for.body
-
-for.end.loopexit:
-  br label %for.end
-
-for.end:
-  ret void
-}
-
 ; Function Attrs: norecurse nounwind uwtable
 define void @doit_stride4(i8* nocapture %Ptr, i32 %Nels) local_unnamed_addr {
 ;CHECK: LV: Found an estimated cost of 1 for VF 1 For instruction:   store i8 %conv7


        


More information about the llvm-commits mailing list