Skip to content

Commit e36af6b

Browse files
committed
!fixup try to make code a bit more compact, rename IVDesc kind.
1 parent 421b0d0 commit e36af6b

File tree

8 files changed

+30
-29
lines changed

8 files changed

+30
-29
lines changed

llvm/include/llvm/Analysis/IVDescriptors.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,9 @@ enum class RecurKind {
4747
FMul, ///< Product of floats.
4848
FMin, ///< FP min implemented in terms of select(cmp()).
4949
FMax, ///< FP max implemented in terms of select(cmp()).
50-
FMaxNoFMFs, ///< FP max implemented in terms of select(cmp()), but without
51-
///any fast-math flags. Users need to handle NaNs and signed zeros when generating code.
50+
FCmpOGTSelect, ///< FP max implemented in terms of select(cmp()), but without
51+
/// any fast-math flags. Users need to handle NaNs and signed
52+
/// zeros when generating code.
5253
FMinimum, ///< FP min with llvm.minimum semantics
5354
FMaximum, ///< FP max with llvm.maximum semantics
5455
FMinimumNum, ///< FP min with llvm.minimumnum semantics
@@ -252,7 +253,7 @@ class RecurrenceDescriptor {
252253
/// Returns true if the recurrence kind is a floating-point min/max kind.
253254
static bool isFPMinMaxRecurrenceKind(RecurKind Kind) {
254255
return Kind == RecurKind::FMin || Kind == RecurKind::FMax ||
255-
Kind == RecurKind::FMaxNoFMFs || Kind == RecurKind::FMinimum ||
256+
Kind == RecurKind::FCmpOGTSelect || Kind == RecurKind::FMinimum ||
256257
Kind == RecurKind::FMaximum || Kind == RecurKind::FMinimumNum ||
257258
Kind == RecurKind::FMaximumNum;
258259
}

llvm/lib/Analysis/IVDescriptors.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -817,7 +817,7 @@ RecurrenceDescriptor::isMinMaxPattern(Instruction *I, RecurKind Kind,
817817
if (match(I, m_OrdOrUnordFMin(m_Value(), m_Value())))
818818
return InstDesc(Kind == RecurKind::FMin, I);
819819
if (match(I, m_OrdOrUnordFMax(m_Value(), m_Value())))
820-
return InstDesc(Kind == RecurKind::FMax || Kind == RecurKind::FMaxNoFMFs,
820+
return InstDesc(Kind == RecurKind::FMax || Kind == RecurKind::FCmpOGTSelect,
821821
I);
822822
if (match(I, m_FMinNum(m_Value(), m_Value())))
823823
return InstDesc(Kind == RecurKind::FMin, I);
@@ -945,9 +945,9 @@ RecurrenceDescriptor::InstDesc RecurrenceDescriptor::isRecurrenceInstr(
945945
if (isFPMinMaxRecurrenceKind(Kind)) {
946946
if (HasRequiredFMF())
947947
return isMinMaxPattern(I, Kind, Prev);
948-
if ((Kind == RecurKind::FMax || Kind == RecurKind::FMaxNoFMFs) &&
948+
if ((Kind == RecurKind::FMax || Kind == RecurKind::FCmpOGTSelect) &&
949949
isMinMaxPattern(I, Kind, Prev).isRecurrence())
950-
return InstDesc(I, RecurKind::FMaxNoFMFs);
950+
return InstDesc(I, RecurKind::FCmpOGTSelect);
951951
} else if (isFMulAddIntrinsic(I))
952952
return InstDesc(Kind == RecurKind::FMulAdd, I,
953953
I->hasAllowReassoc() ? nullptr : I);
@@ -1211,7 +1211,7 @@ unsigned RecurrenceDescriptor::getOpcode(RecurKind Kind) {
12111211
case RecurKind::UMin:
12121212
return Instruction::ICmp;
12131213
case RecurKind::FMax:
1214-
case RecurKind::FMaxNoFMFs:
1214+
case RecurKind::FCmpOGTSelect:
12151215
case RecurKind::FMin:
12161216
case RecurKind::FMaximum:
12171217
case RecurKind::FMinimum:

llvm/lib/Transforms/Utils/LoopUtils.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -937,7 +937,7 @@ constexpr Intrinsic::ID llvm::getReductionIntrinsicID(RecurKind RK) {
937937
return Intrinsic::vector_reduce_umax;
938938
case RecurKind::UMin:
939939
return Intrinsic::vector_reduce_umin;
940-
case RecurKind::FMaxNoFMFs:
940+
case RecurKind::FCmpOGTSelect:
941941
case RecurKind::FMax:
942942
return Intrinsic::vector_reduce_fmax;
943943
case RecurKind::FMin:
@@ -1085,8 +1085,8 @@ CmpInst::Predicate llvm::getMinMaxReductionPredicate(RecurKind RK) {
10851085
return CmpInst::ICMP_SGT;
10861086
case RecurKind::FMin:
10871087
return CmpInst::FCMP_OLT;
1088+
case RecurKind::FCmpOGTSelect:
10881089
case RecurKind::FMax:
1089-
case RecurKind::FMaxNoFMFs:
10901090
return CmpInst::FCMP_OGT;
10911091
// We do not add FMinimum/FMaximum recurrence kind here since there is no
10921092
// equivalent predicate which compares signed zeroes according to the
@@ -1308,8 +1308,8 @@ Value *llvm::createSimpleReduction(IRBuilderBase &Builder, Value *Src,
13081308
case RecurKind::SMin:
13091309
case RecurKind::UMax:
13101310
case RecurKind::UMin:
1311+
case RecurKind::FCmpOGTSelect:
13111312
case RecurKind::FMax:
1312-
case RecurKind::FMaxNoFMFs:
13131313
case RecurKind::FMin:
13141314
case RecurKind::FMinimum:
13151315
case RecurKind::FMaximum:

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4460,10 +4460,8 @@ bool LoopVectorizationPlanner::isCandidateForEpilogueVectorization(
44604460
// currently unsupported.
44614461
if (any_of(OrigLoop->getHeader()->phis(), [&](PHINode &Phi) {
44624462
return Legal->isFixedOrderRecurrence(&Phi) ||
4463-
(Legal->isReductionVariable(&Phi) &&
4464-
Legal->getReductionVars()
4465-
.find(&Phi)
4466-
->second.getRecurrenceKind() == RecurKind::FMaxNoFMFs);
4463+
Legal->getReductionVars().lookup(&Phi).getRecurrenceKind() ==
4464+
RecurKind::FCmpOGTSelect;
44674465
}))
44684466
return false;
44694467

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23184,6 +23184,7 @@ class HorizontalReduction {
2318423184
case RecurKind::FindFirstIVUMin:
2318523185
case RecurKind::FindLastIVSMax:
2318623186
case RecurKind::FindLastIVUMax:
23187+
case RecurKind::FCmpOGTSelect:
2318723188
case RecurKind::FMaximumNum:
2318823189
case RecurKind::FMinimumNum:
2318923190
case RecurKind::None:
@@ -23321,6 +23322,7 @@ class HorizontalReduction {
2332123322
case RecurKind::FindFirstIVUMin:
2332223323
case RecurKind::FindLastIVSMax:
2332323324
case RecurKind::FindLastIVUMax:
23325+
case RecurKind::FCmpOGTSelect:
2332423326
case RecurKind::FMaximumNum:
2332523327
case RecurKind::FMinimumNum:
2332623328
case RecurKind::None:
@@ -23423,7 +23425,7 @@ class HorizontalReduction {
2342323425
case RecurKind::FindFirstIVUMin:
2342423426
case RecurKind::FindLastIVSMax:
2342523427
case RecurKind::FindLastIVUMax:
23426-
case RecurKind::FMaxNoFMFs:
23428+
case RecurKind::FCmpOGTSelect:
2342723429
case RecurKind::FMaximumNum:
2342823430
case RecurKind::FMinimumNum:
2342923431
case RecurKind::None:

llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -596,9 +596,9 @@ bool VPlanTransforms::handleFMaxReductionsWithoutFastMath(VPlan &Plan) {
596596
VPRecipeWithIRFlags *MinMaxOp = nullptr;
597597
VPWidenIntOrFpInductionRecipe *WideIV = nullptr;
598598

599-
// Check if there are any FMaxNoFMFs reductions using wide selects that we can
600-
// fix up. To do so, we also need a wide canonical IV to keep track of the
601-
// indices of the max values.
599+
// Check if there are any FCmpOGTSelect reductions using wide selects that we
600+
// can fix up. To do so, we also need a wide canonical IV to keep track of
601+
// the indices of the max values.
602602
for (auto &R : LoopRegion->getEntryBasicBlock()->phis()) {
603603
// We need a wide canonical IV
604604
if (auto *CurIV = dyn_cast<VPWidenIntOrFpInductionRecipe>(&R)) {
@@ -608,14 +608,14 @@ bool VPlanTransforms::handleFMaxReductionsWithoutFastMath(VPlan &Plan) {
608608
continue;
609609
}
610610

611-
// And a single FMaxNoFMFs reduction phi.
611+
// And a single FCmpOGTSelect reduction phi.
612612
// TODO: Support FMin reductions as well.
613613
auto *CurRedPhiR = dyn_cast<VPReductionPHIRecipe>(&R);
614614
if (!CurRedPhiR)
615615
continue;
616616
if (RedPhiR)
617617
return false;
618-
if (CurRedPhiR->getRecurrenceKind() != RecurKind::FMaxNoFMFs ||
618+
if (CurRedPhiR->getRecurrenceKind() != RecurKind::FCmpOGTSelect ||
619619
CurRedPhiR->isInLoop() || CurRedPhiR->isOrdered())
620620
continue;
621621
RedPhiR = CurRedPhiR;

llvm/test/Transforms/LoopVectorize/ARM/mve-reduction-predselect.ll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -528,17 +528,17 @@ for.end: ; preds = %for.body, %entry
528528
define float @reduction_fmax(ptr nocapture %A, ptr nocapture %B) {
529529
; CHECK-LABEL: @reduction_fmax(
530530
; CHECK-NEXT: entry:
531-
; CHECK-NEXT: br label [[FOR_BODY1:%.*]]
531+
; CHECK-NEXT: br label [[FOR_BODY:%.*]]
532532
; CHECK: for.body:
533-
; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i32 [ [[INDVARS_IV_NEXT:%.*]], [[FOR_BODY1]] ], [ 0, [[ENTRY:%.*]] ]
534-
; CHECK-NEXT: [[RESULT_08:%.*]] = phi float [ [[V0:%.*]], [[FOR_BODY1]] ], [ 1.000000e+03, [[ENTRY]] ]
533+
; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i32 [ [[INDVARS_IV_NEXT:%.*]], [[FOR_BODY]] ], [ 0, [[ENTRY:%.*]] ]
534+
; CHECK-NEXT: [[RESULT_08:%.*]] = phi float [ [[V0:%.*]], [[FOR_BODY]] ], [ 1.000000e+03, [[ENTRY]] ]
535535
; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds float, ptr [[A:%.*]], i32 [[INDVARS_IV]]
536536
; CHECK-NEXT: [[L0:%.*]] = load float, ptr [[ARRAYIDX]], align 4
537537
; CHECK-NEXT: [[C0:%.*]] = fcmp ogt float [[RESULT_08]], [[L0]]
538538
; CHECK-NEXT: [[V0]] = select i1 [[C0]], float [[RESULT_08]], float [[L0]]
539539
; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add i32 [[INDVARS_IV]], 1
540540
; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i32 [[INDVARS_IV_NEXT]], 257
541-
; CHECK-NEXT: br i1 [[EXITCOND]], label [[FOR_END:%.*]], label [[FOR_BODY1]]
541+
; CHECK-NEXT: br i1 [[EXITCOND]], label [[FOR_END:%.*]], label [[FOR_BODY]]
542542
; CHECK: for.end:
543543
; CHECK-NEXT: ret float [[V0]]
544544
;

llvm/test/Transforms/LoopVectorize/ARM/mve-reduction-types.ll

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -952,19 +952,19 @@ define float @fmax_f32(ptr nocapture readonly %x, i32 %n) #0 {
952952
; CHECK-NEXT: [[CMP6:%.*]] = icmp sgt i32 [[N:%.*]], 0
953953
; CHECK-NEXT: br i1 [[CMP6]], label [[FOR_BODY_PREHEADER:%.*]], label [[FOR_COND_CLEANUP:%.*]]
954954
; CHECK: for.body.preheader:
955-
; CHECK-NEXT: br label [[FOR_BODY1:%.*]]
955+
; CHECK-NEXT: br label [[FOR_BODY:%.*]]
956956
; CHECK: for.body:
957-
; CHECK-NEXT: [[I_08:%.*]] = phi i32 [ [[INC:%.*]], [[FOR_BODY1]] ], [ 0, [[FOR_BODY_PREHEADER]] ]
958-
; CHECK-NEXT: [[R_07:%.*]] = phi float [ [[ADD:%.*]], [[FOR_BODY1]] ], [ 0.000000e+00, [[FOR_BODY_PREHEADER]] ]
957+
; CHECK-NEXT: [[I_08:%.*]] = phi i32 [ [[INC:%.*]], [[FOR_BODY]] ], [ 0, [[FOR_BODY_PREHEADER]] ]
958+
; CHECK-NEXT: [[R_07:%.*]] = phi float [ [[ADD:%.*]], [[FOR_BODY]] ], [ 0.000000e+00, [[FOR_BODY_PREHEADER]] ]
959959
; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds float, ptr [[X:%.*]], i32 [[I_08]]
960960
; CHECK-NEXT: [[TMP0:%.*]] = load float, ptr [[ARRAYIDX]], align 4
961961
; CHECK-NEXT: [[C:%.*]] = fcmp fast ugt float [[R_07]], [[TMP0]]
962962
; CHECK-NEXT: [[ADD]] = select i1 [[C]], float [[R_07]], float [[TMP0]]
963963
; CHECK-NEXT: [[INC]] = add nuw nsw i32 [[I_08]], 1
964964
; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i32 [[INC]], [[N]]
965-
; CHECK-NEXT: br i1 [[EXITCOND]], label [[FOR_COND_CLEANUP_LOOPEXIT:%.*]], label [[FOR_BODY1]]
965+
; CHECK-NEXT: br i1 [[EXITCOND]], label [[FOR_COND_CLEANUP_LOOPEXIT:%.*]], label [[FOR_BODY]]
966966
; CHECK: for.cond.cleanup.loopexit:
967-
; CHECK-NEXT: [[ADD_LCSSA:%.*]] = phi float [ [[ADD]], [[FOR_BODY1]] ]
967+
; CHECK-NEXT: [[ADD_LCSSA:%.*]] = phi float [ [[ADD]], [[FOR_BODY]] ]
968968
; CHECK-NEXT: br label [[FOR_COND_CLEANUP]]
969969
; CHECK: for.cond.cleanup:
970970
; CHECK-NEXT: [[R_0_LCSSA:%.*]] = phi float [ 0.000000e+00, [[ENTRY:%.*]] ], [ [[ADD_LCSSA]], [[FOR_COND_CLEANUP_LOOPEXIT]] ]

0 commit comments

Comments
 (0)