aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/ValueTracking.cpp
diff options
context:
space:
mode:
authorNoah Goldstein <goldstein.w.n@gmail.com>2024-04-03 15:35:17 -0500
committerNoah Goldstein <goldstein.w.n@gmail.com>2024-04-10 10:40:48 -0500
commit37ca6fa1e26e86c85c544023b18695be420e80dd (patch)
tree6692288e5afe5d6e511404aa0df4fd6cfc8f5d66 /llvm/lib/Analysis/ValueTracking.cpp
parentf0a487d7e2085e21f3691393070f54110d889fb6 (diff)
downloadllvm-37ca6fa1e26e86c85c544023b18695be420e80dd.zip
llvm-37ca6fa1e26e86c85c544023b18695be420e80dd.tar.gz
llvm-37ca6fa1e26e86c85c544023b18695be420e80dd.tar.bz2
[ValueTracking] Add support for overflow detection functions is `isKnownNonZero`
Adds support for: `{s,u}{add,sub,mul}.with.overflow` The logic is identical to the the non-overflow binops, we where just missing the cases. Closes #87701
Diffstat (limited to 'llvm/lib/Analysis/ValueTracking.cpp')
-rw-r--r--llvm/lib/Analysis/ValueTracking.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index 2c9ea8a..b32dc49 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -2798,6 +2798,29 @@ static bool isKnownNonZeroFromOperator(const Operator *I,
// handled in isKnownNonZero.
return false;
}
+ case Instruction::ExtractValue: {
+ const WithOverflowInst *WO;
+ if (match(I, m_ExtractValue<0>(m_WithOverflowInst(WO)))) {
+ switch (WO->getBinaryOp()) {
+ default:
+ break;
+ case Instruction::Add:
+ return isNonZeroAdd(DemandedElts, Depth, Q, BitWidth,
+ WO->getArgOperand(0), WO->getArgOperand(1),
+ /*NSW=*/false,
+ /*NUW=*/false);
+ case Instruction::Sub:
+ return isNonZeroSub(DemandedElts, Depth, Q, BitWidth,
+ WO->getArgOperand(0), WO->getArgOperand(1));
+ case Instruction::Mul:
+ return isNonZeroMul(DemandedElts, Depth, Q, BitWidth,
+ WO->getArgOperand(0), WO->getArgOperand(1),
+ /*NSW=*/false, /*NUW=*/false);
+ break;
+ }
+ }
+ break;
+ }
case Instruction::Call:
case Instruction::Invoke: {
const auto *Call = cast<CallBase>(I);