[llvm] 53d7bdb - [NFC][X86][LV] Improve costmodel test coverage for interleaved i8 load/store stride=4

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


Author: Roman Lebedev
Date: 2021-10-01T22:49:06+03:00
New Revision: 53d7bdbfbf3ee578ff9341ed28b8a9df838ffa48

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

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

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

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

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


################################################################################
diff  --git a/llvm/test/Analysis/CostModel/X86/interleaved-load-i8-stride-4.ll b/llvm/test/Analysis/CostModel/X86/interleaved-load-i8-stride-4.ll
new file mode 100644
index 0000000000000..de80be89b90d1
--- /dev/null
+++ b/llvm/test/Analysis/CostModel/X86/interleaved-load-i8-stride-4.ll
@@ -0,0 +1,80 @@
+; 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 28 for VF 2 For instruction:   %v0 = load i8, i8* %in0, align 1
+; SSE2: LV: Found an estimated cost of 60 for VF 4 For instruction:   %v0 = load i8, i8* %in0, align 1
+; SSE2: LV: Found an estimated cost of 124 for VF 8 For instruction:   %v0 = load i8, i8* %in0, align 1
+; SSE2: LV: Found an estimated cost of 252 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 17 for VF 2 For instruction:   %v0 = load i8, i8* %in0, align 1
+; AVX1: LV: Found an estimated cost of 33 for VF 4 For instruction:   %v0 = load i8, i8* %in0, align 1
+; AVX1: LV: Found an estimated cost of 81 for VF 8 For instruction:   %v0 = load i8, i8* %in0, align 1
+; AVX1: LV: Found an estimated cost of 162 for VF 16 For instruction:   %v0 = load i8, i8* %in0, align 1
+; AVX1: LV: Found an estimated cost of 332 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 5 for VF 4 For instruction:   %v0 = load i8, i8* %in0, align 1
+; AVX2: LV: Found an estimated cost of 21 for VF 8 For instruction:   %v0 = load i8, i8* %in0, align 1
+; AVX2: LV: Found an estimated cost of 41 for VF 16 For instruction:   %v0 = load i8, i8* %in0, align 1
+; AVX2: LV: Found an estimated cost of 84 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 5 for VF 2 For instruction:   %v0 = load i8, i8* %in0, align 1
+; AVX512: LV: Found an estimated cost of 5 for VF 4 For instruction:   %v0 = load i8, i8* %in0, align 1
+; AVX512: LV: Found an estimated cost of 17 for VF 8 For instruction:   %v0 = load i8, i8* %in0, align 1
+; AVX512: LV: Found an estimated cost of 33 for VF 16 For instruction:   %v0 = load i8, i8* %in0, align 1
+; AVX512: LV: Found an estimated cost of 80 for VF 32 For instruction:   %v0 = load i8, i8* %in0, align 1
+; AVX512: LV: Found an estimated cost of 238 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
+  %iv.3 = add nuw nsw i64 %iv, 3
+
+  %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
+  %in3 = getelementptr inbounds [1024 x i8], [1024 x i8]* @A, i64 0, i64 %iv.3
+
+  %v0 = load i8, i8* %in0
+  %v1 = load i8, i8* %in1
+  %v2 = load i8, i8* %in2
+  %v3 = load i8, i8* %in3
+
+  %reduce.add.0 = add i8 %v0, %v1
+  %reduce.add.1 = add i8 %reduce.add.0, %v2
+  %reduce.add.2 = add i8 %reduce.add.1, %v3
+
+  %out = getelementptr inbounds [1024 x i8], [1024 x i8]* @B, i64 0, i64 %iv.0
+  store i8 %reduce.add.2, i8* %out
+
+  %iv.next = add nuw nsw i64 %iv.0, 4
+  %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
deleted file mode 100644
index 78bca8ef753d8..0000000000000
--- a/llvm/test/Analysis/CostModel/X86/interleaved-load-i8.ll
+++ /dev/null
@@ -1,54 +0,0 @@
-; REQUIRES: asserts
-; RUN: opt -loop-vectorize -S -mcpu=core-avx2 --debug-only=loop-vectorize -vectorizer-maximize-bandwidth < %s 2>&1 | FileCheck %s
-
-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_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
-;CHECK: LV: Found an estimated cost of 13 for VF 2 For instruction:   %0 = load i8
-;CHECK: LV: Found an estimated cost of 5 for VF 4 For instruction:   %0 = load i8
-;CHECK: LV: Found an estimated cost of 21 for VF 8 For instruction:   %0 = load i8
-;CHECK: LV: Found an estimated cost of 41 for VF 16 For instruction:   %0 = load i8
-;CHECK: LV: Found an estimated cost of 84 for VF 32 For instruction:   %0 = load i8
-entry:
-  %cmp59 = icmp sgt i32 %Nels, 0
-  br i1 %cmp59, label %for.body.preheader, label %for.end
-
-for.body.preheader:
-  br label %for.body
-
-for.body:                                         ; preds = %for.body.preheader, %for.body
-  %Ptr.addr.062 = phi i8* [ %incdec.ptr3, %for.body ], [ %Ptr, %for.body.preheader ]
-  %i.061 = phi i32 [ %inc, %for.body ], [ 0, %for.body.preheader ]
-  %s.060 = phi i32 [ %cond39, %for.body ], [ 0, %for.body.preheader ]
-  %incdec.ptr = getelementptr inbounds i8, i8* %Ptr.addr.062, i64 1
-  %0 = load i8, i8* %Ptr.addr.062, align 1
-  %incdec.ptr1 = getelementptr inbounds i8, i8* %Ptr.addr.062, i64 2
-  %1 = load i8, i8* %incdec.ptr, align 1
-  %incdec.ptr2 = getelementptr inbounds i8, i8* %Ptr.addr.062, i64 3
-  %2 = load i8, i8* %incdec.ptr1, align 1
-  %incdec.ptr3 = getelementptr inbounds i8, i8* %Ptr.addr.062, i64 4
-  %3 = load i8, i8* %incdec.ptr2, align 1
-  %cmp5 = icmp ult i8 %0, %1
-  %.sink = select i1 %cmp5, i8 %0, i8 %1
-  %cmp12 = icmp ult i8 %.sink, %2
-  %.sink40 = select i1 %cmp12, i8 %.sink, i8 %2
-  %cmp23 = icmp ult i8 %.sink40, %3
-  %.sink41 = select i1 %cmp23, i8 %.sink40, i8 %3
-  %conv28 = zext i8 %.sink41 to i32
-  %cmp33 = icmp slt i32 %s.060, %conv28
-  %cond39 = select i1 %cmp33, i32 %s.060, i32 %conv28
-  %inc = add nuw nsw i32 %i.061, 1
-  %exitcond = icmp eq i32 %inc, %Nels
-  br i1 %exitcond, label %for.end.loopexit, label %for.body
-
-for.end.loopexit:
-  %cond39.lcssa = phi i32 [ %cond39, %for.body ]
-  br label %for.end
-
-for.end:
-  %s.0.lcssa = phi i32 [ 0, %entry ], [ %cond39.lcssa, %for.end.loopexit ]
-  ret i32 %s.0.lcssa
-}

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
index 4712d25255345..ce436a2501c9e 100644
--- a/llvm/test/Analysis/CostModel/X86/interleaved-store-i8-stride-3.ll
+++ b/llvm/test/Analysis/CostModel/X86/interleaved-store-i8-stride-3.ll
@@ -40,7 +40,7 @@ target triple = "x86_64-unknown-linux-gnu"
 ; 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
