1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=slp-vectorizer -slp-vectorize-hor -slp-vectorize-hor-store -S < %s -mtriple=x86_64-unknown-linux-gnu | FileCheck %s
3 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128-ni:1"
5 define void @mainTest(ptr %ptr) #0 {
6 ; CHECK-LABEL: @mainTest(
8 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq ptr [[PTR:%.*]], null
9 ; CHECK-NEXT: br i1 [[CMP]], label [[LOOP:%.*]], label [[BAIL_OUT:%.*]]
11 ; CHECK-NEXT: [[DUMMY_PHI:%.*]] = phi i32 [ 1, [[ENTRY:%.*]] ], [ [[OP_RDX3:%.*]], [[LOOP]] ]
12 ; CHECK-NEXT: [[TMP1:%.*]] = load <4 x i32>, ptr [[PTR]], align 4
13 ; CHECK-NEXT: [[TMP2:%.*]] = extractelement <4 x i32> [[TMP1]], i32 3
14 ; CHECK-NEXT: [[TMP3:%.*]] = extractelement <4 x i32> [[TMP1]], i32 2
15 ; CHECK-NEXT: [[TMP4:%.*]] = extractelement <4 x i32> [[TMP1]], i32 1
16 ; CHECK-NEXT: [[TMP5:%.*]] = mul <4 x i32> [[TMP1]], [[TMP1]]
17 ; CHECK-NEXT: [[TMP6:%.*]] = sext i32 [[TMP3]] to i64
18 ; CHECK-NEXT: [[TMP7:%.*]] = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> [[TMP5]])
19 ; CHECK-NEXT: [[OP_RDX:%.*]] = add i32 [[TMP7]], [[TMP4]]
20 ; CHECK-NEXT: [[OP_RDX1:%.*]] = add i32 [[TMP3]], [[TMP2]]
21 ; CHECK-NEXT: [[OP_RDX2:%.*]] = add i32 [[OP_RDX]], [[OP_RDX1]]
22 ; CHECK-NEXT: [[OP_RDX3]] = add i32 [[OP_RDX2]], 1
23 ; CHECK-NEXT: br label [[LOOP]]
25 ; CHECK-NEXT: ret void
28 %cmp = icmp eq ptr %ptr, null
29 br i1 %cmp, label %loop, label %bail_out
32 %dummy_phi = phi i32 [ 1, %entry ], [ %18, %loop ]
33 %0 = load i32, ptr %ptr , align 4
36 %3 = getelementptr inbounds i32, ptr %ptr, i64 1
37 %4 = load i32, ptr %3 , align 4
41 %8 = getelementptr inbounds i32, ptr %ptr, i64 2
42 %9 = load i32, ptr %8 , align 4
45 %12 = add i32 %11, %10
46 %13 = sext i32 %9 to i64
47 %14 = getelementptr inbounds i32, ptr %ptr, i64 3
48 %15 = load i32, ptr %14 , align 4
49 %16 = mul i32 %15, %15
50 %17 = add i32 %12, %15
51 %18 = add i32 %17, %16
58 attributes #0 = { "target-cpu"="westmere" }