mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-02-07 21:09:21 +00:00
Fix INT_MIN gotcha pointed out by Eli Friedman.
llvm-svn: 128028
This commit is contained in:
parent
bf35de8849
commit
e8f6eb49ee
@ -725,9 +725,10 @@ bool llvm::isPowerOfTwo(Value *V, const TargetData *TD, unsigned Depth) {
|
||||
isPowerOfTwo(SI->getFalseValue(), TD, Depth);
|
||||
|
||||
// An exact divide or right shift can only shift off zero bits, so the result
|
||||
// is a power of two only if the first operand is a power of two.
|
||||
if (match(V, m_Shr(m_Value(), m_Value())) ||
|
||||
match(V, m_IDiv(m_Value(), m_Value()))) {
|
||||
// is a power of two only if the first operand is a power of two and not
|
||||
// copying a sign bit (sdiv int_min, 2).
|
||||
if (match(V, m_LShr(m_Value(), m_Value())) ||
|
||||
match(V, m_UDiv(m_Value(), m_Value()))) {
|
||||
BinaryOperator *BO = cast<BinaryOperator>(V);
|
||||
if (BO->isExact())
|
||||
return isPowerOfTwo(BO->getOperand(0), TD, Depth);
|
||||
|
Loading…
x
Reference in New Issue
Block a user