[llvm] 5143818 - [RISCV] Move hasOneUse() call after opcode check.
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 13 22:39:13 PDT 2023
Author: Craig Topper
Date: 2023-10-13T22:38:48-07:00
New Revision: 514381840c6d7aa775a092556992c87f022a361f
URL: https://github.com/llvm/llvm-project/commit/514381840c6d7aa775a092556992c87f022a361f
DIFF: https://github.com/llvm/llvm-project/commit/514381840c6d7aa775a092556992c87f022a361f.diff
LOG: [RISCV] Move hasOneUse() call after opcode check.
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.
Added:
Modified:
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
index 5cf5ee496656da3..d7552317fd8bc69 100644
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -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) {
More information about the llvm-commits
mailing list