1 ; RUN: opt < %s -basicaa -slp-vectorizer -S | FileCheck %s
2 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
3 target triple = "x86_64-unknown-linux-gnu"
5 @b = common global [4 x i32] zeroinitializer, align 16
6 @c = common global [4 x i32] zeroinitializer, align 16
7 @d = common global [4 x i32] zeroinitializer, align 16
8 @e = common global [4 x i32] zeroinitializer, align 16
9 @a = common global [4 x i32] zeroinitializer, align 16
10 @fb = common global [4 x float] zeroinitializer, align 16
11 @fc = common global [4 x float] zeroinitializer, align 16
12 @fa = common global [4 x float] zeroinitializer, align 16
14 ; CHECK-LABEL: @addsub
15 ; CHECK: %5 = add nsw <4 x i32> %3, %4
16 ; CHECK: %6 = add nsw <4 x i32> %2, %5
17 ; CHECK: %7 = sub nsw <4 x i32> %2, %5
18 ; CHECK: %8 = shufflevector <4 x i32> %6, <4 x i32> %7, <4 x i32> <i32 0, i32 5, i32 2, i32 7>
20 ; Function Attrs: nounwind uwtable
21 define void @addsub() #0 {
23 %0 = load i32* getelementptr inbounds ([4 x i32]* @b, i32 0, i64 0), align 4
24 %1 = load i32* getelementptr inbounds ([4 x i32]* @c, i32 0, i64 0), align 4
25 %add = add nsw i32 %0, %1
26 %2 = load i32* getelementptr inbounds ([4 x i32]* @d, i32 0, i64 0), align 4
27 %3 = load i32* getelementptr inbounds ([4 x i32]* @e, i32 0, i64 0), align 4
28 %add1 = add nsw i32 %2, %3
29 %add2 = add nsw i32 %add, %add1
30 store i32 %add2, i32* getelementptr inbounds ([4 x i32]* @a, i32 0, i64 0), align 4
31 %4 = load i32* getelementptr inbounds ([4 x i32]* @b, i32 0, i64 1), align 4
32 %5 = load i32* getelementptr inbounds ([4 x i32]* @c, i32 0, i64 1), align 4
33 %add3 = add nsw i32 %4, %5
34 %6 = load i32* getelementptr inbounds ([4 x i32]* @d, i32 0, i64 1), align 4
35 %7 = load i32* getelementptr inbounds ([4 x i32]* @e, i32 0, i64 1), align 4
36 %add4 = add nsw i32 %6, %7
37 %sub = sub nsw i32 %add3, %add4
38 store i32 %sub, i32* getelementptr inbounds ([4 x i32]* @a, i32 0, i64 1), align 4
39 %8 = load i32* getelementptr inbounds ([4 x i32]* @b, i32 0, i64 2), align 4
40 %9 = load i32* getelementptr inbounds ([4 x i32]* @c, i32 0, i64 2), align 4
41 %add5 = add nsw i32 %8, %9
42 %10 = load i32* getelementptr inbounds ([4 x i32]* @d, i32 0, i64 2), align 4
43 %11 = load i32* getelementptr inbounds ([4 x i32]* @e, i32 0, i64 2), align 4
44 %add6 = add nsw i32 %10, %11
45 %add7 = add nsw i32 %add5, %add6
46 store i32 %add7, i32* getelementptr inbounds ([4 x i32]* @a, i32 0, i64 2), align 4
47 %12 = load i32* getelementptr inbounds ([4 x i32]* @b, i32 0, i64 3), align 4
48 %13 = load i32* getelementptr inbounds ([4 x i32]* @c, i32 0, i64 3), align 4
49 %add8 = add nsw i32 %12, %13
50 %14 = load i32* getelementptr inbounds ([4 x i32]* @d, i32 0, i64 3), align 4
51 %15 = load i32* getelementptr inbounds ([4 x i32]* @e, i32 0, i64 3), align 4
52 %add9 = add nsw i32 %14, %15
53 %sub10 = sub nsw i32 %add8, %add9
54 store i32 %sub10, i32* getelementptr inbounds ([4 x i32]* @a, i32 0, i64 3), align 4
58 ; CHECK-LABEL: @subadd
59 ; CHECK: %5 = add nsw <4 x i32> %3, %4
60 ; CHECK: %6 = sub nsw <4 x i32> %2, %5
61 ; CHECK: %7 = add nsw <4 x i32> %2, %5
62 ; CHECK: %8 = shufflevector <4 x i32> %6, <4 x i32> %7, <4 x i32> <i32 0, i32 5, i32 2, i32 7>
64 ; Function Attrs: nounwind uwtable
65 define void @subadd() #0 {
67 %0 = load i32* getelementptr inbounds ([4 x i32]* @b, i32 0, i64 0), align 4
68 %1 = load i32* getelementptr inbounds ([4 x i32]* @c, i32 0, i64 0), align 4
69 %add = add nsw i32 %0, %1
70 %2 = load i32* getelementptr inbounds ([4 x i32]* @d, i32 0, i64 0), align 4
71 %3 = load i32* getelementptr inbounds ([4 x i32]* @e, i32 0, i64 0), align 4
72 %add1 = add nsw i32 %2, %3
73 %sub = sub nsw i32 %add, %add1
74 store i32 %sub, i32* getelementptr inbounds ([4 x i32]* @a, i32 0, i64 0), align 4
75 %4 = load i32* getelementptr inbounds ([4 x i32]* @b, i32 0, i64 1), align 4
76 %5 = load i32* getelementptr inbounds ([4 x i32]* @c, i32 0, i64 1), align 4
77 %add2 = add nsw i32 %4, %5
78 %6 = load i32* getelementptr inbounds ([4 x i32]* @d, i32 0, i64 1), align 4
79 %7 = load i32* getelementptr inbounds ([4 x i32]* @e, i32 0, i64 1), align 4
80 %add3 = add nsw i32 %6, %7
81 %add4 = add nsw i32 %add2, %add3
82 store i32 %add4, i32* getelementptr inbounds ([4 x i32]* @a, i32 0, i64 1), align 4
83 %8 = load i32* getelementptr inbounds ([4 x i32]* @b, i32 0, i64 2), align 4
84 %9 = load i32* getelementptr inbounds ([4 x i32]* @c, i32 0, i64 2), align 4
85 %add5 = add nsw i32 %8, %9
86 %10 = load i32* getelementptr inbounds ([4 x i32]* @d, i32 0, i64 2), align 4
87 %11 = load i32* getelementptr inbounds ([4 x i32]* @e, i32 0, i64 2), align 4
88 %add6 = add nsw i32 %10, %11
89 %sub7 = sub nsw i32 %add5, %add6
90 store i32 %sub7, i32* getelementptr inbounds ([4 x i32]* @a, i32 0, i64 2), align 4
91 %12 = load i32* getelementptr inbounds ([4 x i32]* @b, i32 0, i64 3), align 4
92 %13 = load i32* getelementptr inbounds ([4 x i32]* @c, i32 0, i64 3), align 4
93 %add8 = add nsw i32 %12, %13
94 %14 = load i32* getelementptr inbounds ([4 x i32]* @d, i32 0, i64 3), align 4
95 %15 = load i32* getelementptr inbounds ([4 x i32]* @e, i32 0, i64 3), align 4
96 %add9 = add nsw i32 %14, %15
97 %add10 = add nsw i32 %add8, %add9
98 store i32 %add10, i32* getelementptr inbounds ([4 x i32]* @a, i32 0, i64 3), align 4
102 ; CHECK-LABEL: @faddfsub
103 ; CHECK: %2 = fadd <4 x float> %0, %1
104 ; CHECK: %3 = fsub <4 x float> %0, %1
105 ; CHECK: %4 = shufflevector <4 x float> %2, <4 x float> %3, <4 x i32> <i32 0, i32 5, i32 2, i32 7>
106 ; Function Attrs: nounwind uwtable
107 define void @faddfsub() #0 {
109 %0 = load float* getelementptr inbounds ([4 x float]* @fb, i32 0, i64 0), align 4
110 %1 = load float* getelementptr inbounds ([4 x float]* @fc, i32 0, i64 0), align 4
111 %add = fadd float %0, %1
112 store float %add, float* getelementptr inbounds ([4 x float]* @fa, i32 0, i64 0), align 4
113 %2 = load float* getelementptr inbounds ([4 x float]* @fb, i32 0, i64 1), align 4
114 %3 = load float* getelementptr inbounds ([4 x float]* @fc, i32 0, i64 1), align 4
115 %sub = fsub float %2, %3
116 store float %sub, float* getelementptr inbounds ([4 x float]* @fa, i32 0, i64 1), align 4
117 %4 = load float* getelementptr inbounds ([4 x float]* @fb, i32 0, i64 2), align 4
118 %5 = load float* getelementptr inbounds ([4 x float]* @fc, i32 0, i64 2), align 4
119 %add1 = fadd float %4, %5
120 store float %add1, float* getelementptr inbounds ([4 x float]* @fa, i32 0, i64 2), align 4
121 %6 = load float* getelementptr inbounds ([4 x float]* @fb, i32 0, i64 3), align 4
122 %7 = load float* getelementptr inbounds ([4 x float]* @fc, i32 0, i64 3), align 4
123 %sub2 = fsub float %6, %7
124 store float %sub2, float* getelementptr inbounds ([4 x float]* @fa, i32 0, i64 3), align 4
128 ; CHECK-LABEL: @fsubfadd
129 ; CHECK: %2 = fsub <4 x float> %0, %1
130 ; CHECK: %3 = fadd <4 x float> %0, %1
131 ; CHECK: %4 = shufflevector <4 x float> %2, <4 x float> %3, <4 x i32> <i32 0, i32 5, i32 2, i32 7>
132 ; Function Attrs: nounwind uwtable
133 define void @fsubfadd() #0 {
135 %0 = load float* getelementptr inbounds ([4 x float]* @fb, i32 0, i64 0), align 4
136 %1 = load float* getelementptr inbounds ([4 x float]* @fc, i32 0, i64 0), align 4
137 %sub = fsub float %0, %1
138 store float %sub, float* getelementptr inbounds ([4 x float]* @fa, i32 0, i64 0), align 4
139 %2 = load float* getelementptr inbounds ([4 x float]* @fb, i32 0, i64 1), align 4
140 %3 = load float* getelementptr inbounds ([4 x float]* @fc, i32 0, i64 1), align 4
141 %add = fadd float %2, %3
142 store float %add, float* getelementptr inbounds ([4 x float]* @fa, i32 0, i64 1), align 4
143 %4 = load float* getelementptr inbounds ([4 x float]* @fb, i32 0, i64 2), align 4
144 %5 = load float* getelementptr inbounds ([4 x float]* @fc, i32 0, i64 2), align 4
145 %sub1 = fsub float %4, %5
146 store float %sub1, float* getelementptr inbounds ([4 x float]* @fa, i32 0, i64 2), align 4
147 %6 = load float* getelementptr inbounds ([4 x float]* @fb, i32 0, i64 3), align 4
148 %7 = load float* getelementptr inbounds ([4 x float]* @fc, i32 0, i64 3), align 4
149 %add2 = fadd float %6, %7
150 store float %add2, float* getelementptr inbounds ([4 x float]* @fa, i32 0, i64 3), align 4
154 ; CHECK-LABEL: @No_faddfsub
155 ; CHECK-NOT: fadd <4 x float>
156 ; CHECK-NOT: fsub <4 x float>
157 ; CHECK-NOT: shufflevector
158 ; Function Attrs: nounwind uwtable
159 define void @No_faddfsub() #0 {
161 %0 = load float* getelementptr inbounds ([4 x float]* @fb, i32 0, i64 0), align 4
162 %1 = load float* getelementptr inbounds ([4 x float]* @fc, i32 0, i64 0), align 4
163 %add = fadd float %0, %1
164 store float %add, float* getelementptr inbounds ([4 x float]* @fa, i32 0, i64 0), align 4
165 %2 = load float* getelementptr inbounds ([4 x float]* @fb, i32 0, i64 1), align 4
166 %3 = load float* getelementptr inbounds ([4 x float]* @fc, i32 0, i64 1), align 4
167 %add1 = fadd float %2, %3
168 store float %add1, float* getelementptr inbounds ([4 x float]* @fa, i32 0, i64 1), align 4
169 %4 = load float* getelementptr inbounds ([4 x float]* @fb, i32 0, i64 2), align 4
170 %5 = load float* getelementptr inbounds ([4 x float]* @fc, i32 0, i64 2), align 4
171 %add2 = fadd float %4, %5
172 store float %add2, float* getelementptr inbounds ([4 x float]* @fa, i32 0, i64 2), align 4
173 %6 = load float* getelementptr inbounds ([4 x float]* @fb, i32 0, i64 3), align 4
174 %7 = load float* getelementptr inbounds ([4 x float]* @fc, i32 0, i64 3), align 4
175 %sub = fsub float %6, %7
176 store float %sub, float* getelementptr inbounds ([4 x float]* @fa, i32 0, i64 3), align 4
180 attributes #0 = { nounwind }