aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-01-08 06:25:56 +0000
committerChris Lattner <sabre@nondot.org>2005-01-08 06:25:56 +0000
commit5d2c6c784bdc3d572a553ed7aa48dcf27a45b1a3 (patch)
treed41703e4b2f93b2284ced6eab01b853dfab23e16
parent623f70dd4c5525888aca400c27832282913b539e (diff)
downloadexternal_llvm-5d2c6c784bdc3d572a553ed7aa48dcf27a45b1a3.zip
external_llvm-5d2c6c784bdc3d572a553ed7aa48dcf27a45b1a3.tar.gz
external_llvm-5d2c6c784bdc3d572a553ed7aa48dcf27a45b1a3.tar.bz2
Implement the 'store FPIMM, Ptr' -> 'store INTIMM, Ptr' optimization for
all targets. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19366 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/CodeGen/SelectionDAG/LegalizeDAG.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
index 996f116..4d6d0eb 100644
--- a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
+++ b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
@@ -424,6 +424,31 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) {
Tmp1 = LegalizeOp(Node->getOperand(0)); // Legalize the chain.
Tmp2 = LegalizeOp(Node->getOperand(2)); // Legalize the pointer.
+ // Turn 'store float 1.0, Ptr' -> 'store int 0x12345678, Ptr'
+ if (ConstantFPSDNode *CFP =
+ dyn_cast<ConstantFPSDNode>(Node->getOperand(1))) {
+ if (CFP->getValueType(0) == MVT::f32) {
+ union {
+ unsigned I;
+ float F;
+ } V;
+ V.F = CFP->getValue();
+ Result = DAG.getNode(ISD::STORE, MVT::Other, Tmp1,
+ DAG.getConstant(V.I, MVT::i32), Tmp2);
+ } else {
+ assert(CFP->getValueType(0) == MVT::f64 && "Unknown FP type!");
+ union {
+ uint64_t I;
+ double F;
+ } V;
+ V.F = CFP->getValue();
+ Result = DAG.getNode(ISD::STORE, MVT::Other, Tmp1,
+ DAG.getConstant(V.I, MVT::i64), Tmp2);
+ }
+ Op = Result;
+ Node = Op.Val;
+ }
+
switch (getTypeAction(Node->getOperand(1).getValueType())) {
case Legal: {
SDOperand Val = LegalizeOp(Node->getOperand(1));