diff options
author | Ayman Musa <ayman.musa@intel.com> | 2016-09-13 09:12:45 +0000 |
---|---|---|
committer | Ayman Musa <ayman.musa@intel.com> | 2016-09-13 09:12:45 +0000 |
commit | 0c2da88f82acd9f32557d30cd90b77153f87d7c4 (patch) | |
tree | 84d2170e1e636af24af37643039bee7d462bbba1 /llvm/lib/CodeGen | |
parent | acb6b35b566e6558cef7bfc1d3c19943786c01c9 (diff) | |
download | bcm5719-llvm-0c2da88f82acd9f32557d30cd90b77153f87d7c4.tar.gz bcm5719-llvm-0c2da88f82acd9f32557d30cd90b77153f87d7c4.zip |
Remove MVT:i1 xor instruction before SELECT. (Performance improvement).
Differential Revision: https://reviews.llvm.org/D23764
llvm-svn: 281308
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index 73faff2f582..d1727a15ea0 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -5258,6 +5258,22 @@ SDValue DAGCombiner::visitSELECT(SDNode *N) { } } + // select (xor Cond, 1), X, Y -> select Cond, Y, X + // select (xor Cond, 0), X, Y -> selext Cond, X, Y + if (VT0 == MVT::i1) { + if (N0->getOpcode() == ISD::XOR) { + if (auto *C = dyn_cast<ConstantSDNode>(N0->getOperand(1))) { + SDValue Cond0 = N0->getOperand(0); + if (C->isOne()) + return DAG.getNode(ISD::SELECT, SDLoc(N), N1.getValueType(), + Cond0, N2, N1); + else + return DAG.getNode(ISD::SELECT, SDLoc(N), N1.getValueType(), + Cond0, N1, N2); + } + } + } + // fold selects based on a setcc into other things, such as min/max/abs if (N0.getOpcode() == ISD::SETCC) { // select x, y (fcmp lt x, y) -> fminnum x, y |