diff options
author | Max Kazantsev <mkazantsev@azul.com> | 2021-03-19 14:03:31 +0700 |
---|---|---|
committer | Max Kazantsev <mkazantsev@azul.com> | 2021-03-19 14:03:31 +0700 |
commit | 8eefa07fcfe7b5d4d5827c071e494ecb78c7815c (patch) | |
tree | e017b1fa3018ecfef0a93d40489bed22ef454b0e | |
parent | 8bb952b57fac8b9a37dc132f94df7adc697b10bb (diff) | |
download | llvm-8eefa07fcfe7b5d4d5827c071e494ecb78c7815c.zip llvm-8eefa07fcfe7b5d4d5827c071e494ecb78c7815c.tar.gz llvm-8eefa07fcfe7b5d4d5827c071e494ecb78c7815c.tar.bz2 |
[NFC] Move function up in code
-rw-r--r-- | llvm/lib/Transforms/Utils/SimplifyIndVar.cpp | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp b/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp index 5381411..f0e4466 100644 --- a/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp @@ -99,6 +99,24 @@ namespace { }; } +/// Find a point in code which dominates all given instructions. We can safely +/// assume that, whatever fact we can prove at the found point, this fact is +/// also true for each of the given instructions. +static Instruction *findCommonDominator(ArrayRef<Instruction *> Instructions, + DominatorTree &DT) { + Instruction *CommonDom = nullptr; + for (auto *Insn : Instructions) + if (!CommonDom || DT.dominates(Insn, CommonDom)) + CommonDom = Insn; + else if (!DT.dominates(CommonDom, Insn)) + // If there is no dominance relation, use common dominator. + CommonDom = + DT.findNearestCommonDominator(CommonDom->getParent(), + Insn->getParent())->getTerminator(); + assert(CommonDom && "Common dominator not found?"); + return CommonDom; +} + /// Fold an IV operand into its use. This removes increments of an /// aligned IV when used by a instruction that ignores the low bits. /// @@ -1477,24 +1495,6 @@ bool WidenIV::widenLoopCompare(WidenIV::NarrowIVDefUse DU) { return true; } -/// Find a point in code which dominates all given instructions. We can safely -/// assume that, whatever fact we can prove at the found point, this fact is -/// also true for each of the given instructions. -static Instruction *findCommonDominator(ArrayRef<Instruction *> Instructions, - DominatorTree &DT) { - Instruction *CommonDom = nullptr; - for (auto *Insn : Instructions) - if (!CommonDom || DT.dominates(Insn, CommonDom)) - CommonDom = Insn; - else if (!DT.dominates(CommonDom, Insn)) - // If there is no dominance relation, use common dominator. - CommonDom = - DT.findNearestCommonDominator(CommonDom->getParent(), - Insn->getParent())->getTerminator(); - assert(CommonDom && "Common dominator not found?"); - return CommonDom; -} - // The widenIVUse avoids generating trunc by evaluating the use as AddRec, this // will not work when: // 1) SCEV traces back to an instruction inside the loop that SCEV can not |