1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -S -mtriple=x86_64-unknown -mattr=+avx -passes=slp-vectorizer | FileCheck %s
4 ;void jumble (int * restrict A, int * restrict B) {
5 ; int tmp0 = Aptr A[0];
6 ; int tmp1 = Aptr A[1];
7 ; int tmp2 = Aptr A[3];
8 ; int tmp3 = Aptr A[2];
15 ; Function Attrs: norecurse nounwind uwtable
16 define void @jumble1(ptr noalias nocapture readonly %A, ptr noalias nocapture %B) {
17 ; CHECK-LABEL: @jumble1(
19 ; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, ptr [[A:%.*]], i64 10
20 ; CHECK-NEXT: [[TMP1:%.*]] = load <4 x i32>, ptr [[ARRAYIDX]], align 4
21 ; CHECK-NEXT: [[TMP3:%.*]] = load <4 x i32>, ptr [[A]], align 4
22 ; CHECK-NEXT: [[SHUFFLE:%.*]] = shufflevector <4 x i32> [[TMP3]], <4 x i32> poison, <4 x i32> <i32 0, i32 1, i32 3, i32 2>
23 ; CHECK-NEXT: [[TMP4:%.*]] = mul nsw <4 x i32> [[TMP1]], [[SHUFFLE]]
24 ; CHECK-NEXT: store <4 x i32> [[TMP4]], ptr [[B:%.*]], align 4
25 ; CHECK-NEXT: ret void
28 %arrayidx = getelementptr inbounds i32, ptr %A, i64 10
29 %0 = load i32, ptr %arrayidx, align 4
30 %1 = load i32, ptr %A, align 4
31 %mul = mul nsw i32 %0, %1
32 %arrayidx2 = getelementptr inbounds i32, ptr %A, i64 11
33 %2 = load i32, ptr %arrayidx2, align 4
34 %arrayidx3 = getelementptr inbounds i32, ptr %A, i64 1
35 %3 = load i32, ptr %arrayidx3, align 4
36 %mul4 = mul nsw i32 %2, %3
37 %arrayidx5 = getelementptr inbounds i32, ptr %A, i64 12
38 %4 = load i32, ptr %arrayidx5, align 4
39 %arrayidx6 = getelementptr inbounds i32, ptr %A, i64 3
40 %5 = load i32, ptr %arrayidx6, align 4
41 %mul7 = mul nsw i32 %4, %5
42 %arrayidx8 = getelementptr inbounds i32, ptr %A, i64 13
43 %6 = load i32, ptr %arrayidx8, align 4
44 %arrayidx9 = getelementptr inbounds i32, ptr %A, i64 2
45 %7 = load i32, ptr %arrayidx9, align 4
46 %mul10 = mul nsw i32 %6, %7
47 store i32 %mul, ptr %B, align 4
48 %arrayidx12 = getelementptr inbounds i32, ptr %B, i64 1
49 store i32 %mul4, ptr %arrayidx12, align 4
50 %arrayidx13 = getelementptr inbounds i32, ptr %B, i64 2
51 store i32 %mul7, ptr %arrayidx13, align 4
52 %arrayidx14 = getelementptr inbounds i32, ptr %B, i64 3
53 store i32 %mul10, ptr %arrayidx14, align 4
57 ;Reversing the operand of MUL
59 ; Function Attrs: norecurse nounwind uwtable
60 define void @jumble2(ptr noalias nocapture readonly %A, ptr noalias nocapture %B) {
61 ; CHECK-LABEL: @jumble2(
63 ; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, ptr [[A:%.*]], i64 10
64 ; CHECK-NEXT: [[TMP1:%.*]] = load <4 x i32>, ptr [[ARRAYIDX]], align 4
65 ; CHECK-NEXT: [[TMP3:%.*]] = load <4 x i32>, ptr [[A]], align 4
66 ; CHECK-NEXT: [[SHUFFLE:%.*]] = shufflevector <4 x i32> [[TMP3]], <4 x i32> poison, <4 x i32> <i32 0, i32 1, i32 3, i32 2>
67 ; CHECK-NEXT: [[TMP4:%.*]] = mul nsw <4 x i32> [[SHUFFLE]], [[TMP1]]
68 ; CHECK-NEXT: store <4 x i32> [[TMP4]], ptr [[B:%.*]], align 4
69 ; CHECK-NEXT: ret void
72 %arrayidx = getelementptr inbounds i32, ptr %A, i64 10
73 %0 = load i32, ptr %arrayidx, align 4
74 %1 = load i32, ptr %A, align 4
75 %mul = mul nsw i32 %1, %0
76 %arrayidx2 = getelementptr inbounds i32, ptr %A, i64 11
77 %2 = load i32, ptr %arrayidx2, align 4
78 %arrayidx3 = getelementptr inbounds i32, ptr %A, i64 1
79 %3 = load i32, ptr %arrayidx3, align 4
80 %mul4 = mul nsw i32 %3, %2
81 %arrayidx5 = getelementptr inbounds i32, ptr %A, i64 12
82 %4 = load i32, ptr %arrayidx5, align 4
83 %arrayidx6 = getelementptr inbounds i32, ptr %A, i64 3
84 %5 = load i32, ptr %arrayidx6, align 4
85 %mul7 = mul nsw i32 %5, %4
86 %arrayidx8 = getelementptr inbounds i32, ptr %A, i64 13
87 %6 = load i32, ptr %arrayidx8, align 4
88 %arrayidx9 = getelementptr inbounds i32, ptr %A, i64 2
89 %7 = load i32, ptr %arrayidx9, align 4
90 %mul10 = mul nsw i32 %7, %6
91 store i32 %mul, ptr %B, align 4
92 %arrayidx12 = getelementptr inbounds i32, ptr %B, i64 1
93 store i32 %mul4, ptr %arrayidx12, align 4
94 %arrayidx13 = getelementptr inbounds i32, ptr %B, i64 2
95 store i32 %mul7, ptr %arrayidx13, align 4
96 %arrayidx14 = getelementptr inbounds i32, ptr %B, i64 3
97 store i32 %mul10, ptr %arrayidx14, align 4