1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 3
2 ; RUN: opt -passes=slp-vectorizer -slp-vectorize-hor -slp-vectorize-hor-store -S < %s -mtriple=x86_64-unknown-linux | FileCheck %s
4 @arr_i32 = global [32 x i32] zeroinitializer, align 16
5 define void @test(ptr noalias %pl, ptr noalias %res, ptr noalias %p2) {
6 ; CHECK-LABEL: define void @test(
7 ; CHECK-SAME: ptr noalias [[PL:%.*]], ptr noalias [[RES:%.*]], ptr noalias [[P2:%.*]]) {
9 ; CHECK-NEXT: [[TMP0:%.*]] = load <4 x i32>, ptr @arr_i32, align 16
10 ; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> [[TMP0]])
11 ; CHECK-NEXT: store i32 [[TMP1]], ptr [[P2]], align 16
12 ; CHECK-NEXT: store i32 [[TMP1]], ptr [[RES]], align 16
13 ; CHECK-NEXT: ret void
16 %0 = load i32, ptr @arr_i32, align 16
17 %1 = load i32, ptr getelementptr inbounds ([32 x i32], ptr @arr_i32, i64 0, i64 1), align 4
18 %add = add nsw i32 %1, %0
19 %2 = load i32, ptr getelementptr inbounds ([32 x i32], ptr @arr_i32, i64 0, i64 2), align 8
20 %add.1 = add nsw i32 %2, %add
21 %3 = load i32, ptr getelementptr inbounds ([32 x i32], ptr @arr_i32, i64 0, i64 3), align 4
22 %add.2 = add nsw i32 %3, %add.1
23 store i32 %add.2, ptr %p2, align 16
24 store i32 %add.2, ptr %res, align 16