1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt < %s -vector-library=MASSV -force-vector-interleave=1 \
3; RUN:   -vectorizer-maximize-bandwidth -passes='default<O2>,inject-tli-mappings,loop-vectorize' \
4; RUN:   -mtriple=powerpc64le-unknown-linux -S -mcpu=pwr9 2>&1 | FileCheck %s
5
6define dso_local double @test(float* %Arr) {
7; CHECK-LABEL: @test(
8; CHECK-NEXT:  entry:
9; CHECK-NEXT:    br label [[VECTOR_BODY:%.*]]
10; CHECK:       vector.body:
11; CHECK-NEXT:    [[INDEX:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ]
12; CHECK-NEXT:    [[VEC_PHI:%.*]] = phi <2 x double> [ zeroinitializer, [[ENTRY]] ], [ [[TMP5:%.*]], [[VECTOR_BODY]] ]
13; CHECK-NEXT:    [[TMP0:%.*]] = zext i32 [[INDEX]] to i64
14; CHECK-NEXT:    [[TMP1:%.*]] = getelementptr inbounds float, float* [[ARR:%.*]], i64 [[TMP0]]
15; CHECK-NEXT:    [[TMP2:%.*]] = bitcast float* [[TMP1]] to <2 x float>*
16; CHECK-NEXT:    [[WIDE_LOAD:%.*]] = load <2 x float>, <2 x float>* [[TMP2]], align 4
17; CHECK-NEXT:    [[TMP3:%.*]] = fpext <2 x float> [[WIDE_LOAD]] to <2 x double>
18; CHECK-NEXT:    [[TMP4:%.*]] = tail call fast <2 x double> @__sind2(<2 x double> [[TMP3]])
19; CHECK-NEXT:    [[TMP5]] = fadd fast <2 x double> [[TMP4]], [[VEC_PHI]]
20; CHECK-NEXT:    [[INDEX_NEXT]] = add nuw i32 [[INDEX]], 2
21; CHECK-NEXT:    [[TMP6:%.*]] = icmp eq i32 [[INDEX_NEXT]], 128
22; CHECK-NEXT:    br i1 [[TMP6]], label [[MIDDLE_BLOCK:%.*]], label [[VECTOR_BODY]], !llvm.loop [[LOOP0:![0-9]+]]
23; CHECK:       middle.block:
24; CHECK-NEXT:    [[DOTLCSSA:%.*]] = phi <2 x double> [ [[TMP5]], [[VECTOR_BODY]] ]
25; CHECK-NEXT:    [[TMP7:%.*]] = tail call fast double @llvm.vector.reduce.fadd.v2f64(double -0.000000e+00, <2 x double> [[DOTLCSSA]])
26; CHECK-NEXT:    ret double [[TMP7]]
27;
28entry:
29  br label %for.cond
30
31for.cond:
32  %Sum.0 = phi double [ 0.000000e+00, %entry ], [ %add, %for.inc ]
33  %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.inc ]
34  %cmp = icmp slt i32 %i.0, 128
35  br i1 %cmp, label %for.body, label %for.cond.cleanup
36
37for.cond.cleanup:
38  br label %for.end
39
40for.body:
41  %idxprom = sext i32 %i.0 to i64
42  %arrayidx = getelementptr inbounds float, float* %Arr, i64 %idxprom
43  %0 = load float, float* %arrayidx, align 4
44  %conv = fpext float %0 to double
45  %1 = call fast double @llvm.sin.f64(double %conv)
46  %add = fadd fast double %Sum.0, %1
47  br label %for.inc
48
49for.inc:
50  %inc = add nsw i32 %i.0, 1
51  br label %for.cond
52
53for.end:
54  ret double %Sum.0
55}
56
57declare double @llvm.sin.f64(double)
58