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:%.*]] = extractelement <2 x i32> [[TMP0]], i32 0
21 ; CHECK-NEXT: [[TMP2:%.*]] = sext i32 [[TMP1]] to i64
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 i32> [[TMP0]], i32 1
25 ; CHECK-NEXT: [[TMP4:%.*]] = sext i32 [[TMP3]] to i64
26 ; CHECK-NEXT: [[GEP2:%.*]] = getelementptr inbounds i64, ptr [[P]], i64 [[TMP4]]
27 ; CHECK-NEXT: [[LOAD2:%.*]] = load i64, ptr [[GEP2]], align 4
28 ; CHECK-NEXT: [[E3:%.*]] = extractelement <4 x i32> [[SUB0]], i32 3
29 ; CHECK-NEXT: [[S3:%.*]] = sext i32 [[E3]] to i64
30 ; CHECK-NEXT: [[GEP3:%.*]] = getelementptr inbounds i64, ptr [[P]], i64 [[S3]]
31 ; CHECK-NEXT: [[LOAD3:%.*]] = load i64, ptr [[GEP3]], align 4
32 ; CHECK-NEXT: call void @foo(i64 [[LOAD0]], i64 [[LOAD1]], i64 [[LOAD2]], i64 [[LOAD3]])
33 ; CHECK-NEXT: ret void
36 %z0 = zext <4 x i16> %a to <4 x i32>
37 %z1 = zext <4 x i16> %b to <4 x i32>
38 %sub0 = sub <4 x i32> %z0, %z1
39 %e0 = extractelement <4 x i32> %sub0, i32 0
40 %s0 = sext i32 %e0 to i64
41 %gep0 = getelementptr inbounds i64, ptr %p, i64 %s0
42 %load0 = load i64, ptr %gep0
43 %e1 = extractelement <4 x i32> %sub0, i32 1
44 %s1 = sext i32 %e1 to i64
45 %gep1 = getelementptr inbounds i64, ptr %p, i64 %s1
46 %load1 = load i64, ptr %gep1
47 %e2 = extractelement <4 x i32> %sub0, i32 2
48 %s2 = sext i32 %e2 to i64
49 %gep2 = getelementptr inbounds i64, ptr %p, i64 %s2
50 %load2 = load i64, ptr %gep2
51 %e3 = extractelement <4 x i32> %sub0, i32 3
52 %s3 = sext i32 %e3 to i64
53 %gep3 = getelementptr inbounds i64, ptr %p, i64 %s3
54 %load3 = load i64, ptr %gep3
55 call void @foo(i64 %load0, i64 %load1, i64 %load2, i64 %load3)
59 define void @test2(<4 x i16> %a, <4 x i16> %b, i64 %c0, i64 %c1, i64 %c2, i64 %c3, ptr %p) {
60 ; CHECK-LABEL: @test2(
62 ; CHECK-NEXT: [[Z0:%.*]] = zext <4 x i16> [[A:%.*]] to <4 x i32>
63 ; CHECK-NEXT: [[Z1:%.*]] = zext <4 x i16> [[B:%.*]] to <4 x i32>
64 ; CHECK-NEXT: [[SUB0:%.*]] = sub <4 x i32> [[Z0]], [[Z1]]
65 ; CHECK-NEXT: [[E0:%.*]] = extractelement <4 x i32> [[SUB0]], i32 0
66 ; CHECK-NEXT: [[S0:%.*]] = sext i32 [[E0]] to i64
67 ; CHECK-NEXT: [[A0:%.*]] = add i64 [[S0]], [[C0:%.*]]
68 ; CHECK-NEXT: [[GEP0:%.*]] = getelementptr inbounds i64, ptr [[P:%.*]], i64 [[A0]]
69 ; CHECK-NEXT: [[LOAD0:%.*]] = load i64, ptr [[GEP0]], align 4
70 ; CHECK-NEXT: [[E1:%.*]] = extractelement <4 x i32> [[SUB0]], i32 1
71 ; CHECK-NEXT: [[S1:%.*]] = sext i32 [[E1]] to i64
72 ; CHECK-NEXT: [[A1:%.*]] = add i64 [[S1]], [[C1:%.*]]
73 ; CHECK-NEXT: [[GEP1:%.*]] = getelementptr inbounds i64, ptr [[P]], i64 [[A1]]
74 ; CHECK-NEXT: [[LOAD1:%.*]] = load i64, ptr [[GEP1]], align 4
75 ; CHECK-NEXT: [[E2:%.*]] = extractelement <4 x i32> [[SUB0]], i32 2
76 ; CHECK-NEXT: [[S2:%.*]] = sext i32 [[E2]] to i64
77 ; CHECK-NEXT: [[A2:%.*]] = add i64 [[S2]], [[C2:%.*]]
78 ; CHECK-NEXT: [[GEP2:%.*]] = getelementptr inbounds i64, ptr [[P]], i64 [[A2]]
79 ; CHECK-NEXT: [[LOAD2:%.*]] = load i64, ptr [[GEP2]], align 4
80 ; CHECK-NEXT: [[E3:%.*]] = extractelement <4 x i32> [[SUB0]], i32 3
81 ; CHECK-NEXT: [[S3:%.*]] = sext i32 [[E3]] to i64
82 ; CHECK-NEXT: [[A3:%.*]] = add i64 [[S3]], [[C3:%.*]]
83 ; CHECK-NEXT: [[GEP3:%.*]] = getelementptr inbounds i64, ptr [[P]], i64 [[A3]]
84 ; CHECK-NEXT: [[LOAD3:%.*]] = load i64, ptr [[GEP3]], align 4
85 ; CHECK-NEXT: call void @foo(i64 [[LOAD0]], i64 [[LOAD1]], i64 [[LOAD2]], i64 [[LOAD3]])
86 ; CHECK-NEXT: ret void
89 %z0 = zext <4 x i16> %a to <4 x i32>
90 %z1 = zext <4 x i16> %b to <4 x i32>
91 %sub0 = sub <4 x i32> %z0, %z1
92 %e0 = extractelement <4 x i32> %sub0, i32 0
93 %s0 = sext i32 %e0 to i64
94 %a0 = add i64 %s0, %c0
95 %gep0 = getelementptr inbounds i64, ptr %p, i64 %a0
96 %load0 = load i64, ptr %gep0
97 %e1 = extractelement <4 x i32> %sub0, i32 1
98 %s1 = sext i32 %e1 to i64
99 %a1 = add i64 %s1, %c1
100 %gep1 = getelementptr inbounds i64, ptr %p, i64 %a1
101 %load1 = load i64, ptr %gep1
102 %e2 = extractelement <4 x i32> %sub0, i32 2
103 %s2 = sext i32 %e2 to i64
104 %a2 = add i64 %s2, %c2
105 %gep2 = getelementptr inbounds i64, ptr %p, i64 %a2
106 %load2 = load i64, ptr %gep2
107 %e3 = extractelement <4 x i32> %sub0, i32 3
108 %s3 = sext i32 %e3 to i64
109 %a3 = add i64 %s3, %c3
110 %gep3 = getelementptr inbounds i64, ptr %p, i64 %a3
111 %load3 = load i64, ptr %gep3
112 call void @foo(i64 %load0, i64 %load1, i64 %load2, i64 %load3)