[llvm] [RISCV][NFC] Combine redundant 'if' statements (PR #70423)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Sun Oct 29 23:16:45 PDT 2023
================
@@ -257,15 +248,12 @@ static DecodeStatus decodeVMaskReg(MCInst &Inst, uint64_t RegNo,
uint64_t Address,
const MCDisassembler *Decoder) {
MCRegister Reg = RISCV::NoRegister;
- switch (RegNo) {
- default:
+ if (RegNo > 2) {
return MCDisassembler::Fail;
- case 0:
+ } else if (RegNo == 0) {
----------------
topperc wrote:
I meant.
```
if (RegNo > 2)
return MCDisassembler::Fail;
if (RegNo == 0) <- no need for else before this.
Reg = RISCV::V0
```
Though reading the code again. I think this is simpler
```
if (RegNo > 2)
return MCDisassembler::Fail;
MCRegister Reg = (RegNo == 0) ? RISCV::V0 : RISCV::NoRegister;
```
https://github.com/llvm/llvm-project/pull/70423
More information about the llvm-commits
mailing list