forked from OSchip/llvm-project
[NFC][IndVarSimplify] remove duplicate code in widenWithVariantLoadUseCodegen.
Summary: 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. Reviewers: az, sanjoy, sebpop, efriedma, javed.absar, sanjoy.google Reviewed By: efriedma Subscribers: hiraditya, llvm-commits, amehsan Tags: #llvm Differential Revision: https://reviews.llvm.org/D72652
This commit is contained in:
parent
b72a8c65e4
commit
34ba96a3d4
|
@ -1508,33 +1508,22 @@ void WidenIV::widenWithVariantLoadUseCodegen(NarrowIVDefUse DU) {
|
|||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue