brintos

brintos / llvm-project-archived public Read only

0
0
Text · 9.7 KiB · 1203076 Raw
191 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 52; RUN: opt -passes=loop-vectorize -force-vector-width=2 -force-vector-interleave=2 -S %s | FileCheck %s3; RUN: opt -passes=loop-vectorize -force-vector-width=2 -force-vector-interleave=2 -prefer-inloop-reductions -S %s | FileCheck %s4 5define float @maximumnum_intrinsic(ptr readonly %x) {6; CHECK-LABEL: define float @maximumnum_intrinsic(7; CHECK-SAME: ptr readonly [[X:%.*]]) {8; CHECK-NEXT:  [[ENTRY:.*:]]9; CHECK-NEXT:    br label %[[VECTOR_PH:.*]]10; CHECK:       [[VECTOR_PH]]:11; CHECK-NEXT:    br label %[[VECTOR_BODY:.*]]12; CHECK:       [[VECTOR_BODY]]:13; CHECK-NEXT:    [[IV:%.*]] = phi i32 [ 0, %[[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], %[[VECTOR_BODY]] ]14; CHECK-NEXT:    [[VEC_PHI:%.*]] = phi <2 x float> [ zeroinitializer, %[[VECTOR_PH]] ], [ [[TMP3:%.*]], %[[VECTOR_BODY]] ]15; CHECK-NEXT:    [[VEC_PHI1:%.*]] = phi <2 x float> [ zeroinitializer, %[[VECTOR_PH]] ], [ [[TMP4:%.*]], %[[VECTOR_BODY]] ]16; CHECK-NEXT:    [[GEP:%.*]] = getelementptr inbounds float, ptr [[X]], i32 [[IV]]17; CHECK-NEXT:    [[TMP2:%.*]] = getelementptr inbounds float, ptr [[GEP]], i64 218; CHECK-NEXT:    [[WIDE_LOAD:%.*]] = load <2 x float>, ptr [[GEP]], align 419; CHECK-NEXT:    [[WIDE_LOAD2:%.*]] = load <2 x float>, ptr [[TMP2]], align 420; CHECK-NEXT:    [[TMP3]] = call <2 x float> @llvm.maximumnum.v2f32(<2 x float> [[VEC_PHI]], <2 x float> [[WIDE_LOAD]])21; CHECK-NEXT:    [[TMP4]] = call <2 x float> @llvm.maximumnum.v2f32(<2 x float> [[VEC_PHI1]], <2 x float> [[WIDE_LOAD2]])22; CHECK-NEXT:    [[INDEX_NEXT]] = add nuw i32 [[IV]], 423; CHECK-NEXT:    [[TMP5:%.*]] = icmp eq i32 [[INDEX_NEXT]], 102424; CHECK-NEXT:    br i1 [[TMP5]], label %[[MIDDLE_BLOCK:.*]], label %[[VECTOR_BODY]], !llvm.loop [[LOOP0:![0-9]+]]25; CHECK:       [[MIDDLE_BLOCK]]:26; CHECK-NEXT:    [[RDX_MINMAX:%.*]] = call <2 x float> @llvm.maximumnum.v2f32(<2 x float> [[TMP3]], <2 x float> [[TMP4]])27; CHECK-NEXT:    [[TMP6:%.*]] = call float @llvm.vector.reduce.fmax.v2f32(<2 x float> [[RDX_MINMAX]])28; CHECK-NEXT:    br label %[[EXIT:.*]]29; CHECK:       [[EXIT]]:30; CHECK-NEXT:    ret float [[TMP6]]31;32entry:33  br label %loop34 35loop:36  %iv = phi i32 [ 0, %entry ], [ %inc, %loop ]37  %red = phi float [ 0.000000e+00, %entry ], [ %red.next, %loop ]38  %gep = getelementptr inbounds float, ptr %x, i32 %iv39  %l = load float, ptr %gep, align 440  %red.next = tail call float @llvm.maximumnum.f32(float %red, float %l)41  %inc = add nuw nsw i32 %iv, 142  %ec = icmp eq i32 %inc, 102443  br i1 %ec, label %exit, label %loop44 45exit:46  ret float %red.next47}48 49define float @maximumnum_intrinsic_fast(ptr readonly %x) {50; CHECK-LABEL: define float @maximumnum_intrinsic_fast(51; CHECK-SAME: ptr readonly [[X:%.*]]) {52; CHECK-NEXT:  [[ENTRY:.*:]]53; CHECK-NEXT:    br label %[[VECTOR_PH:.*]]54; CHECK:       [[VECTOR_PH]]:55; CHECK-NEXT:    br label %[[VECTOR_BODY:.*]]56; CHECK:       [[VECTOR_BODY]]:57; CHECK-NEXT:    [[IV:%.*]] = phi i32 [ 0, %[[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], %[[VECTOR_BODY]] ]58; CHECK-NEXT:    [[VEC_PHI:%.*]] = phi <2 x float> [ zeroinitializer, %[[VECTOR_PH]] ], [ [[TMP3:%.*]], %[[VECTOR_BODY]] ]59; CHECK-NEXT:    [[VEC_PHI1:%.*]] = phi <2 x float> [ zeroinitializer, %[[VECTOR_PH]] ], [ [[TMP4:%.*]], %[[VECTOR_BODY]] ]60; CHECK-NEXT:    [[GEP:%.*]] = getelementptr inbounds float, ptr [[X]], i32 [[IV]]61; CHECK-NEXT:    [[TMP2:%.*]] = getelementptr inbounds float, ptr [[GEP]], i64 262; CHECK-NEXT:    [[WIDE_LOAD:%.*]] = load <2 x float>, ptr [[GEP]], align 463; CHECK-NEXT:    [[WIDE_LOAD2:%.*]] = load <2 x float>, ptr [[TMP2]], align 464; CHECK-NEXT:    [[TMP3]] = call fast <2 x float> @llvm.maximumnum.v2f32(<2 x float> [[VEC_PHI]], <2 x float> [[WIDE_LOAD]])65; CHECK-NEXT:    [[TMP4]] = call fast <2 x float> @llvm.maximumnum.v2f32(<2 x float> [[VEC_PHI1]], <2 x float> [[WIDE_LOAD2]])66; CHECK-NEXT:    [[INDEX_NEXT]] = add nuw i32 [[IV]], 467; CHECK-NEXT:    [[TMP5:%.*]] = icmp eq i32 [[INDEX_NEXT]], 102468; CHECK-NEXT:    br i1 [[TMP5]], label %[[MIDDLE_BLOCK:.*]], label %[[VECTOR_BODY]], !llvm.loop [[LOOP3:![0-9]+]]69; CHECK:       [[MIDDLE_BLOCK]]:70; CHECK-NEXT:    [[RDX_MINMAX:%.*]] = call fast <2 x float> @llvm.maximumnum.v2f32(<2 x float> [[TMP3]], <2 x float> [[TMP4]])71; CHECK-NEXT:    [[TMP6:%.*]] = call fast float @llvm.vector.reduce.fmax.v2f32(<2 x float> [[RDX_MINMAX]])72; CHECK-NEXT:    br label %[[EXIT:.*]]73; CHECK:       [[EXIT]]:74; CHECK-NEXT:    ret float [[TMP6]]75;76entry:77  br label %loop78 79loop:80  %iv = phi i32 [ 0, %entry ], [ %inc, %loop ]81  %red = phi float [ 0.000000e+00, %entry ], [ %red.next, %loop ]82  %gep = getelementptr inbounds float, ptr %x, i32 %iv83  %l = load float, ptr %gep, align 484  %red.next = tail call fast float @llvm.maximumnum.f32(float %red, float %l)85  %inc = add nuw nsw i32 %iv, 186  %ec = icmp eq i32 %inc, 102487  br i1 %ec, label %exit, label %loop88 89exit:90  ret float %red.next91}92 93define float @minimumnum_intrinsic(ptr readonly %x) {94; CHECK-LABEL: define float @minimumnum_intrinsic(95; CHECK-SAME: ptr readonly [[X:%.*]]) {96; CHECK-NEXT:  [[ENTRY:.*:]]97; CHECK-NEXT:    br label %[[VECTOR_PH:.*]]98; CHECK:       [[VECTOR_PH]]:99; CHECK-NEXT:    br label %[[VECTOR_BODY:.*]]100; CHECK:       [[VECTOR_BODY]]:101; CHECK-NEXT:    [[IV:%.*]] = phi i32 [ 0, %[[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], %[[VECTOR_BODY]] ]102; CHECK-NEXT:    [[VEC_PHI:%.*]] = phi <2 x float> [ zeroinitializer, %[[VECTOR_PH]] ], [ [[TMP3:%.*]], %[[VECTOR_BODY]] ]103; CHECK-NEXT:    [[VEC_PHI1:%.*]] = phi <2 x float> [ zeroinitializer, %[[VECTOR_PH]] ], [ [[TMP4:%.*]], %[[VECTOR_BODY]] ]104; CHECK-NEXT:    [[GEP:%.*]] = getelementptr inbounds float, ptr [[X]], i32 [[IV]]105; CHECK-NEXT:    [[TMP2:%.*]] = getelementptr inbounds float, ptr [[GEP]], i64 2106; CHECK-NEXT:    [[WIDE_LOAD:%.*]] = load <2 x float>, ptr [[GEP]], align 4107; CHECK-NEXT:    [[WIDE_LOAD2:%.*]] = load <2 x float>, ptr [[TMP2]], align 4108; CHECK-NEXT:    [[TMP3]] = call <2 x float> @llvm.minimumnum.v2f32(<2 x float> [[VEC_PHI]], <2 x float> [[WIDE_LOAD]])109; CHECK-NEXT:    [[TMP4]] = call <2 x float> @llvm.minimumnum.v2f32(<2 x float> [[VEC_PHI1]], <2 x float> [[WIDE_LOAD2]])110; CHECK-NEXT:    [[INDEX_NEXT]] = add nuw i32 [[IV]], 4111; CHECK-NEXT:    [[TMP5:%.*]] = icmp eq i32 [[INDEX_NEXT]], 1024112; CHECK-NEXT:    br i1 [[TMP5]], label %[[MIDDLE_BLOCK:.*]], label %[[VECTOR_BODY]], !llvm.loop [[LOOP4:![0-9]+]]113; CHECK:       [[MIDDLE_BLOCK]]:114; CHECK-NEXT:    [[RDX_MINMAX:%.*]] = call <2 x float> @llvm.minimumnum.v2f32(<2 x float> [[TMP3]], <2 x float> [[TMP4]])115; CHECK-NEXT:    [[TMP6:%.*]] = call float @llvm.vector.reduce.fmin.v2f32(<2 x float> [[RDX_MINMAX]])116; CHECK-NEXT:    br label %[[EXIT:.*]]117; CHECK:       [[EXIT]]:118; CHECK-NEXT:    ret float [[TMP6]]119;120entry:121  br label %loop122 123loop:124  %iv = phi i32 [ 0, %entry ], [ %inc, %loop ]125  %red = phi float [ 0.000000e+00, %entry ], [ %red.next, %loop ]126  %gep = getelementptr inbounds float, ptr %x, i32 %iv127  %l = load float, ptr %gep, align 4128  %red.next = tail call float @llvm.minimumnum.f32(float %red, float %l)129  %inc = add nuw nsw i32 %iv, 1130  %ec = icmp eq i32 %inc, 1024131  br i1 %ec, label %exit, label %loop132 133exit:134  ret float %red.next135}136 137define float @minimumnum_intrinsic_fast(ptr readonly %x) {138; CHECK-LABEL: define float @minimumnum_intrinsic_fast(139; CHECK-SAME: ptr readonly [[X:%.*]]) {140; CHECK-NEXT:  [[ENTRY:.*:]]141; CHECK-NEXT:    br label %[[VECTOR_PH:.*]]142; CHECK:       [[VECTOR_PH]]:143; CHECK-NEXT:    br label %[[VECTOR_BODY:.*]]144; CHECK:       [[VECTOR_BODY]]:145; CHECK-NEXT:    [[IV:%.*]] = phi i32 [ 0, %[[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], %[[VECTOR_BODY]] ]146; CHECK-NEXT:    [[VEC_PHI:%.*]] = phi <2 x float> [ zeroinitializer, %[[VECTOR_PH]] ], [ [[TMP3:%.*]], %[[VECTOR_BODY]] ]147; CHECK-NEXT:    [[VEC_PHI1:%.*]] = phi <2 x float> [ zeroinitializer, %[[VECTOR_PH]] ], [ [[TMP4:%.*]], %[[VECTOR_BODY]] ]148; CHECK-NEXT:    [[GEP:%.*]] = getelementptr inbounds float, ptr [[X]], i32 [[IV]]149; CHECK-NEXT:    [[TMP2:%.*]] = getelementptr inbounds float, ptr [[GEP]], i64 2150; CHECK-NEXT:    [[WIDE_LOAD:%.*]] = load <2 x float>, ptr [[GEP]], align 4151; CHECK-NEXT:    [[WIDE_LOAD2:%.*]] = load <2 x float>, ptr [[TMP2]], align 4152; CHECK-NEXT:    [[TMP3]] = call fast <2 x float> @llvm.minimumnum.v2f32(<2 x float> [[VEC_PHI]], <2 x float> [[WIDE_LOAD]])153; CHECK-NEXT:    [[TMP4]] = call fast <2 x float> @llvm.minimumnum.v2f32(<2 x float> [[VEC_PHI1]], <2 x float> [[WIDE_LOAD2]])154; CHECK-NEXT:    [[INDEX_NEXT]] = add nuw i32 [[IV]], 4155; CHECK-NEXT:    [[TMP5:%.*]] = icmp eq i32 [[INDEX_NEXT]], 1024156; CHECK-NEXT:    br i1 [[TMP5]], label %[[MIDDLE_BLOCK:.*]], label %[[VECTOR_BODY]], !llvm.loop [[LOOP5:![0-9]+]]157; CHECK:       [[MIDDLE_BLOCK]]:158; CHECK-NEXT:    [[RDX_MINMAX:%.*]] = call fast <2 x float> @llvm.minimumnum.v2f32(<2 x float> [[TMP3]], <2 x float> [[TMP4]])159; CHECK-NEXT:    [[TMP6:%.*]] = call fast float @llvm.vector.reduce.fmin.v2f32(<2 x float> [[RDX_MINMAX]])160; CHECK-NEXT:    br label %[[EXIT:.*]]161; CHECK:       [[EXIT]]:162; CHECK-NEXT:    ret float [[TMP6]]163;164entry:165  br label %loop166 167loop:168  %iv = phi i32 [ 0, %entry ], [ %inc, %loop ]169  %red = phi float [ 0.000000e+00, %entry ], [ %red.next, %loop ]170  %gep = getelementptr inbounds float, ptr %x, i32 %iv171  %l = load float, ptr %gep, align 4172  %red.next = tail call fast float @llvm.minimumnum.f32(float %red, float %l)173  %inc = add nuw nsw i32 %iv, 1174  %ec = icmp eq i32 %inc, 1024175  br i1 %ec, label %exit, label %loop176 177exit:178  ret float %red.next179}180 181declare float @llvm.minimumnum.f32(float, float)182declare float @llvm.maximumnum.f32(float, float)183;.184; CHECK: [[LOOP0]] = distinct !{[[LOOP0]], [[META1:![0-9]+]], [[META2:![0-9]+]]}185; CHECK: [[META1]] = !{!"llvm.loop.isvectorized", i32 1}186; CHECK: [[META2]] = !{!"llvm.loop.unroll.runtime.disable"}187; CHECK: [[LOOP3]] = distinct !{[[LOOP3]], [[META1]], [[META2]]}188; CHECK: [[LOOP4]] = distinct !{[[LOOP4]], [[META1]], [[META2]]}189; CHECK: [[LOOP5]] = distinct !{[[LOOP5]], [[META1]], [[META2]]}190;.191