1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -passes=slp-vectorizer -mtriple=aarch64--linux-gnu < %s | FileCheck %s
4 target datalayout = "e-m:e-i32:64-i128:128-n32:64-S128"
6 declare void @foo(i64, i64, i64, i64)
8 define void @test1(<4 x i16> %a, <4 x i16> %b, ptr %p) {
9 ; Make sure types of sub and its sources are not extended.
10 ; CHECK-LABEL: @test1(
12 ; CHECK-NEXT: [[Z0:%.*]] = zext <4 x i16> [[A:%.*]] to <4 x i32>
13 ; CHECK-NEXT: [[Z1:%.*]] = zext <4 x i16> [[B:%.*]] to <4 x i32>
14 ; CHECK-NEXT: [[SUB0:%.*]] = sub <4 x i32> [[Z0]], [[Z1]]
15 ; CHECK-NEXT: [[E0:%.*]] = extractelement <4 x i32> [[SUB0]], i32 0
16 ; CHECK-NEXT: [[S0:%.*]] = sext i32 [[E0]] to i64
17 ; CHECK-NEXT: [[GEP0:%.*]] = getelementptr inbounds i64, ptr [[P:%.*]], i64 [[S0]]
18 ; CHECK-NEXT: [[LOAD0:%.*]] = load i64, ptr [[GEP0]], align 4
19 ; CHECK-NEXT: [[TMP0:%.*]] = shufflevector <4 x i32> [[SUB0]], <4 x i32> poison, <2 x i32> <i32 1, i32 2>
20 ; CHECK-NEXT: [[TMP1:%.*]] = sext <2 x i32> [[TMP0]] to <2 x i64>
21 ; CHECK-NEXT: [[TMP2:%.*]] = extractelement <2 x i64> [[TMP1]], i32 0
22 ; CHECK-NEXT: [[GEP1:%.*]] = getelementptr inbounds i64, ptr [[P]], i64 [[TMP2]]
23 ; CHECK-NEXT: [[LOAD1:%.*]] = load i64, ptr [[GEP1]], align 4
24 ; CHECK-NEXT: [[TMP3:%.*]] = extractelement <2 x i64> [[TMP1]], i32 1
25 ; CHECK-NEXT: [[GEP2:%.*]] = getelementptr inbounds i64, ptr [[P]], i64 [[TMP3]]
26 ; CHECK-NEXT: [[LOAD2:%.*]] = load i64, ptr [[GEP2]], align 4
27 ; CHECK-NEXT: [[E3:%.*]] = extractelement <4 x i32> [[SUB0]], i32 3
28 ; CHECK-NEXT: [[S3:%.*]] = sext i32 [[E3]] to i64
29 ; CHECK-NEXT: [[GEP3:%.*]] = getelementptr inbounds i64, ptr [[P]], i64 [[S3]]
30 ; CHECK-NEXT: [[LOAD3:%.*]] = load i64, ptr [[GEP3]], align 4
31 ; CHECK-NEXT: call void @foo(i64 [[LOAD0]], i64 [[LOAD1]], i64 [[LOAD2]], i64 [[LOAD3]])
32 ; CHECK-NEXT: ret void
35 %z0 = zext <4 x i16> %a to <4 x i32>
36 %z1 = zext <4 x i16> %b to <4 x i32>
37 %sub0 = sub <4 x i32> %z0, %z1
38 %e0 = extractelement <4 x i32> %sub0, i32 0
39 %s0 = sext i32 %e0 to i64
40 %gep0 = getelementptr inbounds i64, ptr %p, i64 %s0
41 %load0 = load i64, ptr %gep0
42 %e1 = extractelement <4 x i32> %sub0, i32 1
43 %s1 = sext i32 %e1 to i64
44 %gep1 = getelementptr inbounds i64, ptr %p, i64 %s1
45 %load1 = load i64, ptr %gep1
46 %e2 = extractelement <4 x i32> %sub0, i32 2
47 %s2 = sext i32 %e2 to i64
48 %gep2 = getelementptr inbounds i64, ptr %p, i64 %s2
49 %load2 = load i64, ptr %gep2
50 %e3 = extractelement <4 x i32> %sub0, i32 3
51 %s3 = sext i32 %e3 to i64
52 %gep3 = getelementptr inbounds i64, ptr %p, i64 %s3
53 %load3 = load i64, ptr %gep3
54 call void @foo(i64 %load0, i64 %load1, i64 %load2, i64 %load3)
58 define void @test2(<4 x i16> %a, <4 x i16> %b, i64 %c0, i64 %c1, i64 %c2, i64 %c3, ptr %p) {
59 ; CHECK-LABEL: @test2(
61 ; CHECK-NEXT: [[Z0:%.*]] = zext <4 x i16> [[A:%.*]] to <4 x i32>
62 ; CHECK-NEXT: [[Z1:%.*]] = zext <4 x i16> [[B:%.*]] to <4 x i32>
63 ; CHECK-NEXT: [[SUB0:%.*]] = sub <4 x i32> [[Z0]], [[Z1]]
64 ; CHECK-NEXT: [[E0:%.*]] = extractelement <4 x i32> [[SUB0]], i32 0
65 ; CHECK-NEXT: [[S0:%.*]] = sext i32 [[E0]] to i64
66 ; CHECK-NEXT: [[A0:%.*]] = add i64 [[S0]], [[C0:%.*]]
67 ; CHECK-NEXT: [[GEP0:%.*]] = getelementptr inbounds i64, ptr [[P:%.*]], i64 [[A0]]
68 ; CHECK-NEXT: [[LOAD0:%.*]] = load i64, ptr [[GEP0]], align 4
69 ; CHECK-NEXT: [[E1:%.*]] = extractelement <4 x i32> [[SUB0]], i32 1
70 ; CHECK-NEXT: [[S1:%.*]] = sext i32 [[E1]] to i64
71 ; CHECK-NEXT: [[A1:%.*]] = add i64 [[S1]], [[C1:%.*]]
72 ; CHECK-NEXT: [[GEP1:%.*]] = getelementptr inbounds i64, ptr [[P]], i64 [[A1]]
73 ; CHECK-NEXT: [[LOAD1:%.*]] = load i64, ptr [[GEP1]], align 4
74 ; CHECK-NEXT: [[E2:%.*]] = extractelement <4 x i32> [[SUB0]], i32 2
75 ; CHECK-NEXT: [[S2:%.*]] = sext i32 [[E2]] to i64
76 ; CHECK-NEXT: [[A2:%.*]] = add i64 [[S2]], [[C2:%.*]]
77 ; CHECK-NEXT: [[GEP2:%.*]] = getelementptr inbounds i64, ptr [[P]], i64 [[A2]]
78 ; CHECK-NEXT: [[LOAD2:%.*]] = load i64, ptr [[GEP2]], align 4
79 ; CHECK-NEXT: [[E3:%.*]] = extractelement <4 x i32> [[SUB0]], i32 3
80 ; CHECK-NEXT: [[S3:%.*]] = sext i32 [[E3]] to i64
81 ; CHECK-NEXT: [[A3:%.*]] = add i64 [[S3]], [[C3:%.*]]
82 ; CHECK-NEXT: [[GEP3:%.*]] = getelementptr inbounds i64, ptr [[P]], i64 [[A3]]
83 ; CHECK-NEXT: [[LOAD3:%.*]] = load i64, ptr [[GEP3]], align 4
84 ; CHECK-NEXT: call void @foo(i64 [[LOAD0]], i64 [[LOAD1]], i64 [[LOAD2]], i64 [[LOAD3]])
85 ; CHECK-NEXT: ret void
88 %z0 = zext <4 x i16> %a to <4 x i32>
89 %z1 = zext <4 x i16> %b to <4 x i32>
90 %sub0 = sub <4 x i32> %z0, %z1
91 %e0 = extractelement <4 x i32> %sub0, i32 0
92 %s0 = sext i32 %e0 to i64
93 %a0 = add i64 %s0, %c0
94 %gep0 = getelementptr inbounds i64, ptr %p, i64 %a0
95 %load0 = load i64, ptr %gep0
96 %e1 = extractelement <4 x i32> %sub0, i32 1
97 %s1 = sext i32 %e1 to i64
98 %a1 = add i64 %s1, %c1
99 %gep1 = getelementptr inbounds i64, ptr %p, i64 %a1
100 %load1 = load i64, ptr %gep1
101 %e2 = extractelement <4 x i32> %sub0, i32 2
102 %s2 = sext i32 %e2 to i64
103 %a2 = add i64 %s2, %c2
104 %gep2 = getelementptr inbounds i64, ptr %p, i64 %a2
105 %load2 = load i64, ptr %gep2
106 %e3 = extractelement <4 x i32> %sub0, i32 3
107 %s3 = sext i32 %e3 to i64
108 %a3 = add i64 %s3, %c3
109 %gep3 = getelementptr inbounds i64, ptr %p, i64 %a3
110 %load3 = load i64, ptr %gep3
111 call void @foo(i64 %load0, i64 %load1, i64 %load2, i64 %load3)