diff options
author | Nate Begeman <natebegeman@mac.com> | 2006-01-31 08:17:29 +0000 |
---|---|---|
committer | Nate Begeman <natebegeman@mac.com> | 2006-01-31 08:17:29 +0000 |
commit | a162f208ee05751ec9b3931f09f207cc0f6511a1 (patch) | |
tree | ab4b6dbc9f9771c517e83965f3e5e02f49c9fc86 /llvm/lib | |
parent | ac9892ccaf08ba1f7802db60ac732166e0a77856 (diff) | |
download | bcm5719-llvm-a162f208ee05751ec9b3931f09f207cc0f6511a1.tar.gz bcm5719-llvm-a162f208ee05751ec9b3931f09f207cc0f6511a1.zip |
Codegen
bool %test(int %X) {
%Y = seteq int %X, 13
ret bool %Y
}
as
_test:
addi r2, r3, -13
cntlzw r2, r2
srwi r3, r2, 5
blr
rather than
_test:
cmpwi cr7, r3, 13
mfcr r2
rlwinm r3, r2, 31, 31, 31
blr
This has very little effect on most code, but speeds up analyzer 23% and
mason 11%
llvm-svn: 25848
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Target/PowerPC/PPCISelLowering.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp index 3e8214a0574..c4f6be81af2 100644 --- a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp +++ b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp @@ -83,6 +83,9 @@ PPCTargetLowering::PPCTargetLowering(TargetMachine &TM) // PowerPC wants to turn select_cc of FP into fsel when possible. setOperationAction(ISD::SELECT_CC, MVT::f32, Custom); setOperationAction(ISD::SELECT_CC, MVT::f64, Custom); + + // PowerPC wants to optimize setcc i32, imm a bit. + setOperationAction(ISD::SETCC, MVT::i32, Custom); // PowerPC does not have BRCOND* which requires SetCC setOperationAction(ISD::BRCOND, MVT::Other, Expand); @@ -445,6 +448,19 @@ SDOperand PPCTargetLowering::LowerOperation(SDOperand Op, SelectionDAG &DAG) { // resolution stub. return DAG.getLoad(MVT::i32, DAG.getEntryNode(), Lo, DAG.getSrcValue(0)); } + case ISD::SETCC: { + ISD::CondCode CC = cast<CondCodeSDNode>(Op.getOperand(2))->get(); + if (ConstantSDNode *C = dyn_cast<ConstantSDNode>(Op.getOperand(1))) + if (C->getValue() && !C->isAllOnesValue()) + if (CC == ISD::SETEQ || CC == ISD::SETNE || + CC == ISD::SETLT || CC == ISD::SETGT) { + MVT::ValueType VT = Op.getValueType(); + SDOperand SUB = DAG.getNode(ISD::SUB, Op.getOperand(0).getValueType(), + Op.getOperand(0), Op.getOperand(1)); + return DAG.getSetCC(VT, SUB, DAG.getConstant(0, VT), CC); + } + break; + } case ISD::VASTART: { // vastart just stores the address of the VarArgsFrameIndex slot into the // memory location argument. |