1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=slp-vectorizer -S -mtriple=x86_64-unknown-linux -slp-threshold=-2 | FileCheck %s
4 define i32 @diamond_broadcast(ptr noalias nocapture %B, ptr noalias nocapture %A) {
5 ; CHECK-LABEL: @diamond_broadcast(
7 ; CHECK-NEXT: [[LD:%.*]] = load i32, ptr [[A:%.*]], align 4
8 ; CHECK-NEXT: [[TMP0:%.*]] = insertelement <4 x i32> poison, i32 [[LD]], i32 0
9 ; CHECK-NEXT: [[SHUFFLE:%.*]] = shufflevector <4 x i32> [[TMP0]], <4 x i32> poison, <4 x i32> zeroinitializer
10 ; CHECK-NEXT: [[TMP1:%.*]] = mul <4 x i32> [[SHUFFLE]], [[SHUFFLE]]
11 ; CHECK-NEXT: store <4 x i32> [[TMP1]], ptr [[B:%.*]], align 4
12 ; CHECK-NEXT: ret i32 0
15 %ld = load i32, ptr %A, align 4
16 %mul = mul i32 %ld, %ld
17 store i32 %mul, ptr %B, align 4
18 %mul8 = mul i32 %ld, %ld
19 %arrayidx9 = getelementptr inbounds i32, ptr %B, i64 1
20 store i32 %mul8, ptr %arrayidx9, align 4
21 %mul14 = mul i32 %ld, %ld
22 %arrayidx15 = getelementptr inbounds i32, ptr %B, i64 2
23 store i32 %mul14, ptr %arrayidx15, align 4
24 %mul20 = mul i32 %ld, undef
25 %arrayidx21 = getelementptr inbounds i32, ptr %B, i64 3
26 store i32 %mul20, ptr %arrayidx21, align 4
30 define i32 @diamond_broadcast2(ptr noalias nocapture %B, ptr noalias nocapture %A) {
31 ; CHECK-LABEL: @diamond_broadcast2(
33 ; CHECK-NEXT: [[LD:%.*]] = load i32, ptr [[A:%.*]], align 4
34 ; CHECK-NEXT: [[TMP0:%.*]] = insertelement <4 x i32> poison, i32 [[LD]], i32 0
35 ; CHECK-NEXT: [[SHUFFLE:%.*]] = shufflevector <4 x i32> [[TMP0]], <4 x i32> poison, <4 x i32> zeroinitializer
36 ; CHECK-NEXT: [[TMP1:%.*]] = mul <4 x i32> [[SHUFFLE]], [[SHUFFLE]]
37 ; CHECK-NEXT: store <4 x i32> [[TMP1]], ptr [[B:%.*]], align 4
38 ; CHECK-NEXT: ret i32 0
41 %ld = load i32, ptr %A, align 4
42 %mul = mul i32 %ld, %ld
43 store i32 %mul, ptr %B, align 4
44 %mul8 = mul i32 %ld, %ld
45 %arrayidx9 = getelementptr inbounds i32, ptr %B, i64 1
46 store i32 %mul8, ptr %arrayidx9, align 4
47 %mul14 = mul i32 %ld, %ld
48 %arrayidx15 = getelementptr inbounds i32, ptr %B, i64 2
49 store i32 %mul14, ptr %arrayidx15, align 4
50 %mul20 = mul i32 undef, %ld
51 %arrayidx21 = getelementptr inbounds i32, ptr %B, i64 3
52 store i32 %mul20, ptr %arrayidx21, align 4
56 define i32 @diamond_broadcast3(ptr noalias nocapture %B, ptr noalias nocapture %A) {
57 ; CHECK-LABEL: @diamond_broadcast3(
59 ; CHECK-NEXT: [[LD:%.*]] = load i32, ptr [[A:%.*]], align 4
60 ; CHECK-NEXT: [[TMP0:%.*]] = insertelement <4 x i32> poison, i32 [[LD]], i32 0
61 ; CHECK-NEXT: [[SHUFFLE:%.*]] = shufflevector <4 x i32> [[TMP0]], <4 x i32> poison, <4 x i32> zeroinitializer
62 ; CHECK-NEXT: [[TMP1:%.*]] = mul <4 x i32> [[SHUFFLE]], [[SHUFFLE]]
63 ; CHECK-NEXT: store <4 x i32> [[TMP1]], ptr [[B:%.*]], align 4
64 ; CHECK-NEXT: ret i32 0
67 %ld = load i32, ptr %A, align 4
68 %mul = mul i32 %ld, %ld
69 store i32 %mul, ptr %B, align 4
70 %mul8 = mul i32 %ld, %ld
71 %arrayidx9 = getelementptr inbounds i32, ptr %B, i64 1
72 store i32 %mul8, ptr %arrayidx9, align 4
73 %mul14 = mul i32 %ld, undef
74 %arrayidx15 = getelementptr inbounds i32, ptr %B, i64 2
75 store i32 %mul14, ptr %arrayidx15, align 4
76 %mul20 = mul i32 undef, %ld
77 %arrayidx21 = getelementptr inbounds i32, ptr %B, i64 3
78 store i32 %mul20, ptr %arrayidx21, align 4