[llvm] a32d491 - [RISCV] Clean up the code for isBareSimmNLsb0. NFC.

Jim Lin via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 13 19:57:33 PDT 2025


Author: Jim Lin
Date: 2025-04-14T10:39:34+08:00
New Revision: a32d4917c82840179a9ff5686567834922fc4e6d

URL: https://github.com/llvm/llvm-project/commit/a32d4917c82840179a9ff5686567834922fc4e6d
DIFF: https://github.com/llvm/llvm-project/commit/a32d4917c82840179a9ff5686567834922fc4e6d.diff

LOG: [RISCV] Clean up the code for isBareSimmNLsb0. NFC.

Added: 
    

Modified: 
    llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
index 8dd5aa4b6c075..f246aee4da394 100644
--- a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
+++ b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
@@ -539,17 +539,16 @@ struct RISCVOperand final : public MCParsedAsmOperand {
   // True if operand is a symbol with no modifiers, or a constant with no
   // modifiers and isShiftedInt<N-1, 1>(Op).
   template <int N> bool isBareSimmNLsb0() const {
-    int64_t Imm;
-    RISCVMCExpr::Specifier VK = RISCVMCExpr::VK_None;
     if (!isImm())
       return false;
-    bool IsConstantImm = evaluateConstantImm(getImm(), Imm);
-    bool IsValid;
-    if (!IsConstantImm)
-      IsValid = RISCVAsmParser::classifySymbolRef(getImm(), VK);
-    else
-      IsValid = isShiftedInt<N - 1, 1>(fixImmediateForRV32(Imm, isRV64Imm()));
-    return IsValid && VK == RISCVMCExpr::VK_None;
+
+    int64_t Imm;
+    if (evaluateConstantImm(getImm(), Imm))
+      return isShiftedInt<N - 1, 1>(fixImmediateForRV32(Imm, isRV64Imm()));
+
+    RISCVMCExpr::Specifier VK = RISCVMCExpr::VK_None;
+    return RISCVAsmParser::classifySymbolRef(getImm(), VK) &&
+           VK == RISCVMCExpr::VK_None;
   }
 
   // True if operand is a symbol with no modifiers, or a constant with no


        


More information about the llvm-commits mailing list