Skip to content

Commit 958cec0

Browse files
authored
[LV] Remove use of llc from vectoriser tests (#154759)
There were 5 X86 loop vectoriser tests that were piping the output from opt into llc. I think in the directory test/Transforms/LoopVectorize we should only be testing the output from the loop vectoriser pass. Any codegen tests should live in test/CodeGen/X86 instead. avx512.ll: it looks like we were really just testing that we generate the right vector length. fp32_to_uint32-cost-model.ll/fp64_to_uint32-cost-model.ll: the tests only seem to care that we're not scalarising the fptoui, so I've modified the test to check for vector ops. I've assumed there are already codegen tests for fptoui vector operations. vectorization-remarks-loopid-dbg.ll: i've copied this test to CodeGen/X86/vectorization-remarks-loopid-dbg.ll for the llc RUN line variant vectorization-remarks.ll: seems to test the same thing as vectorization-remarks-loopid-dbg.ll
1 parent bac8c87 commit 958cec0

File tree

6 files changed

+92
-43
lines changed

6 files changed

+92
-43
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
; RUN: llc < %s -mtriple x86_64-pc-linux-gnu -o - | FileCheck -check-prefix=DEBUG-OUTPUT %s
2+
; DEBUG-OUTPUT-NOT: .loc
3+
; DEBUG-OUTPUT-NOT: {{.*}}.debug_info
4+
5+
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
6+
7+
define i32 @foo(i32 %n) #0 !dbg !4 {
8+
entry:
9+
%diff = alloca i32, align 4
10+
%cb = alloca [16 x i8], align 16
11+
%cc = alloca [16 x i8], align 16
12+
store i32 0, ptr %diff, align 4, !tbaa !11
13+
br label %for.body
14+
15+
for.body: ; preds = %for.body, %entry
16+
%indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
17+
%add8 = phi i32 [ 0, %entry ], [ %add, %for.body ]
18+
%arrayidx = getelementptr inbounds [16 x i8], ptr %cb, i64 0, i64 %indvars.iv
19+
%0 = load i8, ptr %arrayidx, align 1, !tbaa !21
20+
%conv = sext i8 %0 to i32
21+
%arrayidx2 = getelementptr inbounds [16 x i8], ptr %cc, i64 0, i64 %indvars.iv
22+
%1 = load i8, ptr %arrayidx2, align 1, !tbaa !21
23+
%conv3 = sext i8 %1 to i32
24+
%sub = sub i32 %conv, %conv3
25+
%add = add nsw i32 %sub, %add8
26+
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
27+
%exitcond = icmp eq i64 %indvars.iv.next, 16
28+
br i1 %exitcond, label %for.end, label %for.body, !llvm.loop !25
29+
30+
for.end: ; preds = %for.body
31+
store i32 %add, ptr %diff, align 4, !tbaa !11
32+
call void @ibar(ptr %diff) #2
33+
ret i32 0
34+
}
35+
36+
declare void @ibar(ptr) #1
37+
38+
!llvm.module.flags = !{!7, !8}
39+
!llvm.ident = !{!9}
40+
!llvm.dbg.cu = !{!24}
41+
42+
!1 = !DIFile(filename: "vectorization-remarks.c", directory: ".")
43+
!2 = !{}
44+
!3 = !{!4}
45+
!4 = distinct !DISubprogram(name: "foo", line: 5, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, unit: !24, scopeLine: 6, file: !1, scope: !5, type: !6, retainedNodes: !2)
46+
!5 = !DIFile(filename: "vectorization-remarks.c", directory: ".")
47+
!6 = !DISubroutineType(types: !2)
48+
!7 = !{i32 2, !"Dwarf Version", i32 4}
49+
!8 = !{i32 1, !"Debug Info Version", i32 3}
50+
!9 = !{!"clang version 3.5.0 "}
51+
!10 = !DILocation(line: 8, column: 3, scope: !4)
52+
!11 = !{!12, !12, i64 0}
53+
!12 = !{!"int", !13, i64 0}
54+
!13 = !{!"omnipotent char", !14, i64 0}
55+
!14 = !{!"Simple C/C++ TBAA"}
56+
!15 = !DILocation(line: 17, column: 8, scope: !16)
57+
!16 = distinct !DILexicalBlock(line: 17, column: 8, file: !1, scope: !17)
58+
!17 = distinct !DILexicalBlock(line: 17, column: 8, file: !1, scope: !18)
59+
!18 = distinct !DILexicalBlock(line: 17, column: 3, file: !1, scope: !4)
60+
!19 = !DILocation(line: 18, column: 5, scope: !20)
61+
!20 = distinct !DILexicalBlock(line: 17, column: 27, file: !1, scope: !18)
62+
!21 = !{!13, !13, i64 0}
63+
!22 = !DILocation(line: 20, column: 3, scope: !4)
64+
!23 = !DILocation(line: 21, column: 3, scope: !4)
65+
!24 = distinct !DICompileUnit(language: DW_LANG_C89, file: !1, emissionKind: NoDebug)
66+
!25 = !{!25, !15}

