[llvm] 766f68d - [RISCV] Invert if conditions in the switch in RISCVDAGToDAGISel::hasAllNBitUsers. NFC
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Sat Aug 3 17:24:20 PDT 2024
Author: Craig Topper
Date: 2024-08-03T17:23:55-07:00
New Revision: 766f68d17ab1b12a46324d8b526f753cd1a353d3
URL: https://github.com/llvm/llvm-project/commit/766f68d17ab1b12a46324d8b526f753cd1a353d3
DIFF: https://github.com/llvm/llvm-project/commit/766f68d17ab1b12a46324d8b526f753cd1a353d3.diff
LOG: [RISCV] Invert if conditions in the switch in RISCVDAGToDAGISel::hasAllNBitUsers. NFC
Make "break" consistently the "if" body and the "return false" the
last thing in each case.
This makes it easier to add different conditions for different operands
of some instructions and makes everything more consistent.
Added:
Modified:
llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp b/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
index 20c24e8ab393d..31f48a6ac24d7 100644
--- a/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
@@ -3169,9 +3169,9 @@ bool RISCVDAGToDAGISel::hasAllNBitUsers(SDNode *Node, unsigned Bits,
case RISCV::FCVT_D_WU:
case RISCV::TH_REVW:
case RISCV::TH_SRRIW:
- if (Bits < 32)
- return false;
- break;
+ if (Bits >= 32)
+ break;
+ return false;
case RISCV::SLL:
case RISCV::SRA:
case RISCV::SRL:
@@ -3181,14 +3181,14 @@ bool RISCVDAGToDAGISel::hasAllNBitUsers(SDNode *Node, unsigned Bits,
case RISCV::BCLR:
case RISCV::BINV:
// Shift amount operands only use log2(Xlen) bits.
- if (UI.getOperandNo() != 1 || Bits < Log2_32(Subtarget->getXLen()))
- return false;
- break;
+ if (UI.getOperandNo() == 1 && Bits >= Log2_32(Subtarget->getXLen()))
+ break;
+ return false;
case RISCV::SLLI:
// SLLI only uses the lower (XLen - ShAmt) bits.
- if (Bits < Subtarget->getXLen() - User->getConstantOperandVal(1))
- return false;
- break;
+ if (Bits >= Subtarget->getXLen() - User->getConstantOperandVal(1))
+ break;
+ return false;
case RISCV::ANDI:
if (Bits >= (unsigned)llvm::bit_width(User->getConstantOperandVal(1)))
break;
@@ -3224,42 +3224,42 @@ bool RISCVDAGToDAGISel::hasAllNBitUsers(SDNode *Node, unsigned Bits,
}
case RISCV::SEXT_B:
case RISCV::PACKH:
- if (Bits < 8)
- return false;
- break;
+ if (Bits >= 8)
+ break;
+ return false;
case RISCV::SEXT_H:
case RISCV::FMV_H_X:
case RISCV::ZEXT_H_RV32:
case RISCV::ZEXT_H_RV64:
case RISCV::PACKW:
- if (Bits < 16)
- return false;
- break;
+ if (Bits >= 16)
+ break;
+ return false;
case RISCV::PACK:
- if (Bits < (Subtarget->getXLen() / 2))
- return false;
- break;
+ if (Bits >= (Subtarget->getXLen() / 2))
+ break;
+ return false;
case RISCV::ADD_UW:
case RISCV::SH1ADD_UW:
case RISCV::SH2ADD_UW:
case RISCV::SH3ADD_UW:
// The first operand to add.uw/shXadd.uw is implicitly zero extended from
// 32 bits.
- if (UI.getOperandNo() != 0 || Bits < 32)
- return false;
- break;
+ if (UI.getOperandNo() == 0 && Bits >= 32)
+ break;
+ return false;
case RISCV::SB:
- if (UI.getOperandNo() != 0 || Bits < 8)
- return false;
- break;
+ if (UI.getOperandNo() == 0 && Bits >= 8)
+ break;
+ return false;
case RISCV::SH:
- if (UI.getOperandNo() != 0 || Bits < 16)
- return false;
- break;
+ if (UI.getOperandNo() == 0 && Bits >= 16)
+ break;
+ return false;
case RISCV::SW:
- if (UI.getOperandNo() != 0 || Bits < 32)
- return false;
- break;
+ if (UI.getOperandNo() == 0 && Bits >= 32)
+ break;
+ return false;
}
}
More information about the llvm-commits
mailing list