1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -basic-aa -slp-vectorizer -S -mtriple=x86_64-unknown-linux-gnu -mattr=+avx | FileCheck %s
3 ; RUN: opt < %s -basic-aa -slp-vectorizer -S -mtriple=x86_64-unknown-linux-gnu -mattr=+avx2 | FileCheck %s
5 define void @powof2div_uniform(i32* noalias nocapture %a, i32* noalias nocapture readonly %b, i32* noalias nocapture readonly %c){
6 ; CHECK-LABEL: @powof2div_uniform(
8 ; CHECK-NEXT: [[ARRAYIDX3:%.*]] = getelementptr inbounds i32, i32* [[B:%.*]], i64 1
9 ; CHECK-NEXT: [[ARRAYIDX4:%.*]] = getelementptr inbounds i32, i32* [[C:%.*]], i64 1
10 ; CHECK-NEXT: [[ARRAYIDX7:%.*]] = getelementptr inbounds i32, i32* [[A:%.*]], i64 1
11 ; CHECK-NEXT: [[ARRAYIDX8:%.*]] = getelementptr inbounds i32, i32* [[B]], i64 2
12 ; CHECK-NEXT: [[ARRAYIDX9:%.*]] = getelementptr inbounds i32, i32* [[C]], i64 2
13 ; CHECK-NEXT: [[ARRAYIDX12:%.*]] = getelementptr inbounds i32, i32* [[A]], i64 2
14 ; CHECK-NEXT: [[ARRAYIDX13:%.*]] = getelementptr inbounds i32, i32* [[B]], i64 3
15 ; CHECK-NEXT: [[TMP0:%.*]] = bitcast i32* [[B]] to <4 x i32>*
16 ; CHECK-NEXT: [[TMP1:%.*]] = load <4 x i32>, <4 x i32>* [[TMP0]], align 4
17 ; CHECK-NEXT: [[ARRAYIDX14:%.*]] = getelementptr inbounds i32, i32* [[C]], i64 3
18 ; CHECK-NEXT: [[TMP2:%.*]] = bitcast i32* [[C]] to <4 x i32>*
19 ; CHECK-NEXT: [[TMP3:%.*]] = load <4 x i32>, <4 x i32>* [[TMP2]], align 4
20 ; CHECK-NEXT: [[TMP4:%.*]] = add nsw <4 x i32> [[TMP3]], [[TMP1]]
21 ; CHECK-NEXT: [[TMP5:%.*]] = sdiv <4 x i32> [[TMP4]], <i32 2, i32 2, i32 2, i32 2>
22 ; CHECK-NEXT: [[ARRAYIDX17:%.*]] = getelementptr inbounds i32, i32* [[A]], i64 3
23 ; CHECK-NEXT: [[TMP6:%.*]] = bitcast i32* [[A]] to <4 x i32>*
24 ; CHECK-NEXT: store <4 x i32> [[TMP5]], <4 x i32>* [[TMP6]], align 4
25 ; CHECK-NEXT: ret void
28 %0 = load i32, i32* %b, align 4
29 %1 = load i32, i32* %c, align 4
30 %add = add nsw i32 %1, %0
31 %div = sdiv i32 %add, 2
32 store i32 %div, i32* %a, align 4
33 %arrayidx3 = getelementptr inbounds i32, i32* %b, i64 1
34 %2 = load i32, i32* %arrayidx3, align 4
35 %arrayidx4 = getelementptr inbounds i32, i32* %c, i64 1
36 %3 = load i32, i32* %arrayidx4, align 4
37 %add5 = add nsw i32 %3, %2
38 %div6 = sdiv i32 %add5, 2
39 %arrayidx7 = getelementptr inbounds i32, i32* %a, i64 1
40 store i32 %div6, i32* %arrayidx7, align 4
41 %arrayidx8 = getelementptr inbounds i32, i32* %b, i64 2
42 %4 = load i32, i32* %arrayidx8, align 4
43 %arrayidx9 = getelementptr inbounds i32, i32* %c, i64 2
44 %5 = load i32, i32* %arrayidx9, align 4
45 %add10 = add nsw i32 %5, %4
46 %div11 = sdiv i32 %add10, 2
47 %arrayidx12 = getelementptr inbounds i32, i32* %a, i64 2
48 store i32 %div11, i32* %arrayidx12, align 4
49 %arrayidx13 = getelementptr inbounds i32, i32* %b, i64 3
50 %6 = load i32, i32* %arrayidx13, align 4
51 %arrayidx14 = getelementptr inbounds i32, i32* %c, i64 3
52 %7 = load i32, i32* %arrayidx14, align 4
53 %add15 = add nsw i32 %7, %6
54 %div16 = sdiv i32 %add15, 2
55 %arrayidx17 = getelementptr inbounds i32, i32* %a, i64 3
56 store i32 %div16, i32* %arrayidx17, align 4
60 define void @powof2div_nonuniform(i32* noalias nocapture %a, i32* noalias nocapture readonly %b, i32* noalias nocapture readonly %c){
61 ; CHECK-LABEL: @powof2div_nonuniform(
63 ; CHECK-NEXT: [[ARRAYIDX3:%.*]] = getelementptr inbounds i32, i32* [[B:%.*]], i64 1
64 ; CHECK-NEXT: [[ARRAYIDX4:%.*]] = getelementptr inbounds i32, i32* [[C:%.*]], i64 1
65 ; CHECK-NEXT: [[ARRAYIDX7:%.*]] = getelementptr inbounds i32, i32* [[A:%.*]], i64 1
66 ; CHECK-NEXT: [[ARRAYIDX8:%.*]] = getelementptr inbounds i32, i32* [[B]], i64 2
67 ; CHECK-NEXT: [[ARRAYIDX9:%.*]] = getelementptr inbounds i32, i32* [[C]], i64 2
68 ; CHECK-NEXT: [[ARRAYIDX12:%.*]] = getelementptr inbounds i32, i32* [[A]], i64 2
69 ; CHECK-NEXT: [[ARRAYIDX13:%.*]] = getelementptr inbounds i32, i32* [[B]], i64 3
70 ; CHECK-NEXT: [[TMP0:%.*]] = bitcast i32* [[B]] to <4 x i32>*
71 ; CHECK-NEXT: [[TMP1:%.*]] = load <4 x i32>, <4 x i32>* [[TMP0]], align 4
72 ; CHECK-NEXT: [[ARRAYIDX14:%.*]] = getelementptr inbounds i32, i32* [[C]], i64 3
73 ; CHECK-NEXT: [[TMP2:%.*]] = bitcast i32* [[C]] to <4 x i32>*
74 ; CHECK-NEXT: [[TMP3:%.*]] = load <4 x i32>, <4 x i32>* [[TMP2]], align 4
75 ; CHECK-NEXT: [[TMP4:%.*]] = add nsw <4 x i32> [[TMP3]], [[TMP1]]
76 ; CHECK-NEXT: [[TMP5:%.*]] = sdiv <4 x i32> [[TMP4]], <i32 2, i32 4, i32 8, i32 16>
77 ; CHECK-NEXT: [[ARRAYIDX17:%.*]] = getelementptr inbounds i32, i32* [[A]], i64 3
78 ; CHECK-NEXT: [[TMP6:%.*]] = bitcast i32* [[A]] to <4 x i32>*
79 ; CHECK-NEXT: store <4 x i32> [[TMP5]], <4 x i32>* [[TMP6]], align 4
80 ; CHECK-NEXT: ret void
83 %0 = load i32, i32* %b, align 4
84 %1 = load i32, i32* %c, align 4
85 %add = add nsw i32 %1, %0
86 %div = sdiv i32 %add, 2
87 store i32 %div, i32* %a, align 4
88 %arrayidx3 = getelementptr inbounds i32, i32* %b, i64 1
89 %2 = load i32, i32* %arrayidx3, align 4
90 %arrayidx4 = getelementptr inbounds i32, i32* %c, i64 1
91 %3 = load i32, i32* %arrayidx4, align 4
92 %add5 = add nsw i32 %3, %2
93 %div6 = sdiv i32 %add5, 4
94 %arrayidx7 = getelementptr inbounds i32, i32* %a, i64 1
95 store i32 %div6, i32* %arrayidx7, align 4
96 %arrayidx8 = getelementptr inbounds i32, i32* %b, i64 2
97 %4 = load i32, i32* %arrayidx8, align 4
98 %arrayidx9 = getelementptr inbounds i32, i32* %c, i64 2
99 %5 = load i32, i32* %arrayidx9, align 4
100 %add10 = add nsw i32 %5, %4
101 %div11 = sdiv i32 %add10, 8
102 %arrayidx12 = getelementptr inbounds i32, i32* %a, i64 2
103 store i32 %div11, i32* %arrayidx12, align 4
104 %arrayidx13 = getelementptr inbounds i32, i32* %b, i64 3
105 %6 = load i32, i32* %arrayidx13, align 4
106 %arrayidx14 = getelementptr inbounds i32, i32* %c, i64 3
107 %7 = load i32, i32* %arrayidx14, align 4
108 %add15 = add nsw i32 %7, %6
109 %div16 = sdiv i32 %add15, 16
110 %arrayidx17 = getelementptr inbounds i32, i32* %a, i64 3
111 store i32 %div16, i32* %arrayidx17, align 4