mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-14 11:32:34 +00:00
Fix bug: InstCombine/2005-05-07-UDivSelectCrash.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21152 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
b37246d65e
commit
bf70b838e7
@ -1068,23 +1068,25 @@ Instruction *InstCombiner::visitDiv(BinaryOperator &I) {
|
|||||||
I.setOperand(1, SFO);
|
I.setOperand(1, SFO);
|
||||||
return &I;
|
return &I;
|
||||||
} else if (SFO->getValue() == 0) {
|
} else if (SFO->getValue() == 0) {
|
||||||
I.setOperand(1, STO);
|
I.setOperand(2, STO);
|
||||||
return &I;
|
return &I;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uint64_t TSA = Log2(STO->getValue()))
|
uint64_t TVA = STO->getValue(), FVA = SFO->getValue();
|
||||||
if (uint64_t FSA = Log2(SFO->getValue())) {
|
unsigned TSA = 0, FSA = 0;
|
||||||
Constant *TC = ConstantUInt::get(Type::UByteTy, TSA);
|
if ((TVA == 1 || (TSA = Log2(TVA))) && // Log2 fails for 0 & 1.
|
||||||
Instruction *TSI = new ShiftInst(Instruction::Shr, Op0,
|
(FVA == 1 || (FSA = Log2(FVA)))) {
|
||||||
TC, SI->getName()+".t");
|
Constant *TC = ConstantUInt::get(Type::UByteTy, TSA);
|
||||||
TSI = InsertNewInstBefore(TSI, I);
|
Instruction *TSI = new ShiftInst(Instruction::Shr, Op0,
|
||||||
|
TC, SI->getName()+".t");
|
||||||
Constant *FC = ConstantUInt::get(Type::UByteTy, FSA);
|
TSI = InsertNewInstBefore(TSI, I);
|
||||||
Instruction *FSI = new ShiftInst(Instruction::Shr, Op0,
|
|
||||||
FC, SI->getName()+".f");
|
Constant *FC = ConstantUInt::get(Type::UByteTy, FSA);
|
||||||
FSI = InsertNewInstBefore(FSI, I);
|
Instruction *FSI = new ShiftInst(Instruction::Shr, Op0,
|
||||||
return new SelectInst(SI->getOperand(0), TSI, FSI);
|
FC, SI->getName()+".f");
|
||||||
}
|
FSI = InsertNewInstBefore(FSI, I);
|
||||||
|
return new SelectInst(SI->getOperand(0), TSI, FSI);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 0 / X == 0, we don't need to preserve faults!
|
// 0 / X == 0, we don't need to preserve faults!
|
||||||
|
Loading…
Reference in New Issue
Block a user