[llvm-commits] CVS: llvm/lib/Target/PowerPC/PPC32ISelDAGToDAG.cpp
Chris Lattner
lattner at cs.uiuc.edu
Thu Aug 25 10:50:17 PDT 2005
Changes in directory llvm/lib/Target/PowerPC:
PPC32ISelDAGToDAG.cpp updated: 1.29 -> 1.30
---
Log message:
Add support for sdiv by 2^k and -2^k. Producing code like:
_test:
srawi r2, r3, 2
addze r3, r2
blr
---
Diffs of the changes: (+27 -1)
PPC32ISelDAGToDAG.cpp | 28 +++++++++++++++++++++++++++-
1 files changed, 27 insertions(+), 1 deletion(-)
Index: llvm/lib/Target/PowerPC/PPC32ISelDAGToDAG.cpp
diff -u llvm/lib/Target/PowerPC/PPC32ISelDAGToDAG.cpp:1.29 llvm/lib/Target/PowerPC/PPC32ISelDAGToDAG.cpp:1.30
--- llvm/lib/Target/PowerPC/PPC32ISelDAGToDAG.cpp:1.29 Thu Aug 25 00:04:11 2005
+++ llvm/lib/Target/PowerPC/PPC32ISelDAGToDAG.cpp Thu Aug 25 12:50:06 2005
@@ -695,10 +695,36 @@
case MVT::f32: Opc = PPC::FMULS; break;
case MVT::f64: Opc = PPC::FMUL; break;
}
- CurDAG->SelectNodeTo(N, N->getValueType(0), Opc, Select(N->getOperand(0)),
+ CurDAG->SelectNodeTo(N, MVT::i32, Opc, Select(N->getOperand(0)),
Select(N->getOperand(1)));
break;
}
+ case ISD::SDIV: {
+ unsigned Imm;
+ if (isIntImmediate(N->getOperand(1), Imm)) {
+ if ((signed)Imm > 0 && isPowerOf2_32(Imm)) {
+ SDOperand Op =
+ CurDAG->getTargetNode(PPC::SRAWI, MVT::i32, MVT::Flag,
+ Select(N->getOperand(0)),
+ getI32Imm(Log2_32(Imm)));
+ CurDAG->SelectNodeTo(N, MVT::i32, PPC::ADDZE,
+ Op.getValue(0), Op.getValue(1));
+ break;
+ } else if ((signed)Imm < 0 && isPowerOf2_32(-Imm)) {
+ SDOperand Op =
+ CurDAG->getTargetNode(PPC::SRAWI, MVT::Flag, MVT::i32,
+ Select(N->getOperand(0)),
+ getI32Imm(Log2_32(-Imm)));
+ SDOperand PT =
+ CurDAG->getTargetNode(PPC::ADDZE, MVT::i32, Op.getValue(1),
+ Op.getValue(0));
+ CurDAG->SelectNodeTo(N, MVT::i32, PPC::NEG, PT);
+ break;
+ }
+ }
+ assert(0 && "SDIV not implemented yet!");
+ abort();
+ }
case ISD::MULHS:
assert(N->getValueType(0) == MVT::i32);
CurDAG->SelectNodeTo(N, MVT::i32, PPC::MULHW, Select(N->getOperand(0)),
More information about the llvm-commits
mailing list