LI can only take signed values, so values > 32767 can only be loaded with ORI

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15299 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Misha Brukman 2004-07-28 00:56:04 +00:00
parent b9b8ba58e7
commit 8b29776d68
2 changed files with 14 additions and 2 deletions

View File

@ -555,7 +555,13 @@ void ISel::copyConstantToRegister(MachineBasicBlock *MBB,
BuildMI(*MBB, IP, PPC32::ORI, 2, R+1).addReg(Temp).addImm(Val & 0xFFFF);
} else if (Val < (1ULL << 48)) {
unsigned Temp = makeAnotherReg(Type::IntTy);
BuildMI(*MBB, IP, PPC32::LI, 1, R).addSImm((Val >> 32) & 0xFFFF);
int HiBits = (Val >> 32) & 0xFFFF;
if (HiBits > 32767) {
BuildMI(*MBB, IP, PPC32::LI, 1, PPC32::R0).addImm(0);
BuildMI(*MBB, IP, PPC32::ORI, 2, R).addReg(PPC32::R0).addSImm(HiBits);
} else {
BuildMI(*MBB, IP, PPC32::LI, 1, R).addSImm(HiBits);
}
BuildMI(*MBB, IP, PPC32::LIS, 1, Temp).addSImm((Val >> 16) & 0xFFFF);
BuildMI(*MBB, IP, PPC32::ORI, 2, R+1).addReg(Temp).addImm(Val & 0xFFFF);
} else {

View File

@ -555,7 +555,13 @@ void ISel::copyConstantToRegister(MachineBasicBlock *MBB,
BuildMI(*MBB, IP, PPC32::ORI, 2, R+1).addReg(Temp).addImm(Val & 0xFFFF);
} else if (Val < (1ULL << 48)) {
unsigned Temp = makeAnotherReg(Type::IntTy);
BuildMI(*MBB, IP, PPC32::LI, 1, R).addSImm((Val >> 32) & 0xFFFF);
int HiBits = (Val >> 32) & 0xFFFF;
if (HiBits > 32767) {
BuildMI(*MBB, IP, PPC32::LI, 1, PPC32::R0).addImm(0);
BuildMI(*MBB, IP, PPC32::ORI, 2, R).addReg(PPC32::R0).addSImm(HiBits);
} else {
BuildMI(*MBB, IP, PPC32::LI, 1, R).addSImm(HiBits);
}
BuildMI(*MBB, IP, PPC32::LIS, 1, Temp).addSImm((Val >> 16) & 0xFFFF);
BuildMI(*MBB, IP, PPC32::ORI, 2, R+1).addReg(Temp).addImm(Val & 0xFFFF);
} else {