Skip to content

Commit

Permalink
[RISCV] Move hasOneUse() call after opcode check.
Browse files Browse the repository at this point in the history
hasOneUse can be more expensive for nodes with multiple outputs.
It's better to check the opcode first to skip nodes with multiple
outputs.

I have not seen an issue from this, just noticed while reviewing
code for a possible enhancement.
  • Loading branch information
topperc committed Oct 14, 2023
1 parent ece5dd1 commit 5143818
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion llvm/lib/Target/RISCV/RISCVISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11999,7 +11999,7 @@ static SDValue performXORCombine(SDNode *N, SelectionDAG &DAG,
}

// Fold (xor (setcc constant, y, setlt), 1) -> (setcc y, constant + 1, setlt)
if (N0.hasOneUse() && N0.getOpcode() == ISD::SETCC && isOneConstant(N1)) {
if (N0.getOpcode() == ISD::SETCC && isOneConstant(N1) && N0.hasOneUse()) {
auto *ConstN00 = dyn_cast<ConstantSDNode>(N0.getOperand(0));
ISD::CondCode CC = cast<CondCodeSDNode>(N0.getOperand(2))->get();
if (ConstN00 && CC == ISD::SETLT) {
Expand Down

0 comments on commit 5143818

Please sign in to comment.