[llvm] 03b529a - [ValueTracking] Use switch for Intrinsics in `isKnownToBePowerOfTwo`; NFC
Noah Goldstein via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 9 12:45:43 PDT 2023
Author: Noah Goldstein
Date: 2023-08-09T14:42:54-05:00
New Revision: 03b529a2a6ca685be6244b52232d1dae4f02c6a5
URL: https://github.com/llvm/llvm-project/commit/03b529a2a6ca685be6244b52232d1dae4f02c6a5
DIFF: https://github.com/llvm/llvm-project/commit/03b529a2a6ca685be6244b52232d1dae4f02c6a5.diff
LOG: [ValueTracking] Use switch for Intrinsics in `isKnownToBePowerOfTwo`; NFC
Differential Revision: https://reviews.llvm.org/D157305
Added:
Modified:
llvm/lib/Analysis/ValueTracking.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index 794c1100a017be..2cdfbdfb825f53 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -2122,11 +2122,20 @@ bool isKnownToBeAPowerOfTwo(const Value *V, bool OrZero, unsigned Depth,
return isKnownToBeAPowerOfTwo(U.get(), OrZero, NewDepth, RecQ);
});
}
+ case Instruction::Invoke:
case Instruction::Call: {
- Value *X, *Y;
- if (match(I, m_MaxOrMin(m_Value(X), m_Value(Y))))
- return isKnownToBeAPowerOfTwo(X, OrZero, Depth, Q) &&
- isKnownToBeAPowerOfTwo(Y, OrZero, Depth, Q);
+ if (auto *II = dyn_cast<IntrinsicInst>(I)) {
+ switch (II->getIntrinsicID()) {
+ case Intrinsic::umax:
+ case Intrinsic::smax:
+ case Intrinsic::umin:
+ case Intrinsic::smin:
+ return isKnownToBeAPowerOfTwo(II->getArgOperand(1), OrZero, Depth, Q) &&
+ isKnownToBeAPowerOfTwo(II->getArgOperand(0), OrZero, Depth, Q);
+ default:
+ break;
+ }
+ }
return false;
}
default:
More information about the llvm-commits
mailing list