1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=slp-vectorizer -S |FileCheck %s
3 ; RUN: opt < %s -aa-pipeline=basic-aa -passes=slp-vectorizer -S |FileCheck %s
4 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
5 target triple = "x86_64-unknown-unknown"
7 ; Test if SLP can handle GEP expressions.
8 ; The test perform the following action:
9 ; x->first = y->first + 16
10 ; x->second = y->second + 16
12 define void @foo1 (ptr noalias %x, ptr noalias %y) {
14 ; CHECK-NEXT: [[TMP1:%.*]] = getelementptr inbounds { ptr, ptr }, ptr [[Y:%.*]], i64 0, i32 0
15 ; CHECK-NEXT: [[TMP2:%.*]] = getelementptr inbounds { ptr, ptr }, ptr [[X:%.*]], i64 0, i32 0
16 ; CHECK-NEXT: [[TMP4:%.*]] = load <2 x ptr>, ptr [[TMP1]], align 8
17 ; CHECK-NEXT: [[TMP5:%.*]] = getelementptr i32, <2 x ptr> [[TMP4]], <2 x i64> <i64 16, i64 16>
18 ; CHECK-NEXT: store <2 x ptr> [[TMP5]], ptr [[TMP2]], align 8
19 ; CHECK-NEXT: ret void
21 %1 = getelementptr inbounds { ptr, ptr }, ptr %y, i64 0, i32 0
22 %2 = load ptr, ptr %1, align 8
23 %3 = getelementptr inbounds i32, ptr %2, i64 16
24 %4 = getelementptr inbounds { ptr, ptr }, ptr %x, i64 0, i32 0
25 store ptr %3, ptr %4, align 8
26 %5 = getelementptr inbounds { ptr, ptr }, ptr %y, i64 0, i32 1
27 %6 = load ptr, ptr %5, align 8
28 %7 = getelementptr inbounds i32, ptr %6, i64 16
29 %8 = getelementptr inbounds { ptr, ptr }, ptr %x, i64 0, i32 1
30 store ptr %7, ptr %8, align 8
34 ; Test that we don't vectorize GEP expressions if indexes are not constants.
35 ; We can't produce an efficient code in that case.
36 define void @foo2 (ptr noalias %x, ptr noalias %y, i32 %i) {
38 ; CHECK-NEXT: [[TMP1:%.*]] = getelementptr inbounds { ptr, ptr }, ptr [[Y:%.*]], i64 0, i32 0
39 ; CHECK-NEXT: [[TMP2:%.*]] = load ptr, ptr [[TMP1]], align 8
40 ; CHECK-NEXT: [[TMP3:%.*]] = getelementptr inbounds i32, ptr [[TMP2]], i32 [[I:%.*]]
41 ; CHECK-NEXT: [[TMP4:%.*]] = getelementptr inbounds { ptr, ptr }, ptr [[X:%.*]], i64 0, i32 0
42 ; CHECK-NEXT: store ptr [[TMP3]], ptr [[TMP4]], align 8
43 ; CHECK-NEXT: [[TMP5:%.*]] = getelementptr inbounds { ptr, ptr }, ptr [[Y]], i64 0, i32 1
44 ; CHECK-NEXT: [[TMP6:%.*]] = load ptr, ptr [[TMP5]], align 8
45 ; CHECK-NEXT: [[TMP7:%.*]] = getelementptr inbounds i32, ptr [[TMP6]], i32 [[I]]
46 ; CHECK-NEXT: [[TMP8:%.*]] = getelementptr inbounds { ptr, ptr }, ptr [[X]], i64 0, i32 1
47 ; CHECK-NEXT: store ptr [[TMP7]], ptr [[TMP8]], align 8
48 ; CHECK-NEXT: ret void
50 %1 = getelementptr inbounds { ptr, ptr }, ptr %y, i64 0, i32 0
51 %2 = load ptr, ptr %1, align 8
52 %3 = getelementptr inbounds i32, ptr %2, i32 %i
53 %4 = getelementptr inbounds { ptr, ptr }, ptr %x, i64 0, i32 0
54 store ptr %3, ptr %4, align 8
55 %5 = getelementptr inbounds { ptr, ptr }, ptr %y, i64 0, i32 1
56 %6 = load ptr, ptr %5, align 8
57 %7 = getelementptr inbounds i32, ptr %6, i32 %i
58 %8 = getelementptr inbounds { ptr, ptr }, ptr %x, i64 0, i32 1
59 store ptr %7, ptr %8, align 8