Skip to content

Commit 9f1d267

Browse files
rotaterightmemfrob
authored andcommitted
[LoopUtils] do not initialize Cmp predicate unnecessarily; NFC
The switch must set the predicate correctly; anything else should lead to unreachable/assert. I'm trying to fix FMF propagation here and the callers, so this is a preliminary cleanup.
1 parent 8728aeb commit 9f1d267

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

llvm/lib/Transforms/Utils/LoopUtils.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -920,27 +920,27 @@ bool llvm::hasIterationCountInvariantInParent(Loop *InnerLoop,
920920

921921
Value *llvm::createMinMaxOp(IRBuilderBase &Builder, RecurKind RK, Value *Left,
922922
Value *Right) {
923-
CmpInst::Predicate P = CmpInst::ICMP_NE;
923+
CmpInst::Predicate Pred;
924924
switch (RK) {
925925
default:
926926
llvm_unreachable("Unknown min/max recurrence kind");
927927
case RecurKind::UMin:
928-
P = CmpInst::ICMP_ULT;
928+
Pred = CmpInst::ICMP_ULT;
929929
break;
930930
case RecurKind::UMax:
931-
P = CmpInst::ICMP_UGT;
931+
Pred = CmpInst::ICMP_UGT;
932932
break;
933933
case RecurKind::SMin:
934-
P = CmpInst::ICMP_SLT;
934+
Pred = CmpInst::ICMP_SLT;
935935
break;
936936
case RecurKind::SMax:
937-
P = CmpInst::ICMP_SGT;
937+
Pred = CmpInst::ICMP_SGT;
938938
break;
939939
case RecurKind::FMin:
940-
P = CmpInst::FCMP_OLT;
940+
Pred = CmpInst::FCMP_OLT;
941941
break;
942942
case RecurKind::FMax:
943-
P = CmpInst::FCMP_OGT;
943+
Pred = CmpInst::FCMP_OGT;
944944
break;
945945
}
946946

@@ -950,7 +950,7 @@ Value *llvm::createMinMaxOp(IRBuilderBase &Builder, RecurKind RK, Value *Left,
950950
FastMathFlags FMF;
951951
FMF.setFast();
952952
Builder.setFastMathFlags(FMF);
953-
Value *Cmp = Builder.CreateCmp(P, Left, Right, "rdx.minmax.cmp");
953+
Value *Cmp = Builder.CreateCmp(Pred, Left, Right, "rdx.minmax.cmp");
954954
Value *Select = Builder.CreateSelect(Cmp, Left, Right, "rdx.minmax.select");
955955
return Select;
956956
}

0 commit comments

Comments
 (0)