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 | 8acb3100de9cfc02048b7ab23490134ed735b051 (patch) | |
tree | f519c95bb090e29b707f78cb8ac4b01e45e0477f /lib | |
parent | 9682043ab55e43679442458ad6f39283d4ed9d1d (diff) | |
download | external_llvm-8acb3100de9cfc02048b7ab23490134ed735b051.zip external_llvm-8acb3100de9cfc02048b7ab23490134ed735b051.tar.gz external_llvm-8acb3100de9cfc02048b7ab23490134ed735b051.tar.bz2 |
Fold (zext (and x, cst)) -> (and (zext x), cst).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91380 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index 52b7ed5..bec5241 100644 --- a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/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()) || |