[llvm-commits] CVS: llvm/lib/Target/X86/X86ISelSimple.cpp
Chris Lattner
lattner at cs.uiuc.edu
Fri Jan 7 21:45:36 PST 2005
Changes in directory llvm/lib/Target/X86:
X86ISelSimple.cpp updated: 1.305 -> 1.306
---
Log message:
The X86 instruction selector already handles codegen of:
store float 123.45, float* %P
as an integer store. This adds handling of float immediate stores as integers
for arguments passed function calls.
This is now tested by CodeGen/X86/store-fp-constant.ll
---
Diffs of the changes: (+33 -8)
Index: llvm/lib/Target/X86/X86ISelSimple.cpp
diff -u llvm/lib/Target/X86/X86ISelSimple.cpp:1.305 llvm/lib/Target/X86/X86ISelSimple.cpp:1.306
--- llvm/lib/Target/X86/X86ISelSimple.cpp:1.305 Thu Jan 6 15:19:16 2005
+++ llvm/lib/Target/X86/X86ISelSimple.cpp Fri Jan 7 23:45:24 2005
@@ -1631,15 +1631,40 @@
break;
case cFP:
- ArgReg = Args[i].Val ? getReg(Args[i].Val) : Args[i].Reg;
- if (Args[i].Ty == Type::FloatTy) {
- addRegOffset(BuildMI(BB, X86::FST32m, 5),
- X86::ESP, ArgOffset).addReg(ArgReg);
+ if (ConstantFP *CFP = dyn_cast_or_null<ConstantFP>(Args[i].Val)) {
+ // 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();
+ addRegOffset(BuildMI(BB, X86::MOV32mi, 5),
+ X86::ESP, ArgOffset).addImm(V.I);
+ } else {
+ union {
+ uint64_t I;
+ double F;
+ } V;
+ V.F = CFP->getValue();
+ addRegOffset(BuildMI(BB, X86::MOV32mi, 5),
+ X86::ESP, ArgOffset).addImm((unsigned)V.I);
+ addRegOffset(BuildMI(BB, X86::MOV32mi, 5),
+ X86::ESP, ArgOffset+4).addImm(unsigned(V.I >> 32));
+ ArgOffset += 4; // 8 byte entry, not 4.
+ }
} else {
- assert(Args[i].Ty == Type::DoubleTy && "Unknown FP type!");
- addRegOffset(BuildMI(BB, X86::FST64m, 5),
- X86::ESP, ArgOffset).addReg(ArgReg);
- ArgOffset += 4; // 8 byte entry, not 4.
+ ArgReg = Args[i].Val ? getReg(Args[i].Val) : Args[i].Reg;
+ if (Args[i].Ty == Type::FloatTy) {
+ addRegOffset(BuildMI(BB, X86::FST32m, 5),
+ X86::ESP, ArgOffset).addReg(ArgReg);
+ } else {
+ assert(Args[i].Ty == Type::DoubleTy && "Unknown FP type!");
+ addRegOffset(BuildMI(BB, X86::FST64m, 5),
+ X86::ESP, ArgOffset).addReg(ArgReg);
+ ArgOffset += 4; // 8 byte entry, not 4.
+ }
}
break;
More information about the llvm-commits
mailing list