diff options
author | Max Kazantsev <mkazantsev@azul.com> | 2020-11-12 12:01:12 +0700 |
---|---|---|
committer | Max Kazantsev <mkazantsev@azul.com> | 2020-11-12 12:02:01 +0700 |
commit | d6dd9385893e034c7c3561e5d47dc5cf3bce4552 (patch) | |
tree | 510ac5c42b9fd7d8203c0cee550942bd07343216 /llvm/lib/Transforms/Utils/SimplifyIndVar.cpp | |
parent | 8bc7b9278e55c4c8c731e7600a2d146438697964 (diff) | |
download | llvm-d6dd9385893e034c7c3561e5d47dc5cf3bce4552.zip llvm-d6dd9385893e034c7c3561e5d47dc5cf3bce4552.tar.gz llvm-d6dd9385893e034c7c3561e5d47dc5cf3bce4552.tar.bz2 |
[IndVars] IV user should not prevent use widening
Sometimes the an instruction we are trying to widen is used by the IV
(which means the instruction is the IV increment). Currently this may
prevent its widening. We should ignore such user because it will be
dead once the transform is done anyways.
Differential Revision: https://reviews.llvm.org/D90920
Reviewed By: fhahn
Diffstat (limited to 'llvm/lib/Transforms/Utils/SimplifyIndVar.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/SimplifyIndVar.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp b/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp index c7c0815..8e2fa03e 100644 --- a/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp @@ -1566,7 +1566,11 @@ bool WidenIV::widenWithVariantUse(WidenIV::NarrowIVDefUse DU) { if (!AddRecOp1 || AddRecOp1->getLoop() != L) return false; + // Check that all uses are either s/zext, or narrow def (in case of we are + // widening the IV increment). for (Use &U : NarrowUse->uses()) { + if (U.getUser() == NarrowDef) + continue; Instruction *User = nullptr; if (ExtKind == SignExtended) User = dyn_cast<SExtInst>(U.getUser()); @@ -1597,6 +1601,9 @@ bool WidenIV::widenWithVariantUse(WidenIV::NarrowIVDefUse DU) { ExtendKindMap[NarrowUse] = ExtKind; for (Use &U : NarrowUse->uses()) { + // Ignore narrow def: it will be removed after the transform. + if (U.getUser() == NarrowDef) + continue; Instruction *User = nullptr; if (ExtKind == SignExtended) User = cast<SExtInst>(U.getUser()); |