mirror of
https://github.com/RPCSX/llvm.git
synced 2025-02-25 23:45:36 +00:00
Fix a bug in my load/cast folding patch.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12849 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
13c07feb20
commit
9938286325
@ -2759,15 +2759,17 @@ void ISel::visitStoreInst(StoreInst &I) {
|
||||
void ISel::visitCastInst(CastInst &CI) {
|
||||
Value *Op = CI.getOperand(0);
|
||||
|
||||
// Noop casts are not even emitted.
|
||||
if (getClassB(CI.getType()) == getClassB(Op->getType()))
|
||||
unsigned SrcClass = getClassB(Op->getType());
|
||||
unsigned DestClass = getClassB(CI.getType());
|
||||
// Noop casts are not emitted: getReg will return the source operand as the
|
||||
// register to use for any uses of the noop cast.
|
||||
if (DestClass == SrcClass)
|
||||
return;
|
||||
|
||||
// If this is a cast from a 32-bit integer to a Long type, and the only uses
|
||||
// of the case are GEP instructions, then the cast does not need to be
|
||||
// generated explicitly, it will be folded into the GEP.
|
||||
if (CI.getType() == Type::LongTy &&
|
||||
(Op->getType() == Type::IntTy || Op->getType() == Type::UIntTy)) {
|
||||
if (DestClass == cLong && SrcClass == cInt) {
|
||||
bool AllUsesAreGEPs = true;
|
||||
for (Value::use_iterator I = CI.use_begin(), E = CI.use_end(); I != E; ++I)
|
||||
if (!isa<GetElementPtrInst>(*I)) {
|
||||
@ -2779,6 +2781,14 @@ void ISel::visitCastInst(CastInst &CI) {
|
||||
if (AllUsesAreGEPs) return;
|
||||
}
|
||||
|
||||
// If this cast converts a load from a short,int, or long integer to a FP
|
||||
// value, we will have folded this cast away.
|
||||
if (DestClass == cFP && isa<LoadInst>(Op) && Op->hasOneUse() &&
|
||||
(Op->getType() == Type::ShortTy || Op->getType() == Type::IntTy ||
|
||||
Op->getType() == Type::LongTy))
|
||||
return;
|
||||
|
||||
|
||||
unsigned DestReg = getReg(CI);
|
||||
MachineBasicBlock::iterator MI = BB->end();
|
||||
emitCastOperation(BB, MI, Op, CI.getType(), DestReg);
|
||||
@ -2794,14 +2804,6 @@ void ISel::emitCastOperation(MachineBasicBlock *BB,
|
||||
const Type *SrcTy = Src->getType();
|
||||
unsigned SrcClass = getClassB(SrcTy);
|
||||
unsigned DestClass = getClassB(DestTy);
|
||||
|
||||
// If this cast converts a load from a short,int, or long integer to a FP
|
||||
// value, we will have folded this cast away.
|
||||
if (DestClass == cFP && isa<LoadInst>(Src) &&
|
||||
(Src->getType() == Type::ShortTy || Src->getType() == Type::IntTy ||
|
||||
Src->getType() == Type::LongTy))
|
||||
return;
|
||||
|
||||
unsigned SrcReg = getReg(Src, BB, IP);
|
||||
|
||||
// Implement casts to bool by using compare on the operand followed by set if
|
||||
|
@ -2759,15 +2759,17 @@ void ISel::visitStoreInst(StoreInst &I) {
|
||||
void ISel::visitCastInst(CastInst &CI) {
|
||||
Value *Op = CI.getOperand(0);
|
||||
|
||||
// Noop casts are not even emitted.
|
||||
if (getClassB(CI.getType()) == getClassB(Op->getType()))
|
||||
unsigned SrcClass = getClassB(Op->getType());
|
||||
unsigned DestClass = getClassB(CI.getType());
|
||||
// Noop casts are not emitted: getReg will return the source operand as the
|
||||
// register to use for any uses of the noop cast.
|
||||
if (DestClass == SrcClass)
|
||||
return;
|
||||
|
||||
// If this is a cast from a 32-bit integer to a Long type, and the only uses
|
||||
// of the case are GEP instructions, then the cast does not need to be
|
||||
// generated explicitly, it will be folded into the GEP.
|
||||
if (CI.getType() == Type::LongTy &&
|
||||
(Op->getType() == Type::IntTy || Op->getType() == Type::UIntTy)) {
|
||||
if (DestClass == cLong && SrcClass == cInt) {
|
||||
bool AllUsesAreGEPs = true;
|
||||
for (Value::use_iterator I = CI.use_begin(), E = CI.use_end(); I != E; ++I)
|
||||
if (!isa<GetElementPtrInst>(*I)) {
|
||||
@ -2779,6 +2781,14 @@ void ISel::visitCastInst(CastInst &CI) {
|
||||
if (AllUsesAreGEPs) return;
|
||||
}
|
||||
|
||||
// If this cast converts a load from a short,int, or long integer to a FP
|
||||
// value, we will have folded this cast away.
|
||||
if (DestClass == cFP && isa<LoadInst>(Op) && Op->hasOneUse() &&
|
||||
(Op->getType() == Type::ShortTy || Op->getType() == Type::IntTy ||
|
||||
Op->getType() == Type::LongTy))
|
||||
return;
|
||||
|
||||
|
||||
unsigned DestReg = getReg(CI);
|
||||
MachineBasicBlock::iterator MI = BB->end();
|
||||
emitCastOperation(BB, MI, Op, CI.getType(), DestReg);
|
||||
@ -2794,14 +2804,6 @@ void ISel::emitCastOperation(MachineBasicBlock *BB,
|
||||
const Type *SrcTy = Src->getType();
|
||||
unsigned SrcClass = getClassB(SrcTy);
|
||||
unsigned DestClass = getClassB(DestTy);
|
||||
|
||||
// If this cast converts a load from a short,int, or long integer to a FP
|
||||
// value, we will have folded this cast away.
|
||||
if (DestClass == cFP && isa<LoadInst>(Src) &&
|
||||
(Src->getType() == Type::ShortTy || Src->getType() == Type::IntTy ||
|
||||
Src->getType() == Type::LongTy))
|
||||
return;
|
||||
|
||||
unsigned SrcReg = getReg(Src, BB, IP);
|
||||
|
||||
// Implement casts to bool by using compare on the operand followed by set if
|
||||
|
Loading…
x
Reference in New Issue
Block a user