diff options
author | Chris Lattner <sabre@nondot.org> | 2006-09-20 06:29:17 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2006-09-20 06:29:17 +0000 |
commit | 84750587bf859a048580f7f13b1b2710d0b681fb (patch) | |
tree | a9679b269f6d57f74ec55c76ea99a97790d4cb14 /lib/CodeGen/SelectionDAG/DAGCombiner.cpp | |
parent | 5f42a240ba5c6199d2d78fb1238938da2c073755 (diff) |
Fold the full generality of (any_extend (truncate x))
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30514 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/SelectionDAG/DAGCombiner.cpp')
-rw-r--r-- | lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index 4e3b572226..bcbac950f4 100644 --- a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -1858,9 +1858,15 @@ SDOperand DAGCombiner::visitANY_EXTEND(SDNode *N) { N0.getOpcode() == ISD::SIGN_EXTEND) return DAG.getNode(N0.getOpcode(), VT, N0.getOperand(0)); - // fold (aext (truncate x)) -> x iff x size == zext size. - if (N0.getOpcode() == ISD::TRUNCATE && N0.getOperand(0).getValueType() == VT) - return N0.getOperand(0); + // fold (aext (truncate x)) + if (N0.getOpcode() == ISD::TRUNCATE) { + SDOperand TruncOp = N0.getOperand(0); + if (TruncOp.getValueType() == VT) + return TruncOp; // x iff x size == zext size. + if (TruncOp.getValueType() > VT) + return DAG.getNode(ISD::TRUNCATE, VT, TruncOp); + return DAG.getNode(ISD::ANY_EXTEND, VT, TruncOp); + } // fold (aext (load x)) -> (aext (truncate (extload x))) if (N0.getOpcode() == ISD::LOAD && N0.hasOneUse() && (!AfterLegalize||TLI.isOperationLegal(ISD::EXTLOAD, N0.getValueType()))) { |