diff options
author | Chris Lattner <sabre@nondot.org> | 2005-04-11 20:29:59 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2005-04-11 20:29:59 +0000 |
commit | 8ffd00492091353bd28e24c2393f858e382aa6ec (patch) | |
tree | ed673a5a0cf9e944ccd7e1a16cdd066f8df799f7 /llvm/lib/CodeGen | |
parent | edd197062f31d66dec0e5ce669fd59624ad59690 (diff) | |
download | bcm5719-llvm-8ffd00492091353bd28e24c2393f858e382aa6ec.tar.gz bcm5719-llvm-8ffd00492091353bd28e24c2393f858e382aa6ec.zip |
Teach the dag mechanism that this:
long long test2(unsigned A, unsigned B) {
return ((unsigned long long)A << 32) + B;
}
is equivalent to this:
long long test1(unsigned A, unsigned B) {
return ((unsigned long long)A << 32) | B;
}
Now they are both codegen'd to this on ppc:
_test2:
blr
or this on x86:
test2:
movl 4(%esp), %edx
movl 8(%esp), %eax
ret
llvm-svn: 21231
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp index e4213171724..a9329cf8769 100644 --- a/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp @@ -1443,8 +1443,27 @@ ExpandByParts(unsigned NodeOp, SDOperand LHS, SDOperand RHS, ExpandOp(LHS, LHSL, LHSH); ExpandOp(RHS, RHSL, RHSH); - // Convert this add to the appropriate ADDC pair. The low part has no carry - // in. + // FIXME: this should be moved to the dag combiner someday. + if (NodeOp == ISD::ADD_PARTS || NodeOp == ISD::SUB_PARTS) + if (LHSL.getValueType() == MVT::i32) { + SDOperand LowEl; + if (ConstantSDNode *C = dyn_cast<ConstantSDNode>(LHSL)) + if (C->getValue() == 0) + LowEl = RHSL; + if (ConstantSDNode *C = dyn_cast<ConstantSDNode>(RHSL)) + if (C->getValue() == 0) + LowEl = LHSL; + if (LowEl.Val) { + // Turn this into an add/sub of the high part only. + SDOperand HiEl = + DAG.getNode(NodeOp == ISD::ADD_PARTS ? ISD::ADD : ISD::SUB, + LowEl.getValueType(), LHSH, RHSH); + Lo = LowEl; + Hi = HiEl; + return; + } + } + std::vector<SDOperand> Ops; Ops.push_back(LHSL); Ops.push_back(LHSH); |