Fold the full generality of (any_extend (truncate x))

llvm-svn: 30514
This commit is contained in:
Chris Lattner 2006-09-20 06:29:17 +00:00
parent 8b68decb27
commit 8746e2cd57
1 changed files with 9 additions and 3 deletions

View File

@ -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()))) {