1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 2; RUN: opt -slp-vectorizer -slp-vectorize-hor -slp-vectorize-hor-store -S < %s -mtriple=x86_64-unknown-linux-gnu | FileCheck %s 3target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128-ni:1" 4 5define void @mainTest(i32* %ptr) #0 { 6; CHECK-LABEL: @mainTest( 7; CHECK-NEXT: entry: 8; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32* [[PTR:%.*]], null 9; CHECK-NEXT: br i1 [[CMP]], label [[LOOP:%.*]], label [[BAIL_OUT:%.*]] 10; CHECK: loop: 11; CHECK-NEXT: [[DUMMY_PHI:%.*]] = phi i32 [ 1, [[ENTRY:%.*]] ], [ [[OP_EXTRA3:%.*]], [[LOOP]] ] 12; CHECK-NEXT: [[TMP0:%.*]] = getelementptr inbounds i32, i32* [[PTR]], i64 1 13; CHECK-NEXT: [[TMP1:%.*]] = getelementptr inbounds i32, i32* [[PTR]], i64 2 14; CHECK-NEXT: [[TMP2:%.*]] = getelementptr inbounds i32, i32* [[PTR]], i64 3 15; CHECK-NEXT: [[TMP3:%.*]] = bitcast i32* [[PTR]] to <4 x i32>* 16; CHECK-NEXT: [[TMP4:%.*]] = load <4 x i32>, <4 x i32>* [[TMP3]], align 4 17; CHECK-NEXT: [[TMP5:%.*]] = extractelement <4 x i32> [[TMP4]], i32 3 18; CHECK-NEXT: [[TMP6:%.*]] = extractelement <4 x i32> [[TMP4]], i32 2 19; CHECK-NEXT: [[TMP7:%.*]] = extractelement <4 x i32> [[TMP4]], i32 1 20; CHECK-NEXT: [[TMP8:%.*]] = mul <4 x i32> [[TMP4]], [[TMP4]] 21; CHECK-NEXT: [[TMP9:%.*]] = sext i32 [[TMP6]] to i64 22; CHECK-NEXT: [[TMP10:%.*]] = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> [[TMP8]]) 23; CHECK-NEXT: [[OP_EXTRA:%.*]] = add i32 [[TMP10]], 1 24; CHECK-NEXT: [[OP_EXTRA1:%.*]] = add i32 [[OP_EXTRA]], [[TMP7]] 25; CHECK-NEXT: [[OP_EXTRA2:%.*]] = add i32 [[OP_EXTRA1]], [[TMP6]] 26; CHECK-NEXT: [[OP_EXTRA3]] = add i32 [[OP_EXTRA2]], [[TMP5]] 27; CHECK-NEXT: br label [[LOOP]] 28; CHECK: bail_out: 29; CHECK-NEXT: ret void 30; 31entry: 32 %cmp = icmp eq i32* %ptr, null 33 br i1 %cmp, label %loop, label %bail_out 34 35loop: 36 %dummy_phi = phi i32 [ 1, %entry ], [ %18, %loop ] 37 %0 = load i32, i32 * %ptr , align 4 38 %1 = mul i32 %0, %0 39 %2 = add i32 1, %1 40 %3 = getelementptr inbounds i32, i32 * %ptr, i64 1 41 %4 = load i32, i32 * %3 , align 4 42 %5 = mul i32 %4, %4 43 %6 = add i32 %2, %4 44 %7 = add i32 %6, %5 45 %8 = getelementptr inbounds i32, i32 *%ptr, i64 2 46 %9 = load i32, i32 * %8 , align 4 47 %10 = mul i32 %9, %9 48 %11 = add i32 %7, %9 49 %12 = add i32 %11, %10 50 %13 = sext i32 %9 to i64 51 %14 = getelementptr inbounds i32, i32 *%ptr, i64 3 52 %15 = load i32, i32 * %14 , align 4 53 %16 = mul i32 %15, %15 54 %17 = add i32 %12, %15 55 %18 = add i32 %17, %16 56 br label %loop 57 58bail_out: 59 ret void 60} 61 62attributes #0 = { "target-cpu"="westmere" } 63 64