Skip to content

Commit

Permalink
[ValueTracking] Use switch for Intrinsics in isKnownToBePowerOfTwo;…
Browse files Browse the repository at this point in the history
… NFC

Differential Revision: https://reviews.llvm.org/D157305
  • Loading branch information
goldsteinn committed Aug 9, 2023
1 parent bab8058 commit 03b529a
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions llvm/lib/Analysis/ValueTracking.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 03b529a

Please sign in to comment.