diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2020-07-11 22:48:26 +0200 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2020-07-13 21:10:11 +0200 |
commit | 353fa4403a06c2d86d617362b42e20ee6b3f53be (patch) | |
tree | 8b5651b150839db86fdbf9cb75496e78f3406368 /llvm/lib/Transforms/Utils/PredicateInfo.cpp | |
parent | 4b626dd94944d60751af62d65a2692698520fcc2 (diff) | |
download | llvm-353fa4403a06c2d86d617362b42e20ee6b3f53be.zip llvm-353fa4403a06c2d86d617362b42e20ee6b3f53be.tar.gz llvm-353fa4403a06c2d86d617362b42e20ee6b3f53be.tar.bz2 |
[PredicateInfo] Place predicate info after assume
Place the ssa.copy instructions for assumes after the assume,
instead of before it. Both options are valid, but placing them
afterwards prevents assumes from being replaced with assume(true).
This fixes https://bugs.llvm.org/show_bug.cgi?id=37541 in NewGVN
and will avoid a similar issue in SCCP when we handle more
predicate infos.
Differential Revision: https://reviews.llvm.org/D83631
Diffstat (limited to 'llvm/lib/Transforms/Utils/PredicateInfo.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/PredicateInfo.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/Utils/PredicateInfo.cpp b/llvm/lib/Transforms/Utils/PredicateInfo.cpp index c81efd7..6ac2d64 100644 --- a/llvm/lib/Transforms/Utils/PredicateInfo.cpp +++ b/llvm/lib/Transforms/Utils/PredicateInfo.cpp @@ -205,14 +205,14 @@ struct ValueDFS_Compare { // numbering will say the placed predicaeinfos should go first (IE // LN_beginning), so we won't be in this function. For assumes, we will end // up here, beause we need to order the def we will place relative to the - // assume. So for the purpose of ordering, we pretend the def is the assume - // because that is where we will insert the info. + // assume. So for the purpose of ordering, we pretend the def is right + // after the assume, because that is where we will insert the info. if (!VD.U) { assert(VD.PInfo && "No def, no use, and no predicateinfo should not occur"); assert(isa<PredicateAssume>(VD.PInfo) && "Middle of block should only occur for assumes"); - return cast<PredicateAssume>(VD.PInfo)->AssumeInst; + return cast<PredicateAssume>(VD.PInfo)->AssumeInst->getNextNode(); } return nullptr; } @@ -621,7 +621,9 @@ Value *PredicateInfoBuilder::materializeStack(unsigned int &Counter, auto *PAssume = dyn_cast<PredicateAssume>(ValInfo); assert(PAssume && "Should not have gotten here without it being an assume"); - IRBuilder<> B(PAssume->AssumeInst); + // Insert the predicate directly after the assume. While it also holds + // directly before it, assume(i1 true) is not a useful fact. + IRBuilder<> B(PAssume->AssumeInst->getNextNode()); Function *IF = getCopyDeclaration(F.getParent(), Op->getType()); if (IF->users().empty()) PI.CreatedDeclarations.insert(IF); |