[llvm-commits] CVS: llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
Chris Lattner
lattner at cs.uiuc.edu
Mon Mar 20 14:38:34 PST 2006
Changes in directory llvm/lib/Target/PowerPC:
PPCISelDAGToDAG.cpp updated: 1.172 -> 1.173
---
Log message:
Handle constant addresses more efficiently, folding the low bits into the
disp field of the load/store if possible. This compiles
CodeGen/PowerPC/load-constant-addr.ll to:
_test:
lis r2, 2838
lfs f1, 26848(r2)
blr
instead of:
_test:
lis r2, 2838
ori r2, r2, 26848
lfs f1, 0(r2)
blr
---
Diffs of the changes: (+17 -0)
PPCISelDAGToDAG.cpp | 17 +++++++++++++++++
1 files changed, 17 insertions(+)
Index: llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
diff -u llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp:1.172 llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp:1.173
--- llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp:1.172 Mon Mar 20 11:54:43 2006
+++ llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp Mon Mar 20 16:38:22 2006
@@ -535,7 +535,24 @@
return true;
}
}
+ } else if (ConstantSDNode *CN = dyn_cast<ConstantSDNode>(N)) {
+ // Loading from a constant address.
+ int Addr = (int)CN->getValue();
+
+ // If this address fits entirely in a 16-bit sext immediate field, codegen
+ // this as "d, 0"
+ if (Addr == (short)Addr) {
+ Disp = getI32Imm(Addr);
+ Base = CurDAG->getRegister(PPC::R0, MVT::i32);
+ return true;
+ }
+
+ // Otherwise, break this down into an LIS + disp.
+ Disp = getI32Imm((short)Addr);
+ Base = CurDAG->getConstant(Addr - (signed short)Addr, MVT::i32);
+ return true;
}
+
Disp = getI32Imm(0);
if (FrameIndexSDNode *FI = dyn_cast<FrameIndexSDNode>(N))
Base = CurDAG->getTargetFrameIndex(FI->getIndex(), MVT::i32);
More information about the llvm-commits
mailing list