mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-04-12 12:33:17 +00:00
Get rid of shifts by zero in most cases.
llvm-svn: 18931
This commit is contained in:
parent
cc0adb0271
commit
83dcf14697
@ -55,13 +55,6 @@ To-do
|
|||||||
* support casting 64-bit integers to FP types (fhourstones needs this)
|
* support casting 64-bit integers to FP types (fhourstones needs this)
|
||||||
* support FP rem (call fmod)
|
* support FP rem (call fmod)
|
||||||
|
|
||||||
* Eliminate srl/sll by zero bits like this:
|
|
||||||
sll %l0, 0, %l0
|
|
||||||
srl %l0, 0, %o0
|
|
||||||
|
|
||||||
We think these are only used by V9 to clear off the top 32 bits of a reg,
|
|
||||||
so they are not needed.
|
|
||||||
|
|
||||||
* Keep the address of the constant pool in a register instead of forming its
|
* Keep the address of the constant pool in a register instead of forming its
|
||||||
address all of the time.
|
address all of the time.
|
||||||
|
|
||||||
|
@ -71,7 +71,8 @@ namespace {
|
|||||||
unsigned emitIntegerCast (MachineBasicBlock *BB,
|
unsigned emitIntegerCast (MachineBasicBlock *BB,
|
||||||
MachineBasicBlock::iterator IP,
|
MachineBasicBlock::iterator IP,
|
||||||
const Type *oldTy, unsigned SrcReg,
|
const Type *oldTy, unsigned SrcReg,
|
||||||
const Type *newTy, unsigned DestReg);
|
const Type *newTy, unsigned DestReg,
|
||||||
|
bool castToLong = false);
|
||||||
void emitFPToIntegerCast (MachineBasicBlock *BB,
|
void emitFPToIntegerCast (MachineBasicBlock *BB,
|
||||||
MachineBasicBlock::iterator IP, const Type *oldTy,
|
MachineBasicBlock::iterator IP, const Type *oldTy,
|
||||||
unsigned SrcReg, const Type *newTy,
|
unsigned SrcReg, const Type *newTy,
|
||||||
@ -606,15 +607,15 @@ void V8ISel::visitCastInst(CastInst &I) {
|
|||||||
unsigned V8ISel::emitIntegerCast (MachineBasicBlock *BB,
|
unsigned V8ISel::emitIntegerCast (MachineBasicBlock *BB,
|
||||||
MachineBasicBlock::iterator IP, const Type *oldTy,
|
MachineBasicBlock::iterator IP, const Type *oldTy,
|
||||||
unsigned SrcReg, const Type *newTy,
|
unsigned SrcReg, const Type *newTy,
|
||||||
unsigned DestReg) {
|
unsigned DestReg, bool castToLong) {
|
||||||
if (oldTy == newTy) {
|
unsigned shiftWidth = 32 - (8 * TM.getTargetData ().getTypeSize (newTy));
|
||||||
|
if (oldTy == newTy || (!castToLong && shiftWidth == 0)) {
|
||||||
// No-op cast - just emit a copy; assume the reg. allocator will zap it.
|
// No-op cast - just emit a copy; assume the reg. allocator will zap it.
|
||||||
BuildMI (*BB, IP, V8::ORrr, 2, DestReg).addReg (V8::G0).addReg(SrcReg);
|
BuildMI (*BB, IP, V8::ORrr, 2, DestReg).addReg (V8::G0).addReg(SrcReg);
|
||||||
return SrcReg;
|
return SrcReg;
|
||||||
}
|
}
|
||||||
// Emit left-shift, then right-shift to sign- or zero-extend.
|
// Emit left-shift, then right-shift to sign- or zero-extend.
|
||||||
unsigned TmpReg = makeAnotherReg (newTy);
|
unsigned TmpReg = makeAnotherReg (newTy);
|
||||||
unsigned shiftWidth = 32 - (8 * TM.getTargetData ().getTypeSize (newTy));
|
|
||||||
BuildMI (*BB, IP, V8::SLLri, 2, TmpReg).addZImm (shiftWidth).addReg(SrcReg);
|
BuildMI (*BB, IP, V8::SLLri, 2, TmpReg).addZImm (shiftWidth).addReg(SrcReg);
|
||||||
if (newTy->isSigned ()) { // sign-extend with SRA
|
if (newTy->isSigned ()) { // sign-extend with SRA
|
||||||
BuildMI(*BB, IP, V8::SRAri, 2, DestReg).addZImm (shiftWidth).addReg(TmpReg);
|
BuildMI(*BB, IP, V8::SRAri, 2, DestReg).addZImm (shiftWidth).addReg(TmpReg);
|
||||||
@ -739,7 +740,7 @@ void V8ISel::emitCastOperation(MachineBasicBlock *BB,
|
|||||||
const Type *OldHalfTy = oldTy->isSigned() ? Type::IntTy : Type::UIntTy;
|
const Type *OldHalfTy = oldTy->isSigned() ? Type::IntTy : Type::UIntTy;
|
||||||
const Type *NewHalfTy = newTy->isSigned() ? Type::IntTy : Type::UIntTy;
|
const Type *NewHalfTy = newTy->isSigned() ? Type::IntTy : Type::UIntTy;
|
||||||
unsigned TempReg = emitIntegerCast (BB, IP, OldHalfTy, SrcReg,
|
unsigned TempReg = emitIntegerCast (BB, IP, OldHalfTy, SrcReg,
|
||||||
NewHalfTy, DestReg+1);
|
NewHalfTy, DestReg+1, true);
|
||||||
if (newTy->isSigned ()) {
|
if (newTy->isSigned ()) {
|
||||||
BuildMI (*BB, IP, V8::SRAri, 2, DestReg).addReg (TempReg)
|
BuildMI (*BB, IP, V8::SRAri, 2, DestReg).addReg (TempReg)
|
||||||
.addZImm (31);
|
.addZImm (31);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user