aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/ValueTracking.cpp
diff options
context:
space:
mode:
authorPhilip Reames <listmail@philipreames.com>2021-04-05 19:21:38 -0700
committerPhilip Reames <listmail@philipreames.com>2021-04-05 19:22:36 -0700
commit13deb6aac723e5694d404f21ee136e9773eb27a6 (patch)
tree8121f759f8d8c389dd2fe8aae087fbf5b833c463 /llvm/lib/Analysis/ValueTracking.cpp
parent812ce7f9beb2b828032ddbd01d3aba4c1f9d76da (diff)
downloadllvm-13deb6aac723e5694d404f21ee136e9773eb27a6.zip
llvm-13deb6aac723e5694d404f21ee136e9773eb27a6.tar.gz
llvm-13deb6aac723e5694d404f21ee136e9773eb27a6.tar.bz2
Exact ashr/lshr don't loose any set bits and are thus trivially invertible
Use that fact to improve isKnownNonEqual.
Diffstat (limited to 'llvm/lib/Analysis/ValueTracking.cpp')
-rw-r--r--llvm/lib/Analysis/ValueTracking.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index 93c628b..4732a1f 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -2588,6 +2588,17 @@ static Optional<unsigned> getInvertibleOperand(const Operator *Op1,
return 0;
break;
}
+ case Instruction::AShr:
+ case Instruction::LShr: {
+ auto *PEO1 = cast<PossiblyExactOperator>(Op1);
+ auto *PEO2 = cast<PossiblyExactOperator>(Op2);
+ if (!PEO1->isExact() || !PEO2->isExact())
+ break;
+
+ if (Op1->getOperand(1) == Op2->getOperand(1))
+ return 0;
+ break;
+ }
case Instruction::SExt:
case Instruction::ZExt:
if (Op1->getOperand(0)->getType() == Op2->getOperand(0)->getType())