+; CHECK-NOT: LV: Found an estimated cost of {{[0-9]+}} for VF {{[0-9]+}} For instruction:   store i8 %v2, i8* %out2, align 1
 
 define void @test() {
 entry:

diff  --git a/llvm/test/Analysis/CostModel/X86/interleaved-store-i8-stride-4.ll b/llvm/test/Analysis/CostModel/X86/interleaved-store-i8-stride-4.ll
new file mode 100644
index 0000000000000..4a866eb80741c
--- /dev/null
+++ b/llvm/test/Analysis/CostModel/X86/interleaved-store-i8-stride-4.ll
@@ -0,0 +1,81 @@
+; 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 %v3, i8* %out3, align 1
+; SSE2: LV: Found an estimated cost of 28 for VF 2 For instruction:   store i8 %v3, i8* %out3, align 1
+; SSE2: LV: Found an estimated cost of 60 for VF 4 For instruction:   store i8 %v3, i8* %out3, align 1
+; SSE2: LV: Found an estimated cost of 124 for VF 8 For instruction:   store i8 %v3, i8* %out3, align 1
+; SSE2: LV: Found an estimated cost of 252 for VF 16 For instruction:   store i8 %v3, i8* %out3, align 1
+;
+; AVX1: LV: Found an estimated cost of 1 for VF 1 For instruction:   store i8 %v3, i8* %out3, align 1
+; AVX1: LV: Found an estimated cost of 17 for VF 2 For instruction:   store i8 %v3, i8* %out3, align 1
+; AVX1: LV: Found an estimated cost of 33 for VF 4 For instruction:   store i8 %v3, i8* %out3, align 1
+; AVX1: LV: Found an estimated cost of 67 for VF 8 For instruction:   store i8 %v3, i8* %out3, align 1
+; AVX1: LV: Found an estimated cost of 134 for VF 16 For instruction:   store i8 %v3, i8* %out3, align 1
+; AVX1: LV: Found an estimated cost of 332 for VF 32 For instruction:   store i8 %v3, i8* %out3, align 1
+;
+; AVX2: LV: Found an estimated cost of 1 for VF 1 For instruction:   store i8 %v3, i8* %out3, align 1
+; AVX2: LV: Found an estimated cost of 13 for VF 2 For instruction:   store i8 %v3, i8* %out3, align 1
+; AVX2: LV: Found an estimated cost of 10 for VF 4 For instruction:   store i8 %v3, i8* %out3, align 1
+; AVX2: LV: Found an estimated cost of 11 for VF 8 For instruction:   store i8 %v3, i8* %out3, align 1
+; AVX2: LV: Found an estimated cost of 12 for VF 16 For instruction:   store i8 %v3, i8* %out3, align 1
+; AVX2: LV: Found an estimated cost of 16 for VF 32 For instruction:   store i8 %v3, i8* %out3, align 1
+;
+; AVX512: LV: Found an estimated cost of 1 for VF 1 For instruction:   store i8 %v3, i8* %out3, align 1
+; AVX512: LV: Found an estimated cost of 11 for VF 2 For instruction:   store i8 %v3, i8* %out3, align 1
+; AVX512: LV: Found an estimated cost of 11 for VF 4 For instruction:   store i8 %v3, i8* %out3, align 1
+; AVX512: LV: Found an estimated cost of 11 for VF 8 For instruction:   store i8 %v3, i8* %out3, align 1
+; AVX512: LV: Found an estimated cost of 12 for VF 16 For instruction:   store i8 %v3, i8* %out3, align 1
+; AVX512: LV: Found an estimated cost of 16 for VF 32 For instruction:   store i8 %v3, i8* %out3, align 1
+; AVX512: LV: Found an estimated cost of 28 for VF 64 For instruction:   store i8 %v3, i8* %out3, align 1
+;
+; CHECK-NOT: LV: Found an estimated cost of {{[0-9]+}} for VF {{[0-9]+}} For instruction:   store i8 %v3, i8* %out3, 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
+  %iv.3 = add nuw nsw i64 %iv, 3
+
+  %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
+  %v3 = add i8 %v, 3
+
+  %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
+  %out3 = getelementptr inbounds [1024 x i8], [1024 x i8]* @B, i64 0, i64 %iv.3
+
+  store i8 %v0, i8* %out0
+  store i8 %v1, i8* %out1
+  store i8 %v2, i8* %out2
+  store i8 %v3, i8* %out3
+
+  %iv.next = add nuw nsw i64 %iv.0, 4
+  %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
deleted file mode 100644
index 3d0890ee1a313..0000000000000
--- a/llvm/test/Analysis/CostModel/X86/interleaved-store-i8.ll
+++ /dev/null
@@ -1,47 +0,0 @@
-; REQUIRES: asserts
-; RUN: opt -loop-vectorize -S -mcpu=core-avx2 --debug-only=loop-vectorize -vectorizer-maximize-bandwidth < %s 2>&1 | FileCheck %s
-
-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_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
-;CHECK: LV: Found an estimated cost of 13 for VF 2 For instruction:   store i8 %conv7
-;CHECK: LV: Found an estimated cost of 10 for VF 4 For instruction:   store i8 %conv7
-;CHECK: LV: Found an estimated cost of 11 for VF 8 For instruction:   store i8 %conv7
-;CHECK: LV: Found an estimated cost of 12 for VF 16 For instruction:   store i8 %conv7
-;CHECK: LV: Found an estimated cost of 16 for VF 32 For instruction:   store i8 %conv7
-entry:
-  %cmp19 = icmp sgt i32 %Nels, 0
-  br i1 %cmp19, 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
-  %mul6 = mul nsw i32 %Nels, 5
-  %conv7 = trunc i32 %mul6 to i8
-  br label %for.body
-
-for.body:
-  %i.021 = phi i32 [ 0, %for.body.lr.ph ], [ %inc, %for.body ]
-  %Ptr.addr.020 = phi i8* [ %Ptr, %for.body.lr.ph ], [ %incdec.ptr8, %for.body ]
-  %incdec.ptr = getelementptr inbounds i8, i8* %Ptr.addr.020, i64 1
-  store i8 %conv, i8* %Ptr.addr.020, align 1
-  %incdec.ptr2 = getelementptr inbounds i8, i8* %Ptr.addr.020, i64 2
-  store i8 %conv1, i8* %incdec.ptr, align 1
-  %incdec.ptr5 = getelementptr inbounds i8, i8* %Ptr.addr.020, i64 3
-  store i8 %conv4, i8* %incdec.ptr2, align 1
-  %incdec.ptr8 = getelementptr inbounds i8, i8* %Ptr.addr.020, i64 4
-  store i8 %conv7, i8* %incdec.ptr5, align 1
-  %inc = add nuw nsw i32 %i.021, 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
-}


        


More information about the llvm-commits mailing list