1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -S -mtriple=x86_64-unknown -mattr=+avx -slp-vectorizer | FileCheck %s
4 ;void jumble (int * restrict A, int * restrict B) {
5 ; int tmp0 = A[10]*A[0];
6 ; int tmp1 = A[11]*A[1];
7 ; int tmp2 = A[12]*A[3];
8 ; int tmp3 = A[13]*A[2];
15 ; Function Attrs: norecurse nounwind uwtable
16 define void @jumble1(i32* noalias nocapture readonly %A, i32* noalias nocapture %B) {
17 ; CHECK-LABEL: @jumble1(
19 ; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, i32* [[A:%.*]], i64 10
20 ; CHECK-NEXT: [[ARRAYIDX2:%.*]] = getelementptr inbounds i32, i32* [[A]], i64 11
21 ; CHECK-NEXT: [[ARRAYIDX3:%.*]] = getelementptr inbounds i32, i32* [[A]], i64 1
22 ; CHECK-NEXT: [[ARRAYIDX5:%.*]] = getelementptr inbounds i32, i32* [[A]], i64 12
23 ; CHECK-NEXT: [[ARRAYIDX6:%.*]] = getelementptr inbounds i32, i32* [[A]], i64 3
24 ; CHECK-NEXT: [[ARRAYIDX8:%.*]] = getelementptr inbounds i32, i32* [[A]], i64 13
25 ; CHECK-NEXT: [[TMP0:%.*]] = bitcast i32* [[ARRAYIDX]] to <4 x i32>*
26 ; CHECK-NEXT: [[TMP1:%.*]] = load <4 x i32>, <4 x i32>* [[TMP0]], align 4
27 ; CHECK-NEXT: [[ARRAYIDX9:%.*]] = getelementptr inbounds i32, i32* [[A]], i64 2
28 ; CHECK-NEXT: [[TMP2:%.*]] = bitcast i32* [[A]] to <4 x i32>*
29 ; CHECK-NEXT: [[TMP3:%.*]] = load <4 x i32>, <4 x i32>* [[TMP2]], align 4
30 ; CHECK-NEXT: [[REORDER_SHUFFLE:%.*]] = shufflevector <4 x i32> [[TMP3]], <4 x i32> undef, <4 x i32> <i32 0, i32 1, i32 3, i32 2>
31 ; CHECK-NEXT: [[TMP4:%.*]] = mul nsw <4 x i32> [[TMP1]], [[REORDER_SHUFFLE]]
32 ; CHECK-NEXT: [[ARRAYIDX12:%.*]] = getelementptr inbounds i32, i32* [[B:%.*]], i64 1
33 ; CHECK-NEXT: [[ARRAYIDX13:%.*]] = getelementptr inbounds i32, i32* [[B]], i64 2
34 ; CHECK-NEXT: [[ARRAYIDX14:%.*]] = getelementptr inbounds i32, i32* [[B]], i64 3
35 ; CHECK-NEXT: [[TMP5:%.*]] = bitcast i32* [[B]] to <4 x i32>*
36 ; CHECK-NEXT: store <4 x i32> [[TMP4]], <4 x i32>* [[TMP5]], align 4
37 ; CHECK-NEXT: ret void
40 %arrayidx = getelementptr inbounds i32, i32* %A, i64 10
41 %0 = load i32, i32* %arrayidx, align 4
42 %1 = load i32, i32* %A, align 4
43 %mul = mul nsw i32 %0, %1
44 %arrayidx2 = getelementptr inbounds i32, i32* %A, i64 11
45 %2 = load i32, i32* %arrayidx2, align 4
46 %arrayidx3 = getelementptr inbounds i32, i32* %A, i64 1
47 %3 = load i32, i32* %arrayidx3, align 4
48 %mul4 = mul nsw i32 %2, %3
49 %arrayidx5 = getelementptr inbounds i32, i32* %A, i64 12
50 %4 = load i32, i32* %arrayidx5, align 4
51 %arrayidx6 = getelementptr inbounds i32, i32* %A, i64 3
52 %5 = load i32, i32* %arrayidx6, align 4
53 %mul7 = mul nsw i32 %4, %5
54 %arrayidx8 = getelementptr inbounds i32, i32* %A, i64 13
55 %6 = load i32, i32* %arrayidx8, align 4
56 %arrayidx9 = getelementptr inbounds i32, i32* %A, i64 2
57 %7 = load i32, i32* %arrayidx9, align 4
58 %mul10 = mul nsw i32 %6, %7
59 store i32 %mul, i32* %B, align 4
60 %arrayidx12 = getelementptr inbounds i32, i32* %B, i64 1
61 store i32 %mul4, i32* %arrayidx12, align 4
62 %arrayidx13 = getelementptr inbounds i32, i32* %B, i64 2
63 store i32 %mul7, i32* %arrayidx13, align 4
64 %arrayidx14 = getelementptr inbounds i32, i32* %B, i64 3
65 store i32 %mul10, i32* %arrayidx14, align 4
69 ;Reversing the operand of MUL
71 ; Function Attrs: norecurse nounwind uwtable
72 define void @jumble2(i32* noalias nocapture readonly %A, i32* noalias nocapture %B) {
73 ; CHECK-LABEL: @jumble2(
75 ; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, i32* [[A:%.*]], i64 10
76 ; CHECK-NEXT: [[ARRAYIDX2:%.*]] = getelementptr inbounds i32, i32* [[A]], i64 11
77 ; CHECK-NEXT: [[ARRAYIDX3:%.*]] = getelementptr inbounds i32, i32* [[A]], i64 1
78 ; CHECK-NEXT: [[ARRAYIDX5:%.*]] = getelementptr inbounds i32, i32* [[A]], i64 12
79 ; CHECK-NEXT: [[ARRAYIDX6:%.*]] = getelementptr inbounds i32, i32* [[A]], i64 3
80 ; CHECK-NEXT: [[ARRAYIDX8:%.*]] = getelementptr inbounds i32, i32* [[A]], i64 13
81 ; CHECK-NEXT: [[TMP0:%.*]] = bitcast i32* [[ARRAYIDX]] to <4 x i32>*
82 ; CHECK-NEXT: [[TMP1:%.*]] = load <4 x i32>, <4 x i32>* [[TMP0]], align 4
83 ; CHECK-NEXT: [[ARRAYIDX9:%.*]] = getelementptr inbounds i32, i32* [[A]], i64 2
84 ; CHECK-NEXT: [[TMP2:%.*]] = bitcast i32* [[A]] to <4 x i32>*
85 ; CHECK-NEXT: [[TMP3:%.*]] = load <4 x i32>, <4 x i32>* [[TMP2]], align 4
86 ; CHECK-NEXT: [[REORDER_SHUFFLE:%.*]] = shufflevector <4 x i32> [[TMP3]], <4 x i32> undef, <4 x i32> <i32 0, i32 1, i32 3, i32 2>
87 ; CHECK-NEXT: [[TMP4:%.*]] = mul nsw <4 x i32> [[REORDER_SHUFFLE]], [[TMP1]]
88 ; CHECK-NEXT: [[ARRAYIDX12:%.*]] = getelementptr inbounds i32, i32* [[B:%.*]], i64 1
89 ; CHECK-NEXT: [[ARRAYIDX13:%.*]] = getelementptr inbounds i32, i32* [[B]], i64 2
90 ; CHECK-NEXT: [[ARRAYIDX14:%.*]] = getelementptr inbounds i32, i32* [[B]], i64 3
91 ; CHECK-NEXT: [[TMP5:%.*]] = bitcast i32* [[B]] to <4 x i32>*
92 ; CHECK-NEXT: store <4 x i32> [[TMP4]], <4 x i32>* [[TMP5]], align 4
93 ; CHECK-NEXT: ret void
96 %arrayidx = getelementptr inbounds i32, i32* %A, i64 10
97 %0 = load i32, i32* %arrayidx, align 4
98 %1 = load i32, i32* %A, align 4
99 %mul = mul nsw i32 %1, %0
100 %arrayidx2 = getelementptr inbounds i32, i32* %A, i64 11
101 %2 = load i32, i32* %arrayidx2, align 4
102 %arrayidx3 = getelementptr inbounds i32, i32* %A, i64 1
103 %3 = load i32, i32* %arrayidx3, align 4
104 %mul4 = mul nsw i32 %3, %2
105 %arrayidx5 = getelementptr inbounds i32, i32* %A, i64 12
106 %4 = load i32, i32* %arrayidx5, align 4
107 %arrayidx6 = getelementptr inbounds i32, i32* %A, i64 3
108 %5 = load i32, i32* %arrayidx6, align 4
109 %mul7 = mul nsw i32 %5, %4
110 %arrayidx8 = getelementptr inbounds i32, i32* %A, i64 13
111 %6 = load i32, i32* %arrayidx8, align 4
112 %arrayidx9 = getelementptr inbounds i32, i32* %A, i64 2
113 %7 = load i32, i32* %arrayidx9, align 4
114 %mul10 = mul nsw i32 %7, %6
115 store i32 %mul, i32* %B, align 4
116 %arrayidx12 = getelementptr inbounds i32, i32* %B, i64 1
117 store i32 %mul4, i32* %arrayidx12, align 4
118 %arrayidx13 = getelementptr inbounds i32, i32* %B, i64 2
119 store i32 %mul7, i32* %arrayidx13, align 4
120 %arrayidx14 = getelementptr inbounds i32, i32* %B, i64 3
121 store i32 %mul10, i32* %arrayidx14, align 4