diff options
author | Sanjay Patel <spatel@rotateright.com> | 2018-12-06 19:18:56 +0000 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2018-12-06 19:18:56 +0000 |
commit | bfc7ffa40ffc570f54e2b4462dc6aae38da1a85a (patch) | |
tree | 682481297bd20b36ecb6167ff18de501ccbebfbb /llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | |
parent | 845d5a0aa836e91be70802b6c6e5bc72b9585b2f (diff) | |
download | bcm5719-llvm-bfc7ffa40ffc570f54e2b4462dc6aae38da1a85a.tar.gz bcm5719-llvm-bfc7ffa40ffc570f54e2b4462dc6aae38da1a85a.zip |
[DAGCombiner] don't hoist logic op if operands have other uses, part 2
The PPC test with 2 extra uses seems clearly better by avoiding this transform.
With 1 extra use, we also prevent an extra register move (although that might
be an RA problem). The general rule should be to only make a change here if
it is always profitable. The x86 diffs are all neutral.
llvm-svn: 348518
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index 5a70deebd68..166577e5faf 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -3764,11 +3764,13 @@ SDValue DAGCombiner::hoistLogicOpWithSameOpcodeHands(SDNode *N) { if ((HandOpcode == ISD::SHL || HandOpcode == ISD::SRL || HandOpcode == ISD::SRA || HandOpcode == ISD::AND) && N0.getOperand(1) == N1.getOperand(1)) { - SDValue ORNode = DAG.getNode(LogicOpcode, SDLoc(N0), - N0.getOperand(0).getValueType(), - N0.getOperand(0), N1.getOperand(0)); - AddToWorklist(ORNode.getNode()); - return DAG.getNode(HandOpcode, SDLoc(N), VT, ORNode, N0.getOperand(1)); + // If either operand has other uses, this transform is not an improvement. + if (!N0.hasOneUse() || !N1.hasOneUse()) + return SDValue(); + SDValue Logic = DAG.getNode(LogicOpcode, SDLoc(N0), Op0VT, + N0.getOperand(0), N1.getOperand(0)); + AddToWorklist(Logic.getNode()); + return DAG.getNode(HandOpcode, SDLoc(N), VT, Logic, N0.getOperand(1)); } // Simplify xor/and/or (bitcast(A), bitcast(B)) -> bitcast(op (A,B)) |