diff options
author | Evan Cheng <evan.cheng@apple.com> | 2009-12-15 00:52:11 +0000 |
---|---|---|
committer | Evan Cheng <evan.cheng@apple.com> | 2009-12-15 00:52:11 +0000 |
commit | d1521ef40ce3e1241c8faa0dc4253e05ea45bc62 (patch) | |
tree | e249661709f54b7384c1d33b825948c57b0585fd /llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | |
parent | 1542d735d99caf54a21b6094bd74e1c0c0c08613 (diff) | |
download | bcm5719-llvm-d1521ef40ce3e1241c8faa0dc4253e05ea45bc62.tar.gz bcm5719-llvm-d1521ef40ce3e1241c8faa0dc4253e05ea45bc62.zip |
Fold (zext (and x, cst)) -> (and (zext x), cst).
llvm-svn: 91380
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index 52b7ed5f158..bec5241ea92 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -3202,6 +3202,19 @@ SDValue DAGCombiner::visitZERO_EXTEND(SDNode *N) { X, DAG.getConstant(Mask, VT)); } + // Fold (zext (and x, cst)) -> (and (zext x), cst) + if (N0.getOpcode() == ISD::AND && + N0.getOperand(1).getOpcode() == ISD::Constant && + N0.getOperand(0).getOpcode() != ISD::TRUNCATE && + N0.getOperand(0).hasOneUse()) { + APInt Mask = cast<ConstantSDNode>(N0.getOperand(1))->getAPIntValue(); + Mask.zext(VT.getSizeInBits()); + return DAG.getNode(ISD::AND, N->getDebugLoc(), VT, + DAG.getNode(ISD::ZERO_EXTEND, N->getDebugLoc(), VT, + N0.getOperand(0)), + DAG.getConstant(Mask, VT)); + } + // fold (zext (load x)) -> (zext (truncate (zextload x))) if (ISD::isNON_EXTLoad(N0.getNode()) && ((!LegalOperations && !cast<LoadSDNode>(N0)->isVolatile()) || |