llvm/test/Transforms/LoopVectorize/X86/avx512.ll

Lines changed: 22 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
1-
; RUN: opt -mattr=+avx512f -passes=loop-vectorize -S < %s | llc -mattr=+avx512f | FileCheck %s
2-
; RUN: opt -mattr=+avx512vl,+prefer-256-bit -passes=loop-vectorize -S < %s | llc -mattr=+avx512f | FileCheck %s --check-prefix=CHECK-PREFER-AVX256
1+
; RUN: opt -mattr=+avx512f -passes=loop-vectorize -S < %s | FileCheck %s --check-prefixes=CHECK,CHECK-NO-PREFER
2+
; RUN: opt -mattr=+avx512vl,+prefer-256-bit -passes=loop-vectorize -S < %s | FileCheck %s --check-prefixes=CHECK,CHECK-PREFER-AVX256
33

44
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
55
target triple = "x86_64-apple-macosx10.9.0"
66

77
; Verify that we generate 512-bit wide vectors for a basic integer memset
88
; loop.
99

10-
; CHECK-LABEL: _f:
11-
; CHECK: %vec.epilog.vector.body
12-
; CHECK: %ymm
13-
; CHECK: %vector.body
14-
; CHECK-NOT: %ymm
15-
; CHECK: vmovdqu64 %zmm{{.}},
10+
; CHECK-NO-PREFER-LABEL: @f(
11+
; CHECK-NO-PREFER: vector.body:
12+
; CHECK-NO-PREFER: store <16 x i32>
13+
; CHECK-NO-PREFER: vec.epilog.vector.body:
14+
; CHECK-NO-PREFER: store <8 x i32>
1615

1716
; Verify that we don't generate 512-bit wide vectors when subtarget feature says not to
1817

19-
; CHECK-PREFER-AVX256-LABEL: f:
20-
; CHECK-PREFER-AVX256: vmovdqu %ymm{{.}},
21-
; CHECK-PREFER-AVX256-NOT: %zmm
18+
; CHECK-PREFER-AVX256-LABEL: @f(
19+
; CHECK-PREFER-AVX256: vector.body:
20+
; CHECK-PREFER-AVX256: store <8 x i32>
21+
; CHECK-PREFER-AVX256: vec.epilog.vector.body:
22+
; CHECK-PREFER-AVX256: store <4 x i32>
2223

2324
define void @f(ptr %a, i32 %n) {
2425
entry:
@@ -47,13 +48,11 @@ for.end: ; preds = %for.end.loopexit, %
4748
; Verify that the "prefer-vector-width=256" attribute prevents the use of 512-bit
4849
; vectors
4950

50-
; CHECK-LABEL: _g:
51-
; CHECK: vmovdqu %ymm{{.}},
52-
; CHECK-NOT: %zmm
53-
54-
; CHECK-PREFER-AVX256-LABEL: g:
55-
; CHECK-PREFER-AVX256: vmovdqu %ymm{{.}},
56-
; CHECK-PREFER-AVX256-NOT: %zmm
51+
; CHECK-LABEL: @g(
52+
; CHECK: vector.body:
53+
; CHECK: store <8 x i32>
54+
; CHECK: vec.epilog.vector.body:
55+
; CHECK: store <4 x i32>
5756

5857
define void @g(ptr %a, i32 %n) "prefer-vector-width"="256" {
5958
entry:
@@ -82,19 +81,11 @@ for.end: ; preds = %for.end.loopexit, %
8281
; Verify that the "prefer-vector-width=512" attribute override the subtarget
8382
; vectors
8483

85-
; CHECK-LABEL: _h:
86-
; CHECK: %vec.epilog.vector.body
87-
; CHECK: %ymm
88-
; CHECK: %vector.body
89-
; CHECK: vmovdqu64 %zmm{{.}},
90-
; CHECK-NOT: %ymm
91-
92-
; CHECK-PREFER-AVX256-LABEL: h:
93-
; CHECK-PREFER-AVX256: %vec.epilog.vector.body
94-
; CHECK-PREFER-AVX256: %ymm
95-
; CHECK-PREFER-AVX256: %vector.body
96-
; CHECK-PREFER-AVX256: vmovdqu64 %zmm{{.}},
97-
; CHECK-PREFER-AVX256-NOT: %ymm
84+
; CHECK-LABEL: @h(
85+
; CHECK: vector.body:
86+
; CHECK: store <16 x i32>
87+
; CHECK: vec.epilog.vector.body:
88+
; CHECK: store <8 x i32>
9889

9990
define void @h(ptr %a, i32 %n) "prefer-vector-width"="512" {
10091
entry:

llvm/test/Transforms/LoopVectorize/X86/fp32_to_uint32-cost-model.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; RUN: opt < %s -mcpu=core-avx2 -passes=loop-vectorize -S | llc -mcpu=core-avx2 | FileCheck %s
1+
; RUN: opt < %s -mcpu=core-avx2 -passes=loop-vectorize -S | FileCheck %s
22

33
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
44
target triple = "x86_64-apple-macosx"
@@ -8,7 +8,7 @@ target triple = "x86_64-apple-macosx"
88

99
; If we need to scalarize the fptoui and then use inserts to build up the
1010
; vector again, then there is certainly no value in going 256-bit wide.
11-
; CHECK-NOT: vinserti128
11+
; CHECK-NOT: fptoui <4 x float>
1212

1313
define void @convert(i32 %N) {
1414
entry:

llvm/test/Transforms/LoopVectorize/X86/fp64_to_uint32-cost-model.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; RUN: opt < %s -mcpu=core-avx2 -passes=loop-vectorize -S | llc -mcpu=core-avx2 | FileCheck %s
1+
; RUN: opt < %s -mcpu=core-avx2 -passes=loop-vectorize -S | FileCheck %s
22

33
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
44
target triple = "x86_64-apple-macosx"
@@ -9,7 +9,7 @@ target triple = "x86_64-apple-macosx"
99

1010
; If we need to scalarize the fptoui and then use inserts to build up the
1111
; vector again, then there is certainly no value in going 256-bit wide.
12-
; CHECK-NOT: vpinsrd
12+
; CHECK-NOT: fptoui <2 x double>
1313

1414
define void @convert() {
1515
entry:

llvm/test/Transforms/LoopVectorize/X86/vectorization-remarks-loopid-dbg.ll

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
; RUN: opt < %s -passes=loop-vectorize -force-vector-width=1 -force-vector-interleave=4 -mtriple=x86_64-unknown-linux -S -pass-remarks='loop-vectorize' 2>&1 | FileCheck -check-prefix=UNROLLED %s
33
; RUN: opt < %s -passes=loop-vectorize -force-vector-width=1 -force-vector-interleave=1 -mtriple=x86_64-unknown-linux -S -pass-remarks-analysis='loop-vectorize' 2>&1 | FileCheck -check-prefix=NONE %s
44

5-
; RUN: llc < %s -mtriple x86_64-pc-linux-gnu -o - | FileCheck -check-prefix=DEBUG-OUTPUT %s
6-
; DEBUG-OUTPUT-NOT: .loc
7-
; DEBUG-OUTPUT-NOT: {{.*}}.debug_info
8-
95
; VECTORIZED: remark: vectorization-remarks.c:17:8: vectorized loop (vectorization width: 4, interleaved count: 2)
106
; UNROLLED: remark: vectorization-remarks.c:17:8: interleaved loop (interleaved count: 4)
117
; NONE: remark: vectorization-remarks.c:17:8: loop not vectorized: vectorization and interleaving are explicitly disabled, or the loop has already been vectorized

llvm/test/Transforms/LoopVectorize/X86/vectorization-remarks.ll

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
; RUN: opt < %s -passes=loop-vectorize -force-vector-width=1 -force-vector-interleave=4 -mtriple=x86_64-unknown-linux -S -pass-remarks='loop-vectorize' 2>&1 | FileCheck -check-prefix=UNROLLED %s
33
; RUN: opt < %s -passes=loop-vectorize -force-vector-width=1 -force-vector-interleave=1 -mtriple=x86_64-unknown-linux -S -pass-remarks-analysis='loop-vectorize' 2>&1 | FileCheck -check-prefix=NONE %s
44

5-
; RUN: llc < %s -mtriple x86_64-pc-linux-gnu -o - | FileCheck -check-prefix=DEBUG-OUTPUT %s
6-
; DEBUG-OUTPUT-NOT: .loc
7-
; DEBUG-OUTPUT-NOT: {{.*}}.debug_info
8-
95
; VECTORIZED: remark: vectorization-remarks.c:17:8: vectorized loop (vectorization width: 4, interleaved count: 2)
106
; UNROLLED: remark: vectorization-remarks.c:17:8: interleaved loop (interleaved count: 4)
117
; NONE: remark: vectorization-remarks.c:17:8: loop not vectorized: vectorization and interleaving are explicitly disabled, or the loop has already been vectorized

0 commit comments

Comments
 (0)