diff options
author | Chris Lattner <sabre@nondot.org> | 2006-05-05 06:31:05 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2006-05-05 06:31:05 +0000 |
commit | 540121f1ec6495445aab87ff464b170c0b762d05 (patch) | |
tree | df2606dc143d912466efa2d82909daa9bc61647c /lib/CodeGen | |
parent | a3dc3f692c2967dc9cfac6344c7216f62098feda (diff) | |
download | llvm-540121f1ec6495445aab87ff464b170c0b762d05.tar.gz llvm-540121f1ec6495445aab87ff464b170c0b762d05.tar.bz2 llvm-540121f1ec6495445aab87ff464b170c0b762d05.tar.xz |
Implement:
// fold (and (sext x), (sext y)) -> (sext (and x, y))
// fold (or (sext x), (sext y)) -> (sext (or x, y))
// fold (xor (sext x), (sext y)) -> (sext (xor x, y))
// fold (and (aext x), (aext y)) -> (aext (and x, y))
// fold (or (aext x), (aext y)) -> (aext (or x, y))
// fold (xor (aext x), (aext y)) -> (aext (xor x, y))
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28123 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r-- | lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index 12c5d40e09..3294b4ca58 100644 --- a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -1045,16 +1045,18 @@ SDOperand DAGCombiner::SimplifyBinOpWithSameOpcodeHands(SDNode *N) { MVT::ValueType VT = N0.getValueType(); assert(N0.getOpcode() == N1.getOpcode() && "Bad input!"); - // fold (and (zext x), (zext y)) -> (zext (and x, y)) - // fold (or (zext x), (zext y)) -> (zext (or x, y)) - // fold (xor (zext x), (zext y)) -> (zext (xor x, y)) - if (N0.getOpcode() == ISD::ZERO_EXTEND && + // For each of OP in AND/OR/XOR: + // fold (OP (zext x), (zext y)) -> (zext (OP x, y)) + // fold (OP (sext x), (sext y)) -> (sext (OP x, y)) + // fold (OP (aext x), (aext y)) -> (aext (OP x, y)) + if ((N0.getOpcode() == ISD::ZERO_EXTEND || N0.getOpcode() == ISD::ANY_EXTEND|| + N0.getOpcode() == ISD::SIGN_EXTEND) && N0.getOperand(0).getValueType() == N1.getOperand(0).getValueType()) { SDOperand ORNode = DAG.getNode(N->getOpcode(), N0.getOperand(0).getValueType(), N0.getOperand(0), N1.getOperand(0)); AddToWorkList(ORNode.Val); - return DAG.getNode(ISD::ZERO_EXTEND, VT, ORNode); + return DAG.getNode(N0.getOpcode(), VT, ORNode); } // fold (and (trunc x), (trunc y)) -> (trunc (and x, y)) |