[llvm] 0ee0c7d - [Indvars][NFC] Remove duplicating checks
Max Kazantsev via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 16 03:36:14 PDT 2020
Author: Max Kazantsev
Date: 2020-10-16T17:35:14+07:00
New Revision: 0ee0c7dcc3282b541befaaeaf8179abe1483370c
URL: https://github.com/llvm/llvm-project/commit/0ee0c7dcc3282b541befaaeaf8179abe1483370c
DIFF: https://github.com/llvm/llvm-project/commit/0ee0c7dcc3282b541befaaeaf8179abe1483370c.diff
LOG: [Indvars][NFC] Remove duplicating checks
Some facts have already been checked in widenWithVariantUse and then
checked again in widenWithVariantUseCodegen. The latter is redundant,
we can replace it with asserts.
Added:
Modified:
llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
index 602d1ec572cd..bd609344af87 100644
--- a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
+++ b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
@@ -1171,7 +1171,7 @@ void WidenIV::widenWithVariantUseCodegen(NarrowIVDefUse DU) {
Instruction *WideDef = DU.WideDef;
ExtendKind ExtKind = getExtendKind(NarrowDef);
-
+ assert(ExtKind != Unknown && "Unknown ExtKind not handled");
LLVM_DEBUG(dbgs() << "Cloning arithmetic IVUser: " << *NarrowUse << "\n");
// Generating a widening use instruction.
@@ -1190,24 +1190,20 @@ void WidenIV::widenWithVariantUseCodegen(NarrowIVDefUse DU) {
IRBuilder<> Builder(NarrowUse);
Builder.Insert(WideBO);
WideBO->copyIRFlags(NarrowBO);
-
- assert(ExtKind != Unknown && "Unknown ExtKind not handled");
-
ExtendKindMap[NarrowUse] = ExtKind;
for (Use &U : NarrowUse->uses()) {
Instruction *User = nullptr;
if (ExtKind == SignExtended)
- User = dyn_cast<SExtInst>(U.getUser());
+ User = cast<SExtInst>(U.getUser());
else
- User = dyn_cast<ZExtInst>(U.getUser());
- if (User && User->getType() == WideType) {
- LLVM_DEBUG(dbgs() << "INDVARS: eliminating " << *User << " replaced by "
- << *WideBO << "\n");
- ++NumElimExt;
- User->replaceAllUsesWith(WideBO);
- DeadInsts.emplace_back(User);
- }
+ User = cast<ZExtInst>(U.getUser());
+ assert(User->getType() == WideType && "Checked before!");
+ LLVM_DEBUG(dbgs() << "INDVARS: eliminating " << *User << " replaced by "
+ << *WideBO << "\n");
+ ++NumElimExt;
+ User->replaceAllUsesWith(WideBO);
+ DeadInsts.emplace_back(User);
}
}
More information about the llvm-commits
mailing list