[PATCH] D72652: [NFC][IndVarSimplify] remove duplicate code in widenWithVariantLoadUseCodegen
Zhongduo Lin (Jimmy) via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 13 14:22:02 PST 2020
zhongduo created this revision.
zhongduo added reviewers: az, sanjoy, sebpop, efriedma, javed.absar, sanjoy.google.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.
Duplicate code in widenWithVariantLoadUseCodegen is removed and also use assert to check unknown extension type as it should be filtered out by the pre condition check before calling this function.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D72652
Files:
llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
Index: llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
+++ llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
@@ -1508,33 +1508,22 @@
Builder.Insert(WideBO);
WideBO->copyIRFlags(NarrowBO);
- if (ExtKind == SignExtended)
- ExtendKindMap[NarrowUse] = SignExtended;
- else
- ExtendKindMap[NarrowUse] = ZeroExtended;
+ assert(ExtKind != Unknown && "Unknown ExtKind not handled");
- // Update the Use.
- if (ExtKind == SignExtended) {
- for (Use &U : NarrowUse->uses()) {
- SExtInst *User = dyn_cast<SExtInst>(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);
- }
- }
- } else { // ExtKind == ZeroExtended
- for (Use &U : NarrowUse->uses()) {
- ZExtInst *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);
- }
+ ExtendKindMap[NarrowUse] = ExtKind;
+
+ for (Use &U : NarrowUse->uses()) {
+ Instruction *User = nullptr;
+ if (ExtKind == SignExtended)
+ User = dyn_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);
}
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D72652.237781.patch
Type: text/x-patch
Size: 1929 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200113/4266391f/attachment.bin>
More information about the llvm-commits
mailing list