diff options
| author | Simon Pilgrim <llvm-dev@redking.me.uk> | 2014-12-04 09:44:01 +0000 | 
|---|---|---|
| committer | Simon Pilgrim <llvm-dev@redking.me.uk> | 2014-12-04 09:44:01 +0000 | 
| commit | be24ab367b0a9ccaa6c1e8653524ff81320deb33 (patch) | |
| tree | ad2269e1fe9234700a693d921e09cfa3a27f6d5f /llvm/lib/CodeGen/SelectionDAG | |
| parent | f1de34b84dea91b5060ee0fafbadaad5deaf199c (diff) | |
| download | bcm5719-llvm-be24ab367b0a9ccaa6c1e8653524ff81320deb33.tar.gz bcm5719-llvm-be24ab367b0a9ccaa6c1e8653524ff81320deb33.zip | |
[InstCombine] Minor optimization for bswap with binary ops
Added instcombine optimizations for BSWAP with AND/OR/XOR ops:
OP( BSWAP(x), BSWAP(y) ) -> BSWAP( OP(x, y) )
OP( BSWAP(x), CONSTANT ) -> BSWAP( OP(x, BSWAP(CONSTANT) ) )
Since its just a one liner, I've also added BSWAP to the DAGCombiner equivalent as well:
fold (OP (bswap x), (bswap y)) -> (bswap (OP x, y))
Refactored bswap-fold tests to use FileCheck instead of just checking that the bswaps had gone.
Differential Revision: http://reviews.llvm.org/D6407
llvm-svn: 223349
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG')
| -rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 2 | 
1 files changed, 2 insertions, 0 deletions
| diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index 7347111728e..cbae0559486 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -2526,6 +2526,7 @@ SDValue DAGCombiner::SimplifyBinOpWithSameOpcodeHands(SDNode *N) {    // 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)) +  // fold (OP (bswap x), (bswap y)) -> (bswap (OP x, y))    // fold (OP (trunc x), (trunc y)) -> (trunc (OP x, y)) (if trunc isn't free)    //    // do not sink logical op inside of a vector extend, since it may combine @@ -2533,6 +2534,7 @@ SDValue DAGCombiner::SimplifyBinOpWithSameOpcodeHands(SDNode *N) {    EVT Op0VT = N0.getOperand(0).getValueType();    if ((N0.getOpcode() == ISD::ZERO_EXTEND ||         N0.getOpcode() == ISD::SIGN_EXTEND || +       N0.getOpcode() == ISD::BSWAP ||         // Avoid infinite looping with PromoteIntBinOp.         (N0.getOpcode() == ISD::ANY_EXTEND &&          (!LegalTypes || TLI.isTypeDesirableForOp(N->getOpcode(), Op0VT))) || | 

