[llvm] 3c2203a - [RISCV] Use a switch instead of a series of if-clauses [nfc]
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 25 13:15:10 PDT 2023
Author: Philip Reames
Date: 2023-10-25T13:15:01-07:00
New Revision: 3c2203ae03ca8a8cf56691d6f03050ccc2420ff6
URL: https://github.com/llvm/llvm-project/commit/3c2203ae03ca8a8cf56691d6f03050ccc2420ff6
DIFF: https://github.com/llvm/llvm-project/commit/3c2203ae03ca8a8cf56691d6f03050ccc2420ff6.diff
LOG: [RISCV] Use a switch instead of a series of if-clauses [nfc]
This way the compiler can tell us about missing cases if we add a new value to this enum.
Added:
Modified:
llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp b/llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
index 91d8d91cdfe85f7..adcc608b2286dd5 100644
--- a/llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
+++ b/llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
@@ -301,18 +301,21 @@ inline raw_ostream &operator<<(raw_ostream &OS, const DemandedFields &DF) {
/// of instructions) which use only the Used subfields and properties.
static bool areCompatibleVTYPEs(uint64_t CurVType, uint64_t NewVType,
const DemandedFields &Used) {
- if (Used.SEW == DemandedFields::SEWEqual &&
- RISCVVType::getSEW(CurVType) != RISCVVType::getSEW(NewVType))
- return false;
-
- if (Used.SEW == DemandedFields::SEWGreaterThanOrEqual &&
- RISCVVType::getSEW(NewVType) < RISCVVType::getSEW(CurVType))
- return false;
-
- if (Used.SEW == DemandedFields::SEWGreaterThanOrEqualAndLessThan64 &&
- (RISCVVType::getSEW(NewVType) < RISCVVType::getSEW(CurVType) ||
- RISCVVType::getSEW(NewVType) >= 64))
- return false;
+ switch (Used.SEW) {
+ case DemandedFields::SEWEqual:
+ if (RISCVVType::getSEW(CurVType) != RISCVVType::getSEW(NewVType))
+ return false;
+ break;
+ case DemandedFields::SEWGreaterThanOrEqual:
+ if (RISCVVType::getSEW(NewVType) < RISCVVType::getSEW(CurVType))
+ return false;
+ break;
+ case DemandedFields::SEWGreaterThanOrEqualAndLessThan64:
+ if (RISCVVType::getSEW(NewVType) < RISCVVType::getSEW(CurVType) ||
+ RISCVVType::getSEW(NewVType) >= 64)
+ return false;
+ break;
+ }
if (Used.LMUL &&
RISCVVType::getVLMUL(CurVType) != RISCVVType::getVLMUL(NewVType))
More information about the llvm-commits
mailing list