Skip to content

Commit 5675396

Browse files
committed
!fixup try to make code a bit more compact, rename IVDesc kind.
1 parent 9d28282 commit 5675396

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
@@ -819,7 +819,7 @@ RecurrenceDescriptor::isMinMaxPattern(Instruction *I, RecurKind Kind,
819819
if (match(I, m_OrdOrUnordFMin(m_Value(), m_Value())))
820820
return InstDesc(Kind == RecurKind::FMin, I);
821821
if (match(I, m_OrdOrUnordFMax(m_Value(), m_Value())))
822-
return InstDesc(Kind == RecurKind::FMax || Kind == RecurKind::FMaxNoFMFs,
822+
return InstDesc(Kind == RecurKind::FMax || Kind == RecurKind::FCmpOGTSelect,
823823
I);
824824
if (match(I, m_FMinNum(m_Value(), m_Value())))
825825
return InstDesc(Kind == RecurKind::FMin, I);
@@ -947,9 +947,9 @@ RecurrenceDescriptor::InstDesc RecurrenceDescriptor::isRecurrenceInstr(
947947
if (isFPMinMaxRecurrenceKind(Kind)) {
948948
if (HasRequiredFMF())
949949
return isMinMaxPattern(I, Kind, Prev);
950-
if ((Kind == RecurKind::FMax || Kind == RecurKind::FMaxNoFMFs) &&
950+
if ((Kind == RecurKind::FMax || Kind == RecurKind::FCmpOGTSelect) &&
951951
isMinMaxPattern(I, Kind, Prev).isRecurrence())
952-
return InstDesc(I, RecurKind::FMaxNoFMFs);
952+
return InstDesc(I, RecurKind::FCmpOGTSelect);
953953
} else if (isFMulAddIntrinsic(I))
954954
return InstDesc(Kind == RecurKind::FMulAdd, I,
955955
I->hasAllowReassoc() ? nullptr : I);
@@ -1213,7 +1213,7 @@ unsigned RecurrenceDescriptor::getOpcode(RecurKind Kind) {
12131213
case RecurKind::UMin:
12141214
return Instruction::ICmp;
12151215
case RecurKind::FMax:
1216-
case RecurKind::FMaxNoFMFs:
1216+
case RecurKind::FCmpOGTSelect:
12171217
case RecurKind::FMin:
12181218
case RecurKind::FMaximum:
12191219
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
@@ -4348,10 +4348,8 @@ bool LoopVectorizationPlanner::isCandidateForEpilogueVectorization(
43484348
// currently unsupported.
43494349
if (any_of(OrigLoop->getHeader()->phis(), [&](PHINode &Phi) {
43504350
return Legal->isFixedOrderRecurrence(&Phi) ||
4351-
(Legal->isReductionVariable(&Phi) &&
4352-
Legal->getReductionVars()
4353-
.find(&Phi)
4354-
->second.getRecurrenceKind() == RecurKind::FMaxNoFMFs);
4351+
Legal->getReductionVars().lookup(&Phi).getRecurrenceKind() ==
4352+
RecurKind::FCmpOGTSelect;
43554353
}))
43564354
return false;
43574355

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23136,6 +23136,7 @@ class HorizontalReduction {
2313623136
case RecurKind::FindFirstIVUMin:
2313723137
case RecurKind::FindLastIVSMax:
2313823138
case RecurKind::FindLastIVUMax:
23139+
case RecurKind::FCmpOGTSelect:
2313923140
case RecurKind::FMaximumNum:
2314023141
case RecurKind::FMinimumNum:
2314123142
case RecurKind::None:
@@ -23273,6 +23274,7 @@ class HorizontalReduction {
2327323274
case RecurKind::FindFirstIVUMin:
2327423275
case RecurKind::FindLastIVSMax:
2327523276
case RecurKind::FindLastIVUMax:
23277+
case RecurKind::FCmpOGTSelect:
2327623278
case RecurKind::FMaximumNum:
2327723279
case RecurKind::FMinimumNum:
2327823280
case RecurKind::None:
@@ -23375,7 +23377,7 @@ class HorizontalReduction {
2337523377
case RecurKind::FindFirstIVUMin:
2337623378
case RecurKind::FindLastIVSMax:
2337723379
case RecurKind::FindLastIVUMax:
23378-
case RecurKind::FMaxNoFMFs:
23380+
case RecurKind::FCmpOGTSelect:
2337923381
case RecurKind::FMaximumNum:
2338023382
case RecurKind::FMinimumNum:
2338123383
case RecurKind::None:

llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp

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

638-
// Check if there are any FMaxNoFMFs reductions using wide selects that we can
639-
// fix up. To do so, we also need a wide canonical IV to keep track of the
640-
// indices of the max values.
638+
// Check if there are any FCmpOGTSelect reductions using wide selects that we
639+
// can fix up. To do so, we also need a wide canonical IV to keep track of
640+
// the indices of the max values.
641641
for (auto &R : LoopRegion->getEntryBasicBlock()->phis()) {
642642
// We need a wide canonical IV
643643
if (auto *CurIV = dyn_cast<VPWidenIntOrFpInductionRecipe>(&R)) {
@@ -647,14 +647,14 @@ bool VPlanTransforms::handleFMaxReductionsWithoutFastMath(VPlan &Plan) {
647647
continue;
648648
}
649649

650-
// And a single FMaxNoFMFs reduction phi.
650+
// And a single FCmpOGTSelect reduction phi.
651651
// TODO: Support FMin reductions as well.
652652
auto *CurRedPhiR = dyn_cast<VPReductionPHIRecipe>(&R);
653653
if (!CurRedPhiR)
654654
continue;
655655
if (RedPhiR)
656656
return false;
657-
if (CurRedPhiR->getRecurrenceKind() != RecurKind::FMaxNoFMFs ||
657+
if (CurRedPhiR->getRecurrenceKind() != RecurKind::FCmpOGTSelect ||
658658
CurRedPhiR->isInLoop() || CurRedPhiR->isOrdered())
659659
continue;
660660
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)