Codegen floating point stores of constants into integer instructions. This

allows us to compile:

store float 10.0, float* %P

into:
        mov DWORD PTR [%EAX], 1092616192

instead of:

.CPItest_0:                                     # float 0x4024000000000000
.long   1092616192      # float 10
...
        fld DWORD PTR [.CPItest_0]
        fstp DWORD PTR [%EAX]

llvm-svn: 13409
This commit is contained in:
Chris Lattner 2004-05-07 21:18:15 +00:00
parent 1edc9637d0
commit a2dc6bf6e6
1 changed files with 37 additions and 15 deletions

View File

@ -2879,8 +2879,31 @@ void ISel::visitStoreInst(StoreInst &I) {
} else if (ConstantBool *CB = dyn_cast<ConstantBool>(I.getOperand(0))) {
addFullAddress(BuildMI(BB, X86::MOV8mi, 5),
BaseReg, Scale, IndexReg, Disp).addImm(CB->getValue());
} else if (ConstantFP *CFP = dyn_cast<ConstantFP>(I.getOperand(0))) {
// Store constant FP values with integer instructions to avoid having to
// load the constants from the constant pool then do a store.
if (CFP->getType() == Type::FloatTy) {
union {
unsigned I;
float F;
} V;
V.F = CFP->getValue();
addFullAddress(BuildMI(BB, X86::MOV32mi, 5),
BaseReg, Scale, IndexReg, Disp).addImm(V.I);
} else {
if (Class == cLong) {
union {
uint64_t I;
double F;
} V;
V.F = CFP->getValue();
addFullAddress(BuildMI(BB, X86::MOV32mi, 5),
BaseReg, Scale, IndexReg, Disp).addImm((unsigned)V.I);
addFullAddress(BuildMI(BB, X86::MOV32mi, 5),
BaseReg, Scale, IndexReg, Disp+4).addImm(
unsigned(V.I >> 32));
}
} else if (Class == cLong) {
unsigned ValReg = getReg(I.getOperand(0));
addFullAddress(BuildMI(BB, X86::MOV32mr, 5),
BaseReg, Scale, IndexReg, Disp).addReg(ValReg);
@ -2897,7 +2920,6 @@ void ISel::visitStoreInst(StoreInst &I) {
BaseReg, Scale, IndexReg, Disp).addReg(ValReg);
}
}
}
/// visitCastInst - Here we have various kinds of copying with or without sign