1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -passes=slp-vectorizer -mtriple=x86_64-apple-macosx -mcpu=haswell < %s | FileCheck %s
4 define void @test(ptr %r, ptr %p, ptr %q) #0 {
6 ; CHECK-NEXT: [[P0:%.*]] = getelementptr inbounds i64, ptr [[P:%.*]], i64 0
7 ; CHECK-NEXT: [[Q0:%.*]] = getelementptr inbounds i64, ptr [[Q:%.*]], i64 0
8 ; CHECK-NEXT: [[TMP1:%.*]] = load <4 x i64>, ptr [[P0]], align 2
9 ; CHECK-NEXT: [[TMP2:%.*]] = load <4 x i64>, ptr [[Q0]], align 2
10 ; CHECK-NEXT: [[TMP3:%.*]] = sub nsw <4 x i64> [[TMP1]], [[TMP2]]
11 ; CHECK-NEXT: [[TMP4:%.*]] = extractelement <4 x i64> [[TMP3]], i32 0
12 ; CHECK-NEXT: [[G0:%.*]] = getelementptr inbounds i32, ptr [[R:%.*]], i64 [[TMP4]]
13 ; CHECK-NEXT: [[TMP5:%.*]] = extractelement <4 x i64> [[TMP3]], i32 1
14 ; CHECK-NEXT: [[G1:%.*]] = getelementptr inbounds i32, ptr [[R]], i64 [[TMP5]]
15 ; CHECK-NEXT: [[TMP6:%.*]] = extractelement <4 x i64> [[TMP3]], i32 2
16 ; CHECK-NEXT: [[G2:%.*]] = getelementptr inbounds i32, ptr [[R]], i64 [[TMP6]]
17 ; CHECK-NEXT: [[TMP7:%.*]] = extractelement <4 x i64> [[TMP3]], i32 3
18 ; CHECK-NEXT: [[G3:%.*]] = getelementptr inbounds i32, ptr [[R]], i64 [[TMP7]]
19 ; CHECK-NEXT: ret void
21 %p0 = getelementptr inbounds i64, ptr %p, i64 0
22 %p1 = getelementptr inbounds i64, ptr %p, i64 1
23 %p2 = getelementptr inbounds i64, ptr %p, i64 2
24 %p3 = getelementptr inbounds i64, ptr %p, i64 3
26 %q0 = getelementptr inbounds i64, ptr %q, i64 0
27 %q1 = getelementptr inbounds i64, ptr %q, i64 1
28 %q2 = getelementptr inbounds i64, ptr %q, i64 2
29 %q3 = getelementptr inbounds i64, ptr %q, i64 3
31 %x0 = load i64, ptr %p0, align 2
32 %x1 = load i64, ptr %p1, align 2
33 %x2 = load i64, ptr %p2, align 2
34 %x3 = load i64, ptr %p3, align 2
36 %y0 = load i64, ptr %q0, align 2
37 %y1 = load i64, ptr %q1, align 2
38 %y2 = load i64, ptr %q2, align 2
39 %y3 = load i64, ptr %q3, align 2
41 %sub0 = sub nsw i64 %x0, %y0
42 %sub1 = sub nsw i64 %x1, %y1
43 %sub2 = sub nsw i64 %x2, %y2
44 %sub3 = sub nsw i64 %x3, %y3
46 %g0 = getelementptr inbounds i32, ptr %r, i64 %sub0
47 %g1 = getelementptr inbounds i32, ptr %r, i64 %sub1
48 %g2 = getelementptr inbounds i32, ptr %r, i64 %sub2
49 %g3 = getelementptr inbounds i32, ptr %r, i64 %sub3
53 define void @test2(i64* %a, i64* %b) {
54 ; CHECK-LABEL: @test2(
55 ; CHECK-NEXT: [[A1:%.*]] = getelementptr inbounds i64, ptr [[A:%.*]], i64 1
56 ; CHECK-NEXT: [[A2:%.*]] = getelementptr inbounds i64, ptr [[A]], i64 2
57 ; CHECK-NEXT: [[I1:%.*]] = ptrtoint ptr [[A1]] to i64
58 ; CHECK-NEXT: [[B3:%.*]] = getelementptr inbounds i64, ptr [[B:%.*]], i64 3
59 ; CHECK-NEXT: [[I2:%.*]] = ptrtoint ptr [[B3]] to i64
60 ; CHECK-NEXT: [[V1:%.*]] = load i64, ptr [[A1]], align 8
61 ; CHECK-NEXT: [[V2:%.*]] = load i64, ptr [[A2]], align 8
62 ; CHECK-NEXT: [[ADD1:%.*]] = add i64 [[I1]], [[V1]]
63 ; CHECK-NEXT: [[ADD2:%.*]] = add i64 [[I2]], [[V2]]
64 ; CHECK-NEXT: store i64 [[ADD1]], ptr [[A1]], align 8
65 ; CHECK-NEXT: store i64 [[ADD2]], ptr [[A2]], align 8
66 ; CHECK-NEXT: ret void
68 %a1 = getelementptr inbounds i64, i64* %a, i64 1
69 %a2 = getelementptr inbounds i64, i64* %a, i64 2
70 %i1 = ptrtoint i64* %a1 to i64
71 %b3 = getelementptr inbounds i64, i64* %b, i64 3
72 %i2 = ptrtoint i64* %b3 to i64
73 %v1 = load i64, i64* %a1, align 8
74 %v2 = load i64, i64* %a2, align 8
75 %add1 = add i64 %i1, %v1
76 %add2 = add i64 %i2, %v2
77 store i64 %add1, i64* %a1, align 8
78 store i64 %add2, i64* %a2, align 8