1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -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, i64* %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: [[TMP0:%.*]] = sext <4 x i32> [[SUB0]] to <4 x i64>
16 ; CHECK-NEXT: [[TMP1:%.*]] = extractelement <4 x i64> [[TMP0]], i32 0
17 ; CHECK-NEXT: [[GEP0:%.*]] = getelementptr inbounds i64, i64* [[P:%.*]], i64 [[TMP1]]
18 ; CHECK-NEXT: [[LOAD0:%.*]] = load i64, i64* [[GEP0]], align 4
19 ; CHECK-NEXT: [[TMP2:%.*]] = extractelement <4 x i64> [[TMP0]], i32 1
20 ; CHECK-NEXT: [[GEP1:%.*]] = getelementptr inbounds i64, i64* [[P]], i64 [[TMP2]]
21 ; CHECK-NEXT: [[LOAD1:%.*]] = load i64, i64* [[GEP1]], align 4
22 ; CHECK-NEXT: [[TMP3:%.*]] = extractelement <4 x i64> [[TMP0]], i32 2
23 ; CHECK-NEXT: [[GEP2:%.*]] = getelementptr inbounds i64, i64* [[P]], i64 [[TMP3]]
24 ; CHECK-NEXT: [[LOAD2:%.*]] = load i64, i64* [[GEP2]], align 4
25 ; CHECK-NEXT: [[TMP4:%.*]] = extractelement <4 x i64> [[TMP0]], i32 3
26 ; CHECK-NEXT: [[GEP3:%.*]] = getelementptr inbounds i64, i64* [[P]], i64 [[TMP4]]
27 ; CHECK-NEXT: [[LOAD3:%.*]] = load i64, i64* [[GEP3]], align 4
28 ; CHECK-NEXT: call void @foo(i64 [[LOAD0]], i64 [[LOAD1]], i64 [[LOAD2]], i64 [[LOAD3]])
29 ; CHECK-NEXT: ret void
32 %z0 = zext <4 x i16> %a to <4 x i32>
33 %z1 = zext <4 x i16> %b to <4 x i32>
34 %sub0 = sub <4 x i32> %z0, %z1
35 %e0 = extractelement <4 x i32> %sub0, i32 0
36 %s0 = sext i32 %e0 to i64
37 %gep0 = getelementptr inbounds i64, i64* %p, i64 %s0
38 %load0 = load i64, i64* %gep0
39 %e1 = extractelement <4 x i32> %sub0, i32 1
40 %s1 = sext i32 %e1 to i64
41 %gep1 = getelementptr inbounds i64, i64* %p, i64 %s1
42 %load1 = load i64, i64* %gep1
43 %e2 = extractelement <4 x i32> %sub0, i32 2
44 %s2 = sext i32 %e2 to i64
45 %gep2 = getelementptr inbounds i64, i64* %p, i64 %s2
46 %load2 = load i64, i64* %gep2
47 %e3 = extractelement <4 x i32> %sub0, i32 3
48 %s3 = sext i32 %e3 to i64
49 %gep3 = getelementptr inbounds i64, i64* %p, i64 %s3
50 %load3 = load i64, i64* %gep3
51 call void @foo(i64 %load0, i64 %load1, i64 %load2, i64 %load3)
55 define void @test2(<4 x i16> %a, <4 x i16> %b, i64 %c0, i64 %c1, i64 %c2, i64 %c3, i64* %p) {
56 ; CHECK-LABEL: @test2(
58 ; CHECK-NEXT: [[Z0:%.*]] = zext <4 x i16> [[A:%.*]] to <4 x i32>
59 ; CHECK-NEXT: [[Z1:%.*]] = zext <4 x i16> [[B:%.*]] to <4 x i32>
60 ; CHECK-NEXT: [[SUB0:%.*]] = sub <4 x i32> [[Z0]], [[Z1]]
61 ; CHECK-NEXT: [[TMP0:%.*]] = sext <4 x i32> [[SUB0]] to <4 x i64>
62 ; CHECK-NEXT: [[TMP1:%.*]] = insertelement <4 x i64> poison, i64 [[C0:%.*]], i32 0
63 ; CHECK-NEXT: [[TMP2:%.*]] = insertelement <4 x i64> [[TMP1]], i64 [[C1:%.*]], i32 1
64 ; CHECK-NEXT: [[TMP3:%.*]] = insertelement <4 x i64> [[TMP2]], i64 [[C2:%.*]], i32 2
65 ; CHECK-NEXT: [[TMP4:%.*]] = insertelement <4 x i64> [[TMP3]], i64 [[C3:%.*]], i32 3
66 ; CHECK-NEXT: [[TMP5:%.*]] = add <4 x i64> [[TMP0]], [[TMP4]]
67 ; CHECK-NEXT: [[TMP6:%.*]] = extractelement <4 x i64> [[TMP5]], i32 0
68 ; CHECK-NEXT: [[GEP0:%.*]] = getelementptr inbounds i64, i64* [[P:%.*]], i64 [[TMP6]]
69 ; CHECK-NEXT: [[LOAD0:%.*]] = load i64, i64* [[GEP0]], align 4
70 ; CHECK-NEXT: [[TMP7:%.*]] = extractelement <4 x i64> [[TMP5]], i32 1
71 ; CHECK-NEXT: [[GEP1:%.*]] = getelementptr inbounds i64, i64* [[P]], i64 [[TMP7]]
72 ; CHECK-NEXT: [[LOAD1:%.*]] = load i64, i64* [[GEP1]], align 4
73 ; CHECK-NEXT: [[TMP8:%.*]] = extractelement <4 x i64> [[TMP5]], i32 2
74 ; CHECK-NEXT: [[GEP2:%.*]] = getelementptr inbounds i64, i64* [[P]], i64 [[TMP8]]
75 ; CHECK-NEXT: [[LOAD2:%.*]] = load i64, i64* [[GEP2]], align 4
76 ; CHECK-NEXT: [[TMP9:%.*]] = extractelement <4 x i64> [[TMP5]], i32 3
77 ; CHECK-NEXT: [[GEP3:%.*]] = getelementptr inbounds i64, i64* [[P]], i64 [[TMP9]]
78 ; CHECK-NEXT: [[LOAD3:%.*]] = load i64, i64* [[GEP3]], align 4
79 ; CHECK-NEXT: call void @foo(i64 [[LOAD0]], i64 [[LOAD1]], i64 [[LOAD2]], i64 [[LOAD3]])
80 ; CHECK-NEXT: ret void
83 %z0 = zext <4 x i16> %a to <4 x i32>
84 %z1 = zext <4 x i16> %b to <4 x i32>
85 %sub0 = sub <4 x i32> %z0, %z1
86 %e0 = extractelement <4 x i32> %sub0, i32 0
87 %s0 = sext i32 %e0 to i64
88 %a0 = add i64 %s0, %c0
89 %gep0 = getelementptr inbounds i64, i64* %p, i64 %a0
90 %load0 = load i64, i64* %gep0
91 %e1 = extractelement <4 x i32> %sub0, i32 1
92 %s1 = sext i32 %e1 to i64
93 %a1 = add i64 %s1, %c1
94 %gep1 = getelementptr inbounds i64, i64* %p, i64 %a1
95 %load1 = load i64, i64* %gep1
96 %e2 = extractelement <4 x i32> %sub0, i32 2
97 %s2 = sext i32 %e2 to i64
98 %a2 = add i64 %s2, %c2
99 %gep2 = getelementptr inbounds i64, i64* %p, i64 %a2
100 %load2 = load i64, i64* %gep2
101 %e3 = extractelement <4 x i32> %sub0, i32 3
102 %s3 = sext i32 %e3 to i64
103 %a3 = add i64 %s3, %c3
104 %gep3 = getelementptr inbounds i64, i64* %p, i64 %a3
105 %load3 = load i64, i64* %gep3
106 call void @foo(i64 %load0, i64 %load1, i64 %load2, i64 %load3)