Skip to content

Commit aa4cbab

Browse files
committed
[SLP][NFC]Add a test with @llvm.abs nodes, which can be analyzed for
better bitwidth.
1 parent 49b5208 commit aa4cbab

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2+
; RUN: opt < %s -S -mtriple=x86_64-unknown -mattr=+avx512vl -passes=slp-vectorizer -slp-threshold=-3 | FileCheck %s
3+
4+
5+
define i32 @test(ptr noalias %in, ptr noalias %inn, ptr %out) {
6+
; CHECK-LABEL: @test(
7+
; CHECK-NEXT: [[TMP1:%.*]] = load <2 x i8>, ptr [[IN:%.*]], align 1
8+
; CHECK-NEXT: [[GEP_2:%.*]] = getelementptr inbounds i8, ptr [[IN]], i64 2
9+
; CHECK-NEXT: [[TMP2:%.*]] = load <2 x i8>, ptr [[GEP_2]], align 1
10+
; CHECK-NEXT: [[TMP3:%.*]] = load <2 x i8>, ptr [[INN:%.*]], align 1
11+
; CHECK-NEXT: [[GEP_5:%.*]] = getelementptr inbounds i8, ptr [[INN]], i64 2
12+
; CHECK-NEXT: [[TMP4:%.*]] = load <2 x i8>, ptr [[GEP_5]], align 1
13+
; CHECK-NEXT: [[TMP5:%.*]] = shufflevector <2 x i8> [[TMP3]], <2 x i8> poison, <4 x i32> <i32 0, i32 1, i32 poison, i32 poison>
14+
; CHECK-NEXT: [[TMP6:%.*]] = shufflevector <2 x i8> [[TMP2]], <2 x i8> poison, <4 x i32> <i32 0, i32 1, i32 poison, i32 poison>
15+
; CHECK-NEXT: [[TMP7:%.*]] = shufflevector <4 x i8> [[TMP5]], <4 x i8> [[TMP6]], <4 x i32> <i32 0, i32 1, i32 4, i32 5>
16+
; CHECK-NEXT: [[TMP8:%.*]] = sext <4 x i8> [[TMP7]] to <4 x i32>
17+
; CHECK-NEXT: [[TMP9:%.*]] = shufflevector <2 x i8> [[TMP1]], <2 x i8> poison, <4 x i32> <i32 0, i32 1, i32 poison, i32 poison>
18+
; CHECK-NEXT: [[TMP10:%.*]] = shufflevector <2 x i8> [[TMP4]], <2 x i8> poison, <4 x i32> <i32 0, i32 1, i32 poison, i32 poison>
19+
; CHECK-NEXT: [[TMP11:%.*]] = shufflevector <4 x i8> [[TMP9]], <4 x i8> [[TMP10]], <4 x i32> <i32 0, i32 1, i32 4, i32 5>
20+
; CHECK-NEXT: [[TMP12:%.*]] = sext <4 x i8> [[TMP11]] to <4 x i32>
21+
; CHECK-NEXT: [[TMP13:%.*]] = sub <4 x i32> [[TMP12]], [[TMP8]]
22+
; CHECK-NEXT: [[TMP14:%.*]] = call <4 x i32> @llvm.abs.v4i32(<4 x i32> [[TMP13]], i1 true)
23+
; CHECK-NEXT: [[TMP15:%.*]] = trunc <4 x i32> [[TMP14]] to <4 x i16>
24+
; CHECK-NEXT: store <4 x i16> [[TMP15]], ptr [[OUT:%.*]], align 2
25+
; CHECK-NEXT: ret i32 undef
26+
;
27+
%load.1 = load i8, ptr %in, align 1
28+
%gep.1 = getelementptr inbounds i8, ptr %in, i64 1
29+
%load.2 = load i8, ptr %gep.1, align 1
30+
%gep.2 = getelementptr inbounds i8, ptr %in, i64 2
31+
%load.3 = load i8, ptr %gep.2, align 1
32+
%gep.3 = getelementptr inbounds i8, ptr %in, i64 3
33+
%load.4 = load i8, ptr %gep.3, align 1
34+
%load.5 = load i8, ptr %inn, align 1
35+
%gep.4 = getelementptr inbounds i8, ptr %inn, i64 1
36+
%load.6 = load i8, ptr %gep.4, align 1
37+
%gep.5 = getelementptr inbounds i8, ptr %inn, i64 2
38+
%load.7 = load i8, ptr %gep.5, align 1
39+
%gep.6 = getelementptr inbounds i8, ptr %inn, i64 3
40+
%load.8 = load i8, ptr %gep.6, align 1
41+
%sext1 = sext i8 %load.1 to i32
42+
%sext2 = sext i8 %load.2 to i32
43+
%sext3 = sext i8 %load.3 to i32
44+
%sext4 = sext i8 %load.4 to i32
45+
%sext5 = sext i8 %load.5 to i32
46+
%sext6 = sext i8 %load.6 to i32
47+
%sext7 = sext i8 %load.7 to i32
48+
%sext8 = sext i8 %load.8 to i32
49+
%sub1 = sub i32 %sext1, %sext5
50+
%sub2 = sub i32 %sext2, %sext6
51+
%sub3 = sub i32 %sext7, %sext3
52+
%sub4 = sub i32 %sext8, %sext4
53+
%call1 = call i32 @llvm.abs(i32 %sub1, i1 true)
54+
%call2 = call i32 @llvm.abs(i32 %sub2, i1 true)
55+
%call3 = call i32 @llvm.abs(i32 %sub3, i1 true)
56+
%call4 = call i32 @llvm.abs(i32 %sub4, i1 true)
57+
%t1 = trunc i32 %call1 to i16
58+
%t2 = trunc i32 %call2 to i16
59+
%t3 = trunc i32 %call3 to i16
60+
%t4 = trunc i32 %call4 to i16
61+
%gep.8 = getelementptr inbounds i16, ptr %out, i64 1
62+
%gep.9 = getelementptr inbounds i16, ptr %out, i64 2
63+
%gep.10 = getelementptr inbounds i16, ptr %out, i64 3
64+
store i16 %t1, ptr %out, align 2
65+
store i16 %t2, ptr %gep.8, align 2
66+
store i16 %t3, ptr %gep.9, align 2
67+
store i16 %t4, ptr %gep.10, align 2
68+
69+
ret i32 undef
70+
}

0 commit comments

Comments
 (0)