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: [[E0:%.*]] = extractelement <4 x i32> [[SUB0]], i32 0
16 ; CHECK-NEXT: [[S0:%.*]] = sext i32 [[E0]] to i64
17 ; CHECK-NEXT: [[GEP0:%.*]] = getelementptr inbounds i64, i64* [[P:%.*]], i64 [[S0]]
18 ; CHECK-NEXT: [[LOAD0:%.*]] = load i64, i64* [[GEP0]]
19 ; CHECK-NEXT: [[E1:%.*]] = extractelement <4 x i32> [[SUB0]], i32 1
20 ; CHECK-NEXT: [[S1:%.*]] = sext i32 [[E1]] to i64
21 ; CHECK-NEXT: [[GEP1:%.*]] = getelementptr inbounds i64, i64* [[P]], i64 [[S1]]
22 ; CHECK-NEXT: [[LOAD1:%.*]] = load i64, i64* [[GEP1]]
23 ; CHECK-NEXT: [[E2:%.*]] = extractelement <4 x i32> [[SUB0]], i32 2
24 ; CHECK-NEXT: [[S2:%.*]] = sext i32 [[E2]] to i64
25 ; CHECK-NEXT: [[GEP2:%.*]] = getelementptr inbounds i64, i64* [[P]], i64 [[S2]]
26 ; CHECK-NEXT: [[LOAD2:%.*]] = load i64, i64* [[GEP2]]
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, i64* [[P]], i64 [[S3]]
30 ; CHECK-NEXT: [[LOAD3:%.*]] = load i64, i64* [[GEP3]]
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, i64* %p, i64 %s0
41 %load0 = load i64, i64* %gep0
42 %e1 = extractelement <4 x i32> %sub0, i32 1
43 %s1 = sext i32 %e1 to i64
44 %gep1 = getelementptr inbounds i64, i64* %p, i64 %s1
45 %load1 = load i64, i64* %gep1
46 %e2 = extractelement <4 x i32> %sub0, i32 2
47 %s2 = sext i32 %e2 to i64
48 %gep2 = getelementptr inbounds i64, i64* %p, i64 %s2
49 %load2 = load i64, i64* %gep2
50 %e3 = extractelement <4 x i32> %sub0, i32 3
51 %s3 = sext i32 %e3 to i64
52 %gep3 = getelementptr inbounds i64, i64* %p, i64 %s3
53 %load3 = load i64, i64* %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, i64* %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: [[TMP0:%.*]] = sext <4 x i32> [[SUB0]] to <4 x i64>
65 ; CHECK-NEXT: [[TMP1:%.*]] = insertelement <4 x i64> undef, i64 [[C0:%.*]], i32 0
66 ; CHECK-NEXT: [[TMP2:%.*]] = insertelement <4 x i64> [[TMP1]], i64 [[C1:%.*]], i32 1
67 ; CHECK-NEXT: [[TMP3:%.*]] = insertelement <4 x i64> [[TMP2]], i64 [[C2:%.*]], i32 2
68 ; CHECK-NEXT: [[TMP4:%.*]] = insertelement <4 x i64> [[TMP3]], i64 [[C3:%.*]], i32 3
69 ; CHECK-NEXT: [[TMP5:%.*]] = add <4 x i64> [[TMP0]], [[TMP4]]
70 ; CHECK-NEXT: [[TMP6:%.*]] = extractelement <4 x i64> [[TMP5]], i32 0
71 ; CHECK-NEXT: [[GEP0:%.*]] = getelementptr inbounds i64, i64* [[P:%.*]], i64 [[TMP6]]
72 ; CHECK-NEXT: [[LOAD0:%.*]] = load i64, i64* [[GEP0]]
73 ; CHECK-NEXT: [[TMP7:%.*]] = extractelement <4 x i64> [[TMP5]], i32 1
74 ; CHECK-NEXT: [[GEP1:%.*]] = getelementptr inbounds i64, i64* [[P]], i64 [[TMP7]]
75 ; CHECK-NEXT: [[LOAD1:%.*]] = load i64, i64* [[GEP1]]
76 ; CHECK-NEXT: [[TMP8:%.*]] = extractelement <4 x i64> [[TMP5]], i32 2
77 ; CHECK-NEXT: [[GEP2:%.*]] = getelementptr inbounds i64, i64* [[P]], i64 [[TMP8]]
78 ; CHECK-NEXT: [[LOAD2:%.*]] = load i64, i64* [[GEP2]]
79 ; CHECK-NEXT: [[TMP9:%.*]] = extractelement <4 x i64> [[TMP5]], i32 3
80 ; CHECK-NEXT: [[GEP3:%.*]] = getelementptr inbounds i64, i64* [[P]], i64 [[TMP9]]
81 ; CHECK-NEXT: [[LOAD3:%.*]] = load i64, i64* [[GEP3]]
82 ; CHECK-NEXT: call void @foo(i64 [[LOAD0]], i64 [[LOAD1]], i64 [[LOAD2]], i64 [[LOAD3]])
83 ; CHECK-NEXT: ret void
86 %z0 = zext <4 x i16> %a to <4 x i32>
87 %z1 = zext <4 x i16> %b to <4 x i32>
88 %sub0 = sub <4 x i32> %z0, %z1
89 %e0 = extractelement <4 x i32> %sub0, i32 0
90 %s0 = sext i32 %e0 to i64
91 %a0 = add i64 %s0, %c0
92 %gep0 = getelementptr inbounds i64, i64* %p, i64 %a0
93 %load0 = load i64, i64* %gep0
94 %e1 = extractelement <4 x i32> %sub0, i32 1
95 %s1 = sext i32 %e1 to i64
96 %a1 = add i64 %s1, %c1
97 %gep1 = getelementptr inbounds i64, i64* %p, i64 %a1
98 %load1 = load i64, i64* %gep1
99 %e2 = extractelement <4 x i32> %sub0, i32 2
100 %s2 = sext i32 %e2 to i64
101 %a2 = add i64 %s2, %c2
102 %gep2 = getelementptr inbounds i64, i64* %p, i64 %a2
103 %load2 = load i64, i64* %gep2
104 %e3 = extractelement <4 x i32> %sub0, i32 3
105 %s3 = sext i32 %e3 to i64
106 %a3 = add i64 %s3, %c3
107 %gep3 = getelementptr inbounds i64, i64* %p, i64 %a3
108 %load3 = load i64, i64* %gep3
109 call void @foo(i64 %load0, i64 %load1, i64 %load2, i64 %load3)