1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=slp-vectorizer -S | FileCheck %s
4 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
5 target triple = "x86_64-unknown-linux-gnu"
7 @b = common global [4 x i32] zeroinitializer, align 16
8 @c = common global [4 x i32] zeroinitializer, align 16
9 @d = common global [4 x i32] zeroinitializer, align 16
10 @e = common global [4 x i32] zeroinitializer, align 16
11 @a = common global [4 x i32] zeroinitializer, align 16
12 @fb = common global [4 x float] zeroinitializer, align 16
13 @fc = common global [4 x float] zeroinitializer, align 16
14 @fa = common global [4 x float] zeroinitializer, align 16
15 @fd = common global [4 x float] zeroinitializer, align 16
17 define void @addsub() {
18 ; CHECK-LABEL: @addsub(
20 ; CHECK-NEXT: br label [[BB1:%.*]]
22 ; CHECK-NEXT: [[TMP0:%.*]] = load <4 x i32>, ptr @b, align 16
23 ; CHECK-NEXT: [[TMP1:%.*]] = load <4 x i32>, ptr @c, align 16
24 ; CHECK-NEXT: [[TMP2:%.*]] = add nsw <4 x i32> [[TMP0]], [[TMP1]]
25 ; CHECK-NEXT: [[TMP3:%.*]] = load <4 x i32>, ptr @d, align 16
26 ; CHECK-NEXT: [[TMP4:%.*]] = load <4 x i32>, ptr @e, align 16
27 ; CHECK-NEXT: [[TMP5:%.*]] = add nsw <4 x i32> [[TMP3]], [[TMP4]]
28 ; CHECK-NEXT: [[TMP6:%.*]] = add nsw <4 x i32> [[TMP2]], [[TMP5]]
29 ; CHECK-NEXT: [[TMP7:%.*]] = sub nsw <4 x i32> [[TMP2]], [[TMP5]]
30 ; CHECK-NEXT: [[TMP8:%.*]] = shufflevector <4 x i32> [[TMP6]], <4 x i32> [[TMP7]], <4 x i32> <i32 0, i32 5, i32 2, i32 7>
31 ; CHECK-NEXT: store <4 x i32> [[TMP8]], ptr @a, align 16
32 ; CHECK-NEXT: ret void
38 %0 = load i32, ptr @b, align 16
39 %1 = load i32, ptr @c, align 16
40 %add = add nsw i32 %0, %1
41 %2 = load i32, ptr @d, align 16
42 %3 = load i32, ptr @e, align 16
43 %add1 = add nsw i32 %2, %3
44 %add2 = add nsw i32 %add, %add1
45 store i32 %add2, ptr @a, align 16
46 %4 = load i32, ptr getelementptr inbounds ([4 x i32], ptr @b, i64 0, i64 1), align 4
47 %5 = load i32, ptr getelementptr inbounds ([4 x i32], ptr @c, i64 0, i64 1), align 4
48 %add3 = add nsw i32 %4, %5
49 %6 = load i32, ptr getelementptr inbounds ([4 x i32], ptr @d, i64 0, i64 1), align 4
50 %7 = load i32, ptr getelementptr inbounds ([4 x i32], ptr @e, i64 0, i64 1), align 4
51 %add4 = add nsw i32 %6, %7
52 %sub = sub nsw i32 %add3, %add4
53 store i32 %sub, ptr getelementptr inbounds ([4 x i32], ptr @a, i64 0, i64 1), align 4
54 %8 = load i32, ptr getelementptr inbounds ([4 x i32], ptr @b, i64 0, i64 2), align 8
55 %9 = load i32, ptr getelementptr inbounds ([4 x i32], ptr @c, i64 0, i64 2), align 8
56 %add5 = add nsw i32 %8, %9
57 %10 = load i32, ptr getelementptr inbounds ([4 x i32], ptr @d, i64 0, i64 2), align 8
58 %11 = load i32, ptr getelementptr inbounds ([4 x i32], ptr @e, i64 0, i64 2), align 8
59 %add6 = add nsw i32 %10, %11
60 %add7 = add nsw i32 %add5, %add6
61 store i32 %add7, ptr getelementptr inbounds ([4 x i32], ptr @a, i64 0, i64 2), align 8
62 %12 = load i32, ptr getelementptr inbounds ([4 x i32], ptr @b, i64 0, i64 3), align 4
63 %13 = load i32, ptr getelementptr inbounds ([4 x i32], ptr @c, i64 0, i64 3), align 4
64 %add8 = add nsw i32 %12, %13
65 %14 = load i32, ptr getelementptr inbounds ([4 x i32], ptr @d, i64 0, i64 3), align 4
66 %15 = load i32, ptr getelementptr inbounds ([4 x i32], ptr @e, i64 0, i64 3), align 4
67 %add9 = add nsw i32 %14, %15
68 %sub10 = sub nsw i32 %add8, %add9
69 store i32 %sub10, ptr getelementptr inbounds ([4 x i32], ptr @a, i64 0, i64 3), align 4