mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2026-04-26 12:20:42 +00:00
InstCombine: Don't turn -(x/INT_MIN) -> x/INT_MIN
It is not safe to negate the smallest signed integer, doing so yields the same number back. This fixes PR20186. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212164 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -107,6 +107,28 @@ bool Constant::isAllOnesValue() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Constant::isMinSignedValue() const {
|
||||
// Check for INT_MIN integers
|
||||
if (const ConstantInt *CI = dyn_cast<ConstantInt>(this))
|
||||
return CI->isMinValue(/*isSigned=*/true);
|
||||
|
||||
// Check for FP which are bitcasted from INT_MIN integers
|
||||
if (const ConstantFP *CFP = dyn_cast<ConstantFP>(this))
|
||||
return CFP->getValueAPF().bitcastToAPInt().isMinSignedValue();
|
||||
|
||||
// Check for constant vectors which are splats of INT_MIN values.
|
||||
if (const ConstantVector *CV = dyn_cast<ConstantVector>(this))
|
||||
if (Constant *Splat = CV->getSplatValue())
|
||||
return Splat->isMinSignedValue();
|
||||
|
||||
// Check for constant vectors which are splats of INT_MIN values.
|
||||
if (const ConstantDataVector *CV = dyn_cast<ConstantDataVector>(this))
|
||||
if (Constant *Splat = CV->getSplatValue())
|
||||
return Splat->isMinSignedValue();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Constructor to create a '0' constant of arbitrary type...
|
||||
Constant *Constant::getNullValue(Type *Ty) {
|
||||
switch (Ty->getTypeID()) {
|
||||
|
||||
Reference in New Issue
Block a user