aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/LoopUtils.cpp
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2021-01-26 10:25:36 -0500
committerSanjay Patel <spatel@rotateright.com>2021-01-26 11:22:51 -0500
commit09b1c56366b5a81d43013e7d5e739020f866c97f (patch)
treef43600f0a7dc781ff3c91db1fdfc48c78f4f2086 /llvm/lib/Transforms/Utils/LoopUtils.cpp
parent879c12d95a27a62797aede2f7d4f1886ad439d5d (diff)
downloadllvm-09b1c56366b5a81d43013e7d5e739020f866c97f.zip
llvm-09b1c56366b5a81d43013e7d5e739020f866c97f.tar.gz
llvm-09b1c56366b5a81d43013e7d5e739020f866c97f.tar.bz2
[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.
Diffstat (limited to 'llvm/lib/Transforms/Utils/LoopUtils.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/LoopUtils.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/llvm/lib/Transforms/Utils/LoopUtils.cpp b/llvm/lib/Transforms/Utils/LoopUtils.cpp
index 8d16792..f0f423e 100644
--- a/llvm/lib/Transforms/Utils/LoopUtils.cpp
+++ b/llvm/lib/Transforms/Utils/LoopUtils.cpp
@@ -920,27 +920,27 @@ bool llvm::hasIterationCountInvariantInParent(Loop *InnerLoop,
Value *llvm::createMinMaxOp(IRBuilderBase &Builder, RecurKind RK, Value *Left,
Value *Right) {
- CmpInst::Predicate P = CmpInst::ICMP_NE;
+ CmpInst::Predicate Pred;
switch (RK) {
default:
llvm_unreachable("Unknown min/max recurrence kind");
case RecurKind::UMin:
- P = CmpInst::ICMP_ULT;
+ Pred = CmpInst::ICMP_ULT;
break;
case RecurKind::UMax:
- P = CmpInst::ICMP_UGT;
+ Pred = CmpInst::ICMP_UGT;
break;
case RecurKind::SMin:
- P = CmpInst::ICMP_SLT;
+ Pred = CmpInst::ICMP_SLT;
break;
case RecurKind::SMax:
- P = CmpInst::ICMP_SGT;
+ Pred = CmpInst::ICMP_SGT;
break;
case RecurKind::FMin:
- P = CmpInst::FCMP_OLT;
+ Pred = CmpInst::FCMP_OLT;
break;
case RecurKind::FMax:
- P = CmpInst::FCMP_OGT;
+ Pred = CmpInst::FCMP_OGT;
break;
}
@@ -950,7 +950,7 @@ Value *llvm::createMinMaxOp(IRBuilderBase &Builder, RecurKind RK, Value *Left,
FastMathFlags FMF;
FMF.setFast();
Builder.setFastMathFlags(FMF);
- Value *Cmp = Builder.CreateCmp(P, Left, Right, "rdx.minmax.cmp");
+ Value *Cmp = Builder.CreateCmp(Pred, Left, Right, "rdx.minmax.cmp");
Value *Select = Builder.CreateSelect(Cmp, Left, Right, "rdx.minmax.select");
return Select;
}