[llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp

Chris Lattner lattner at cs.uiuc.edu
Sun Aug 21 18:04:43 PDT 2005



Changes in directory llvm/lib/CodeGen/SelectionDAG:

ScheduleDAG.cpp updated: 1.11 -> 1.12
---
Log message:

Add a fast-path for register values.  Add support for constant pool entries,
allowing us to compile this:

float %test2(float* %P) {
        %Q = load float* %P
        %R = add float %Q, 10.1
        ret float %R
}

to this:

_test2:
        lfs r2, 0(r3)
        lis r3, ha16(.CPI_test2_0)
        lfs r3, lo16(.CPI_test2_0)(r3)
        fadds f1, r2, r3
        blr



---
Diffs of the changes:  (+13 -1)

 ScheduleDAG.cpp |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletion(-)


Index: llvm/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp:1.11 llvm/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp:1.12
--- llvm/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp:1.11	Sun Aug 21 14:56:04 2005
+++ llvm/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp	Sun Aug 21 20:04:32 2005
@@ -111,7 +111,16 @@
     // Emit all of the operands of this instruction, adding them to the
     // instruction as appropriate.
     for (unsigned i = 0, e = Op.getNumOperands(); i != e; ++i) {
-      if (ConstantSDNode *C = dyn_cast<ConstantSDNode>(Op.getOperand(i))) {
+      if (Op.getOperand(i).isTargetOpcode()) {
+        // Note that this case is redundant with the final else block, but we
+        // include it because it is the most common and it makes the logic
+        // simpler here.
+        unsigned R = Emit(Op.getOperand(i));
+        // Add an operand, unless this corresponds to a chain node.
+        if (Op.getOperand(i).getValueType() != MVT::Other)
+          MI->addRegOperand(R, MachineOperand::Use);
+      } else if (ConstantSDNode *C =
+                                   dyn_cast<ConstantSDNode>(Op.getOperand(i))) {
         MI->addZeroExtImm64Operand(C->getValue());
       } else if (RegisterSDNode*R =dyn_cast<RegisterSDNode>(Op.getOperand(i))) {
         MI->addRegOperand(R->getReg(), MachineOperand::Use);
@@ -124,6 +133,9 @@
       } else if (FrameIndexSDNode *FI =
                        dyn_cast<FrameIndexSDNode>(Op.getOperand(i))) {
         MI->addFrameIndexOperand(FI->getIndex());
+      } else if (ConstantPoolSDNode *CP = 
+                    dyn_cast<ConstantPoolSDNode>(Op.getOperand(i))) {
+        MI->addConstantPoolIndexOperand(CP->getIndex());
       } else {
         unsigned R = Emit(Op.getOperand(i));
         // Add an operand, unless this corresponds to a chain node.






More information about the llvm-commits mailing list