diff options
author | Chris Lattner <sabre@nondot.org> | 2006-09-21 06:40:43 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2006-09-21 06:40:43 +0000 |
commit | 0e4b922680f55a8e28fc2c3db0b80a1c78d24918 (patch) | |
tree | 223b52a0c0bead21b609ab93581a54843d449aa8 /lib/CodeGen | |
parent | bf3708794f4dca6e959247a3fe7cbe0cb5348eeb (diff) |
fold (aext (and (trunc x), cst)) -> (and x, cst).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30561 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r-- | lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index 64014dcb05..f093bf46f6 100644 --- a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -1897,6 +1897,21 @@ SDOperand DAGCombiner::visitANY_EXTEND(SDNode *N) { return DAG.getNode(ISD::TRUNCATE, VT, TruncOp); return DAG.getNode(ISD::ANY_EXTEND, VT, TruncOp); } + + // fold (aext (and (trunc x), cst)) -> (and x, cst). + if (N0.getOpcode() == ISD::AND && + N0.getOperand(0).getOpcode() == ISD::TRUNCATE && + N0.getOperand(1).getOpcode() == ISD::Constant) { + SDOperand X = N0.getOperand(0).getOperand(0); + if (X.getValueType() < VT) { + X = DAG.getNode(ISD::ANY_EXTEND, VT, X); + } else if (X.getValueType() > VT) { + X = DAG.getNode(ISD::TRUNCATE, VT, X); + } + uint64_t Mask = cast<ConstantSDNode>(N0.getOperand(1))->getValue(); + return DAG.getNode(ISD::AND, VT, X, DAG.getConstant(Mask, VT)); + } + // fold (aext (load x)) -> (aext (truncate (extload x))) if (N0.getOpcode() == ISD::LOAD && N0.hasOneUse() && (!AfterLegalize||TLI.isOperationLegal(ISD::EXTLOAD, N0.getValueType()))) { |