No test case, undefined shifts get folded early, but can occur when other
transforms generate a constant. Thanks to Duncan for bringing this up.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162755
91177308-0d34-0410-b5e6-
96231b3b80d8
Value *X;
ConstantInt *C1;
if (match(Op0, m_LShr(m_Value(X), m_ConstantInt(C1)))) {
- APInt NC = C2->getValue().shl(C1->getZExtValue());
+ APInt NC = C2->getValue().shl(C1->getLimitedValue(C1->getBitWidth()-1));
return BinaryOperator::CreateUDiv(X, Builder->getInt(NC));
}
}
Value *X;
ConstantInt *C1;
if (match(Op0, m_AShr(m_Value(X), m_ConstantInt(C1)))) {
- APInt NC = C2->getValue().shl(C1->getZExtValue());
+ APInt NC = C2->getValue().shl(C1->getLimitedValue(C1->getBitWidth()-1));
return BinaryOperator::CreateSDiv(X, Builder->getInt(NC));
}
}