1cee313d2SEric Christopher; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 2cee313d2SEric Christopher; RUN: opt < %s -loop-vectorize -mtriple=thumbv8-unknown-unknown -mcpu=cortex-a53 -S | FileCheck %s 3cee313d2SEric Christopher 4cee313d2SEric Christopher; This test is reduced from SPECFP 2006 482.sphinx. 5cee313d2SEric Christopher; We expect vectorization with <2 x double> and <2 x float> ops. 6cee313d2SEric Christopher; See https://bugs.llvm.org/show_bug.cgi?id=36280 for more details. 7cee313d2SEric Christopher 8cee313d2SEric Christopher 9cee313d2SEric Christophertarget datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64" 10cee313d2SEric Christopher 11cee313d2SEric Christopher@a = external global i32 12cee313d2SEric Christopher@v = external global i32 13cee313d2SEric Christopher@mm = external global float** 14cee313d2SEric Christopher@vv = external global float** 15cee313d2SEric Christopher@ll = external global float* 16cee313d2SEric Christopher 17cee313d2SEric Christopherdefine i32 @test(float* nocapture readonly %x) { 18cee313d2SEric Christopher; CHECK-LABEL: @test( 19cee313d2SEric Christopher; CHECK-NEXT: entry: 20cee313d2SEric Christopher; CHECK-NEXT: [[T:%.*]] = load i32, i32* @v, align 8 21cee313d2SEric Christopher; CHECK-NEXT: [[T1:%.*]] = load i32, i32* @a, align 4 22cee313d2SEric Christopher; CHECK-NEXT: br label [[OUTERLOOP:%.*]] 23cee313d2SEric Christopher; CHECK: outerloop: 24cee313d2SEric Christopher; CHECK-NEXT: [[T2:%.*]] = phi i32 [ [[V17:%.*]], [[OUTEREND:%.*]] ], [ [[T1]], [[ENTRY:%.*]] ] 25cee313d2SEric Christopher; CHECK-NEXT: [[J_0136:%.*]] = phi i32 [ [[INC144:%.*]], [[OUTEREND]] ], [ 0, [[ENTRY]] ] 26cee313d2SEric Christopher; CHECK-NEXT: [[SCORE_1135:%.*]] = phi i32 [ [[CALL142:%.*]], [[OUTEREND]] ], [ -939524096, [[ENTRY]] ] 27cee313d2SEric Christopher; CHECK-NEXT: [[T3:%.*]] = load float**, float*** @mm, align 4 28cee313d2SEric Christopher; CHECK-NEXT: [[ARRAYIDX109:%.*]] = getelementptr inbounds float*, float** [[T3]], i32 [[T2]] 29cee313d2SEric Christopher; CHECK-NEXT: [[T4:%.*]] = load float*, float** [[ARRAYIDX109]], align 4 30cee313d2SEric Christopher; CHECK-NEXT: [[T5:%.*]] = load float**, float*** @vv, align 4 31cee313d2SEric Christopher; CHECK-NEXT: [[ARRAYIDX111:%.*]] = getelementptr inbounds float*, float** [[T5]], i32 [[T2]] 32cee313d2SEric Christopher; CHECK-NEXT: [[T6:%.*]] = load float*, float** [[ARRAYIDX111]], align 4 33cee313d2SEric Christopher; CHECK-NEXT: [[T7:%.*]] = load float*, float** @ll, align 4 34cee313d2SEric Christopher; CHECK-NEXT: [[ARRAYIDX113:%.*]] = getelementptr inbounds float, float* [[T7]], i32 [[T2]] 35cee313d2SEric Christopher; CHECK-NEXT: [[T8:%.*]] = load float, float* [[ARRAYIDX113]], align 4 36cee313d2SEric Christopher; CHECK-NEXT: [[CONV114:%.*]] = fpext float [[T8]] to double 37cee313d2SEric Christopher; CHECK-NEXT: [[MIN_ITERS_CHECK:%.*]] = icmp ult i32 [[T]], 2 38cee313d2SEric Christopher; CHECK-NEXT: br i1 [[MIN_ITERS_CHECK]], label [[SCALAR_PH:%.*]], label [[VECTOR_PH:%.*]] 39cee313d2SEric Christopher; CHECK: vector.ph: 40cee313d2SEric Christopher; CHECK-NEXT: [[N_MOD_VF:%.*]] = urem i32 [[T]], 2 41cee313d2SEric Christopher; CHECK-NEXT: [[N_VEC:%.*]] = sub i32 [[T]], [[N_MOD_VF]] 42cee313d2SEric Christopher; CHECK-NEXT: [[TMP0:%.*]] = insertelement <2 x double> zeroinitializer, double [[CONV114]], i32 0 43cee313d2SEric Christopher; CHECK-NEXT: br label [[VECTOR_BODY:%.*]] 44cee313d2SEric Christopher; CHECK: vector.body: 45cee313d2SEric Christopher; CHECK-NEXT: [[INDEX:%.*]] = phi i32 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ] 46cee313d2SEric Christopher; CHECK-NEXT: [[VEC_PHI:%.*]] = phi <2 x double> [ [[TMP0]], [[VECTOR_PH]] ], [ [[TMP16:%.*]], [[VECTOR_BODY]] ] 47cee313d2SEric Christopher; CHECK-NEXT: [[TMP1:%.*]] = add i32 [[INDEX]], 0 48cee313d2SEric Christopher; CHECK-NEXT: [[TMP2:%.*]] = getelementptr inbounds float, float* [[X:%.*]], i32 [[TMP1]] 49cee313d2SEric Christopher; CHECK-NEXT: [[TMP3:%.*]] = getelementptr inbounds float, float* [[TMP2]], i32 0 50cee313d2SEric Christopher; CHECK-NEXT: [[TMP4:%.*]] = bitcast float* [[TMP3]] to <2 x float>* 51cee313d2SEric Christopher; CHECK-NEXT: [[WIDE_LOAD:%.*]] = load <2 x float>, <2 x float>* [[TMP4]], align 4 52cee313d2SEric Christopher; CHECK-NEXT: [[TMP5:%.*]] = getelementptr inbounds float, float* [[T4]], i32 [[TMP1]] 53cee313d2SEric Christopher; CHECK-NEXT: [[TMP6:%.*]] = getelementptr inbounds float, float* [[TMP5]], i32 0 54cee313d2SEric Christopher; CHECK-NEXT: [[TMP7:%.*]] = bitcast float* [[TMP6]] to <2 x float>* 55cee313d2SEric Christopher; CHECK-NEXT: [[WIDE_LOAD1:%.*]] = load <2 x float>, <2 x float>* [[TMP7]], align 4 56cee313d2SEric Christopher; CHECK-NEXT: [[TMP8:%.*]] = fsub fast <2 x float> [[WIDE_LOAD]], [[WIDE_LOAD1]] 57cee313d2SEric Christopher; CHECK-NEXT: [[TMP9:%.*]] = fpext <2 x float> [[TMP8]] to <2 x double> 58cee313d2SEric Christopher; CHECK-NEXT: [[TMP10:%.*]] = fmul fast <2 x double> [[TMP9]], [[TMP9]] 59cee313d2SEric Christopher; CHECK-NEXT: [[TMP11:%.*]] = getelementptr inbounds float, float* [[T6]], i32 [[TMP1]] 60cee313d2SEric Christopher; CHECK-NEXT: [[TMP12:%.*]] = getelementptr inbounds float, float* [[TMP11]], i32 0 61cee313d2SEric Christopher; CHECK-NEXT: [[TMP13:%.*]] = bitcast float* [[TMP12]] to <2 x float>* 62cee313d2SEric Christopher; CHECK-NEXT: [[WIDE_LOAD2:%.*]] = load <2 x float>, <2 x float>* [[TMP13]], align 4 63cee313d2SEric Christopher; CHECK-NEXT: [[TMP14:%.*]] = fpext <2 x float> [[WIDE_LOAD2]] to <2 x double> 64cee313d2SEric Christopher; CHECK-NEXT: [[TMP15:%.*]] = fmul fast <2 x double> [[TMP10]], [[TMP14]] 65cee313d2SEric Christopher; CHECK-NEXT: [[TMP16]] = fsub fast <2 x double> [[VEC_PHI]], [[TMP15]] 6623c2f2e6SFlorian Hahn; CHECK-NEXT: [[INDEX_NEXT]] = add nuw i32 [[INDEX]], 2 67cee313d2SEric Christopher; CHECK-NEXT: [[TMP17:%.*]] = icmp eq i32 [[INDEX_NEXT]], [[N_VEC]] 68*872f7000SDávid Bolvanský; CHECK-NEXT: br i1 [[TMP17]], label [[MIDDLE_BLOCK:%.*]], label [[VECTOR_BODY]], [[LOOP0:!llvm.loop !.*]] 69cee313d2SEric Christopher; CHECK: middle.block: 7079b1b4a5SSanjay Patel; CHECK-NEXT: [[TMP18:%.*]] = call fast double @llvm.vector.reduce.fadd.v2f64(double -0.000000e+00, <2 x double> [[TMP16]]) 71cee313d2SEric Christopher; CHECK-NEXT: [[CMP_N:%.*]] = icmp eq i32 [[T]], [[N_VEC]] 72cee313d2SEric Christopher; CHECK-NEXT: br i1 [[CMP_N]], label [[OUTEREND]], label [[SCALAR_PH]] 73cee313d2SEric Christopher; CHECK: scalar.ph: 74cee313d2SEric Christopher; CHECK-NEXT: [[BC_RESUME_VAL:%.*]] = phi i32 [ [[N_VEC]], [[MIDDLE_BLOCK]] ], [ 0, [[OUTERLOOP]] ] 75cee313d2SEric Christopher; CHECK-NEXT: [[BC_MERGE_RDX:%.*]] = phi double [ [[CONV114]], [[OUTERLOOP]] ], [ [[TMP18]], [[MIDDLE_BLOCK]] ] 76cee313d2SEric Christopher; CHECK-NEXT: br label [[INNERLOOP:%.*]] 77cee313d2SEric Christopher; CHECK: innerloop: 78cee313d2SEric Christopher; CHECK-NEXT: [[I_2132:%.*]] = phi i32 [ [[BC_RESUME_VAL]], [[SCALAR_PH]] ], [ [[INC129:%.*]], [[INNERLOOP]] ] 79cee313d2SEric Christopher; CHECK-NEXT: [[DVAL1_4131:%.*]] = phi double [ [[BC_MERGE_RDX]], [[SCALAR_PH]] ], [ [[SUB127:%.*]], [[INNERLOOP]] ] 80cee313d2SEric Christopher; CHECK-NEXT: [[ARRAYIDX119:%.*]] = getelementptr inbounds float, float* [[X]], i32 [[I_2132]] 81cee313d2SEric Christopher; CHECK-NEXT: [[T9:%.*]] = load float, float* [[ARRAYIDX119]], align 4 82cee313d2SEric Christopher; CHECK-NEXT: [[ARRAYIDX120:%.*]] = getelementptr inbounds float, float* [[T4]], i32 [[I_2132]] 83cee313d2SEric Christopher; CHECK-NEXT: [[T10:%.*]] = load float, float* [[ARRAYIDX120]], align 4 84cee313d2SEric Christopher; CHECK-NEXT: [[SUB121:%.*]] = fsub fast float [[T9]], [[T10]] 85cee313d2SEric Christopher; CHECK-NEXT: [[CONV122:%.*]] = fpext float [[SUB121]] to double 86cee313d2SEric Christopher; CHECK-NEXT: [[MUL123:%.*]] = fmul fast double [[CONV122]], [[CONV122]] 87cee313d2SEric Christopher; CHECK-NEXT: [[ARRAYIDX124:%.*]] = getelementptr inbounds float, float* [[T6]], i32 [[I_2132]] 88cee313d2SEric Christopher; CHECK-NEXT: [[T11:%.*]] = load float, float* [[ARRAYIDX124]], align 4 89cee313d2SEric Christopher; CHECK-NEXT: [[CONV125:%.*]] = fpext float [[T11]] to double 90cee313d2SEric Christopher; CHECK-NEXT: [[MUL126:%.*]] = fmul fast double [[MUL123]], [[CONV125]] 91cee313d2SEric Christopher; CHECK-NEXT: [[SUB127]] = fsub fast double [[DVAL1_4131]], [[MUL126]] 92cee313d2SEric Christopher; CHECK-NEXT: [[INC129]] = add nuw nsw i32 [[I_2132]], 1 93cee313d2SEric Christopher; CHECK-NEXT: [[EXITCOND143:%.*]] = icmp eq i32 [[INC129]], [[T]] 94*872f7000SDávid Bolvanský; CHECK-NEXT: br i1 [[EXITCOND143]], label [[OUTEREND]], label [[INNERLOOP]], [[LOOP2:!llvm.loop !.*]] 95cee313d2SEric Christopher; CHECK: outerend: 96cee313d2SEric Christopher; CHECK-NEXT: [[SUB127_LCSSA:%.*]] = phi double [ [[SUB127]], [[INNERLOOP]] ], [ [[TMP18]], [[MIDDLE_BLOCK]] ] 97cee313d2SEric Christopher; CHECK-NEXT: [[CONV138:%.*]] = fptosi double [[SUB127_LCSSA]] to i32 98cee313d2SEric Christopher; CHECK-NEXT: [[CALL142]] = add nuw nsw i32 [[SCORE_1135]], [[CONV138]] 99cee313d2SEric Christopher; CHECK-NEXT: [[INC144]] = add nuw nsw i32 [[J_0136]], 1 100cee313d2SEric Christopher; CHECK-NEXT: [[ARRAYIDX102:%.*]] = getelementptr inbounds i32, i32* @a, i32 [[INC144]] 101cee313d2SEric Christopher; CHECK-NEXT: [[V17]] = load i32, i32* [[ARRAYIDX102]], align 4 102cee313d2SEric Christopher; CHECK-NEXT: [[CMP103:%.*]] = icmp sgt i32 [[V17]], -1 103cee313d2SEric Christopher; CHECK-NEXT: br i1 [[CMP103]], label [[OUTERLOOP]], label [[EXIT:%.*]] 104cee313d2SEric Christopher; CHECK: exit: 105cee313d2SEric Christopher; CHECK-NEXT: ret i32 [[CALL142]] 106cee313d2SEric Christopher; 107cee313d2SEric Christopherentry: 108cee313d2SEric Christopher %t = load i32, i32* @v, align 8 109cee313d2SEric Christopher %t1 = load i32, i32* @a, align 4 110cee313d2SEric Christopher br label %outerloop 111cee313d2SEric Christopher 112cee313d2SEric Christopherouterloop: 113cee313d2SEric Christopher %t2 = phi i32 [ %v17, %outerend ], [ %t1, %entry ] 114cee313d2SEric Christopher %j.0136 = phi i32 [ %inc144, %outerend ], [ 0, %entry ] 115cee313d2SEric Christopher %score.1135 = phi i32 [ %call142, %outerend ], [ -939524096, %entry ] 116cee313d2SEric Christopher %t3 = load float**, float*** @mm, align 4 117cee313d2SEric Christopher %arrayidx109 = getelementptr inbounds float*, float** %t3, i32 %t2 118cee313d2SEric Christopher %t4 = load float*, float** %arrayidx109, align 4 119cee313d2SEric Christopher %t5 = load float**, float*** @vv, align 4 120cee313d2SEric Christopher %arrayidx111 = getelementptr inbounds float*, float** %t5, i32 %t2 121cee313d2SEric Christopher %t6 = load float*, float** %arrayidx111, align 4 122cee313d2SEric Christopher %t7 = load float*, float** @ll, align 4 123cee313d2SEric Christopher %arrayidx113 = getelementptr inbounds float, float* %t7, i32 %t2 124cee313d2SEric Christopher %t8 = load float, float* %arrayidx113, align 4 125cee313d2SEric Christopher %conv114 = fpext float %t8 to double 126cee313d2SEric Christopher br label %innerloop 127cee313d2SEric Christopher 128cee313d2SEric Christopherinnerloop: 129cee313d2SEric Christopher %i.2132 = phi i32 [ 0, %outerloop ], [ %inc129, %innerloop ] 130cee313d2SEric Christopher %dval1.4131 = phi double [ %conv114, %outerloop ], [ %sub127, %innerloop ] 131cee313d2SEric Christopher %arrayidx119 = getelementptr inbounds float, float* %x, i32 %i.2132 132cee313d2SEric Christopher %t9 = load float, float* %arrayidx119, align 4 133cee313d2SEric Christopher %arrayidx120 = getelementptr inbounds float, float* %t4, i32 %i.2132 134cee313d2SEric Christopher %t10 = load float, float* %arrayidx120, align 4 135cee313d2SEric Christopher %sub121 = fsub fast float %t9, %t10 136cee313d2SEric Christopher %conv122 = fpext float %sub121 to double 137cee313d2SEric Christopher %mul123 = fmul fast double %conv122, %conv122 138cee313d2SEric Christopher %arrayidx124 = getelementptr inbounds float, float* %t6, i32 %i.2132 139cee313d2SEric Christopher %t11 = load float, float* %arrayidx124, align 4 140cee313d2SEric Christopher %conv125 = fpext float %t11 to double 141cee313d2SEric Christopher %mul126 = fmul fast double %mul123, %conv125 142cee313d2SEric Christopher %sub127 = fsub fast double %dval1.4131, %mul126 143cee313d2SEric Christopher %inc129 = add nuw nsw i32 %i.2132, 1 144cee313d2SEric Christopher %exitcond143 = icmp eq i32 %inc129, %t 145cee313d2SEric Christopher br i1 %exitcond143, label %outerend, label %innerloop 146cee313d2SEric Christopher 147cee313d2SEric Christopherouterend: 148cee313d2SEric Christopher %sub127.lcssa = phi double [ %sub127, %innerloop ] 149cee313d2SEric Christopher %conv138 = fptosi double %sub127.lcssa to i32 150cee313d2SEric Christopher %call142 = add nuw nsw i32 %score.1135, %conv138 151cee313d2SEric Christopher %inc144 = add nuw nsw i32 %j.0136, 1 152cee313d2SEric Christopher %arrayidx102 = getelementptr inbounds i32, i32* @a, i32 %inc144 153cee313d2SEric Christopher %v17 = load i32, i32* %arrayidx102, align 4 154cee313d2SEric Christopher %cmp103 = icmp sgt i32 %v17, -1 155cee313d2SEric Christopher br i1 %cmp103, label %outerloop, label %exit 156cee313d2SEric Christopher 157cee313d2SEric Christopherexit: 158cee313d2SEric Christopher ret i32 %call142 159cee313d2SEric Christopher} 160cee313d2SEric Christopher 161