diff options
author | Florian Hahn <florian.hahn@arm.com> | 2018-05-22 17:38:22 +0000 |
---|---|---|
committer | Florian Hahn <florian.hahn@arm.com> | 2018-05-22 17:38:22 +0000 |
commit | a6e63f176cdf2d7555938fcbb01781d29363feea (patch) | |
tree | 6743f63183d605fb8ec685fd51ec2a6210cc6ced /llvm/lib/Transforms | |
parent | 63eca15e95adb8e4049cd5b88eeaa37bd9175b6a (diff) | |
download | bcm5719-llvm-a6e63f176cdf2d7555938fcbb01781d29363feea.tar.gz bcm5719-llvm-a6e63f176cdf2d7555938fcbb01781d29363feea.zip |
[NewGVN] Fix handling of assumes
This patch fixes two bugs:
* test1: Previously assume(a >= 5) concluded that a == 5. That's only
valid for assume(a == 5)...
* test2: If operands were swapped, additional users were added to the
wrong cmp operand. This resulted in an "unsettled iteration"
assertion failure.
Patch by Nikita Popov
Differential Revision: https://reviews.llvm.org/D46974
llvm-svn: 333007
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/Scalar/NewGVN.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/Scalar/NewGVN.cpp b/llvm/lib/Transforms/Scalar/NewGVN.cpp index 0cf9979b40a..94973c986e9 100644 --- a/llvm/lib/Transforms/Scalar/NewGVN.cpp +++ b/llvm/lib/Transforms/Scalar/NewGVN.cpp @@ -1585,11 +1585,11 @@ NewGVN::performSymbolicPredicateInfoEvaluation(Instruction *I) const { SwappedOps ? Cmp->getSwappedPredicate() : Cmp->getPredicate(); if (isa<PredicateAssume>(PI)) { - // If the comparison is true when the operands are equal, then we know the - // operands are equal, because assumes must always be true. - if (CmpInst::isTrueWhenEqual(Predicate)) { + // If we assume the operands are equal, then they are equal. + if (Predicate == CmpInst::ICMP_EQ) { addPredicateUsers(PI, I); - addAdditionalUsers(Cmp->getOperand(0), I); + addAdditionalUsers(SwappedOps ? Cmp->getOperand(1) : Cmp->getOperand(0), + I); return createVariableOrConstant(FirstOp); } } |