mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-03 13:31:05 +00:00
ValueTracking: Make isSafeToSpeculativelyExecute a little cleaner
No functional change intended. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@227760 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
3bafb64914
commit
9e8b7214ed
@ -2620,20 +2620,20 @@ bool llvm::isSafeToSpeculativelyExecute(const Value *V,
|
||||
case Instruction::SDiv:
|
||||
case Instruction::SRem: {
|
||||
// x / y is undefined if y == 0 or x == INT_MIN and y == -1
|
||||
const APInt *X, *Y;
|
||||
if (match(Inst->getOperand(1), m_APInt(Y))) {
|
||||
if (*Y != 0) {
|
||||
if (*Y == -1) {
|
||||
// The numerator can't be MinSignedValue if the denominator is -1.
|
||||
if (match(Inst->getOperand(0), m_APInt(X)))
|
||||
return !Y->isMinSignedValue();
|
||||
// The numerator *might* be MinSignedValue.
|
||||
return false;
|
||||
}
|
||||
// The denominator is not 0 or -1, it's safe to proceed.
|
||||
return true;
|
||||
}
|
||||
}
|
||||
const APInt *Numerator, *Denominator;
|
||||
if (!match(Inst->getOperand(1), m_APInt(Denominator)))
|
||||
return false;
|
||||
// We cannot hoist this division if the denominator is 0.
|
||||
if (*Denominator == 0)
|
||||
return false;
|
||||
// It's safe to hoist if the denominator is not 0 or -1.
|
||||
if (*Denominator != -1)
|
||||
return true;
|
||||
// At this point we know that the denominator is -1. It is safe to hoist as
|
||||
// long we know that the numerator is not INT_MIN.
|
||||
if (match(Inst->getOperand(0), m_APInt(Numerator)))
|
||||
return !Numerator->isMinSignedValue();
|
||||
// The numerator *might* be MinSignedValue.
|
||||
return false;
|
||||
}
|
||||
case Instruction::Load: {
|
||||
|
Loading…
Reference in New Issue
Block a user