1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -slp-vectorizer -S -mtriple=x86_64-unknown-linux -mcpu=corei7-avx -slp-threshold=-999 < %s | FileCheck %s
10 ; We broadcast %v1 and %v2
13 define void @bcast_vals(i64 *%A, i64 *%B, i64 *%S) {
14 ; CHECK-LABEL: @bcast_vals(
16 ; CHECK-NEXT: [[A0:%.*]] = load i64, i64* [[A:%.*]], align 8
17 ; CHECK-NEXT: [[B0:%.*]] = load i64, i64* [[B:%.*]], align 8
18 ; CHECK-NEXT: [[V1:%.*]] = sub i64 [[A0]], 1
19 ; CHECK-NEXT: [[V2:%.*]] = sub i64 [[B0]], 1
20 ; CHECK-NEXT: [[TMP0:%.*]] = insertelement <4 x i64> poison, i64 [[V1]], i32 0
21 ; CHECK-NEXT: [[SHUFFLE:%.*]] = shufflevector <4 x i64> [[TMP0]], <4 x i64> poison, <4 x i32> zeroinitializer
22 ; CHECK-NEXT: [[TMP1:%.*]] = insertelement <4 x i64> poison, i64 [[V2]], i32 0
23 ; CHECK-NEXT: [[SHUFFLE1:%.*]] = shufflevector <4 x i64> [[TMP1]], <4 x i64> poison, <4 x i32> zeroinitializer
24 ; CHECK-NEXT: [[TMP2:%.*]] = add <4 x i64> [[SHUFFLE]], [[SHUFFLE1]]
25 ; CHECK-NEXT: [[IDXS0:%.*]] = getelementptr inbounds i64, i64* [[S:%.*]], i64 0
26 ; CHECK-NEXT: [[IDXS1:%.*]] = getelementptr inbounds i64, i64* [[S]], i64 1
27 ; CHECK-NEXT: [[IDXS2:%.*]] = getelementptr inbounds i64, i64* [[S]], i64 2
28 ; CHECK-NEXT: [[IDXS3:%.*]] = getelementptr inbounds i64, i64* [[S]], i64 3
29 ; CHECK-NEXT: [[TMP3:%.*]] = bitcast i64* [[IDXS0]] to <4 x i64>*
30 ; CHECK-NEXT: store <4 x i64> [[TMP2]], <4 x i64>* [[TMP3]], align 8
31 ; CHECK-NEXT: ret void
34 %A0 = load i64, i64 *%A, align 8
35 %B0 = load i64, i64 *%B, align 8
40 %Add0 = add i64 %v1, %v2
41 %Add1 = add i64 %v2, %v1
42 %Add2 = add i64 %v2, %v1
43 %Add3 = add i64 %v1, %v2
45 %idxS0 = getelementptr inbounds i64, i64* %S, i64 0
46 %idxS1 = getelementptr inbounds i64, i64* %S, i64 1
47 %idxS2 = getelementptr inbounds i64, i64* %S, i64 2
48 %idxS3 = getelementptr inbounds i64, i64* %S, i64 3
50 store i64 %Add0, i64 *%idxS0, align 8
51 store i64 %Add1, i64 *%idxS1, align 8
52 store i64 %Add2, i64 *%idxS2, align 8
53 store i64 %Add3, i64 *%idxS3, align 8
65 define void @bcast_vals2(i16 *%A, i16 *%B, i16 *%C, i16 *%D, i16 *%E, i32 *%S) {
66 ; CHECK-LABEL: @bcast_vals2(
68 ; CHECK-NEXT: [[A0:%.*]] = load i16, i16* [[A:%.*]], align 8
69 ; CHECK-NEXT: [[B0:%.*]] = load i16, i16* [[B:%.*]], align 8
70 ; CHECK-NEXT: [[C0:%.*]] = load i16, i16* [[C:%.*]], align 8
71 ; CHECK-NEXT: [[D0:%.*]] = load i16, i16* [[D:%.*]], align 8
72 ; CHECK-NEXT: [[E0:%.*]] = load i16, i16* [[E:%.*]], align 8
73 ; CHECK-NEXT: [[V1:%.*]] = sext i16 [[A0]] to i32
74 ; CHECK-NEXT: [[TMP0:%.*]] = insertelement <4 x i16> poison, i16 [[B0]], i32 0
75 ; CHECK-NEXT: [[TMP1:%.*]] = insertelement <4 x i16> [[TMP0]], i16 [[C0]], i32 1
76 ; CHECK-NEXT: [[TMP2:%.*]] = insertelement <4 x i16> [[TMP1]], i16 [[E0]], i32 2
77 ; CHECK-NEXT: [[TMP3:%.*]] = insertelement <4 x i16> [[TMP2]], i16 [[D0]], i32 3
78 ; CHECK-NEXT: [[TMP4:%.*]] = sext <4 x i16> [[TMP3]] to <4 x i32>
79 ; CHECK-NEXT: [[TMP5:%.*]] = insertelement <4 x i32> poison, i32 [[V1]], i32 0
80 ; CHECK-NEXT: [[SHUFFLE:%.*]] = shufflevector <4 x i32> [[TMP5]], <4 x i32> poison, <4 x i32> zeroinitializer
81 ; CHECK-NEXT: [[TMP6:%.*]] = add <4 x i32> [[SHUFFLE]], [[TMP4]]
82 ; CHECK-NEXT: [[IDXS0:%.*]] = getelementptr inbounds i32, i32* [[S:%.*]], i64 0
83 ; CHECK-NEXT: [[IDXS1:%.*]] = getelementptr inbounds i32, i32* [[S]], i64 1
84 ; CHECK-NEXT: [[IDXS2:%.*]] = getelementptr inbounds i32, i32* [[S]], i64 2
85 ; CHECK-NEXT: [[IDXS3:%.*]] = getelementptr inbounds i32, i32* [[S]], i64 3
86 ; CHECK-NEXT: [[TMP7:%.*]] = bitcast i32* [[IDXS0]] to <4 x i32>*
87 ; CHECK-NEXT: store <4 x i32> [[TMP6]], <4 x i32>* [[TMP7]], align 8
88 ; CHECK-NEXT: ret void
91 %A0 = load i16, i16 *%A, align 8
92 %B0 = load i16, i16 *%B, align 8
93 %C0 = load i16, i16 *%C, align 8
94 %D0 = load i16, i16 *%D, align 8
95 %E0 = load i16, i16 *%E, align 8
97 %v1 = sext i16 %A0 to i32
98 %v2 = sext i16 %B0 to i32
99 %v3 = sext i16 %C0 to i32
100 %v4 = sext i16 %D0 to i32
101 %v5 = sext i16 %E0 to i32
103 %Add0 = add i32 %v1, %v2
104 %Add1 = add i32 %v3, %v1
105 %Add2 = add i32 %v5, %v1
106 %Add3 = add i32 %v1, %v4
108 %idxS0 = getelementptr inbounds i32, i32* %S, i64 0
109 %idxS1 = getelementptr inbounds i32, i32* %S, i64 1
110 %idxS2 = getelementptr inbounds i32, i32* %S, i64 2
111 %idxS3 = getelementptr inbounds i32, i32* %S, i64 3
113 store i32 %Add0, i32 *%idxS0, align 8
114 store i32 %Add1, i32 *%idxS1, align 8
115 store i32 %Add2, i32 *%idxS2, align 8
116 store i32 %Add3, i32 *%idxS3, align 8