summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-12-23 05:37:50 +0000
committerChris Lattner <sabre@nondot.org>2005-12-23 05:37:50 +0000
commitefbbedbf4a1eb6890fb8e529aabcfc05025ec080 (patch)
tree19e7793c4c572fef529ad14f829b0182e466eaf2 /llvm/lib/CodeGen
parenta18746055282076c04086559d1aa9746978ca343 (diff)
downloadbcm5719-llvm-efbbedbf4a1eb6890fb8e529aabcfc05025ec080.tar.gz
bcm5719-llvm-efbbedbf4a1eb6890fb8e529aabcfc05025ec080.zip
Fold bitconv(bitconv(x)) -> x. We now compile this:
void foo(double); void bar(double X) { foo(X); } to this: bar: save -96, %o6, %o6 or %g0, %i0, %o0 or %g0, %i1, %o1 call foo nop restore %g0, %g0, %g0 retl nop instead of this: bar: save -112, %o6, %o6 st %i1, [%i6+-4] st %i0, [%i6+-8] ldd [%i6+-8], %f0 std %f0, [%i6+-16] ld [%i6+-12], %o1 ld [%i6+-16], %o0 call foo nop restore %g0, %g0, %g0 retl nop on V8. llvm-svn: 24981
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp3
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp2
2 files changed, 5 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index ad26719dca8..e4f5125e798 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -1757,6 +1757,9 @@ SDOperand DAGCombiner::visitBIT_CONVERT(SDNode *N) {
if (Res.Val != N) return Res;
}
+ if (N0.getOpcode() == ISD::BIT_CONVERT) // conv(conv(x,t1),t2) -> conv(x,t2)
+ return DAG.getNode(ISD::BIT_CONVERT, VT, N0.getOperand(0));
+
return SDOperand();
}
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index 76d983f57e8..b510f1cd959 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -916,6 +916,8 @@ SDOperand SelectionDAG::getNode(unsigned Opcode, MVT::ValueType VT,
assert(MVT::getSizeInBits(VT)==MVT::getSizeInBits(Operand.getValueType()) &&
"Cannot BIT_CONVERT between two different types!");
if (VT == Operand.getValueType()) return Operand; // noop conversion.
+ if (OpOpcode == ISD::BIT_CONVERT) // bitconv(bitconv(x)) -> bitconv(x)
+ return getNode(ISD::BIT_CONVERT, VT, Operand.getOperand(0));
break;
case ISD::FNEG:
if (OpOpcode == ISD::FSUB) // -(X-Y) -> (Y-X)
OpenPOWER on IntegriCloud