[llvm] 43cf2f8 - [LoongArch] Refine the condition to return Match_RequiresAMORdDifferRkRj in AsmParser. NFC

Weining Lu via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 11 01:16:50 PST 2023


Author: Weining Lu
Date: 2023-01-11T17:16:21+08:00
New Revision: 43cf2f8103f9ef0f292c2cd12e89c55406182e1a

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

LOG: [LoongArch] Refine the condition to return Match_RequiresAMORdDifferRkRj in AsmParser. NFC

This can suppress compilation warning like `enumerated mismatch in conditional expression`.

See:
https://lab.llvm.org/staging/#/builders/236/builds/645/steps/6/logs/warnings__1_

Added: 
    

Modified: 
    llvm/lib/Target/LoongArch/AsmParser/LoongArchAsmParser.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/LoongArch/AsmParser/LoongArchAsmParser.cpp b/llvm/lib/Target/LoongArch/AsmParser/LoongArchAsmParser.cpp
index b27070f717f50..5517ce20479c6 100644
--- a/llvm/lib/Target/LoongArch/AsmParser/LoongArchAsmParser.cpp
+++ b/llvm/lib/Target/LoongArch/AsmParser/LoongArchAsmParser.cpp
@@ -1177,9 +1177,8 @@ unsigned LoongArchAsmParser::checkTargetMatchPredicate(MCInst &Inst) {
       unsigned Rd = Inst.getOperand(0).getReg();
       unsigned Rk = Inst.getOperand(1).getReg();
       unsigned Rj = Inst.getOperand(2).getReg();
-      if (Rd == Rk || Rd == Rj)
-        return Rd == LoongArch::R0 ? Match_Success
-                                   : Match_RequiresAMORdDifferRkRj;
+      if ((Rd == Rk || Rd == Rj) && Rd != LoongArch::R0)
+        return Match_RequiresAMORdDifferRkRj;
     }
     break;
   case LoongArch::PseudoLA_PCREL_LARGE:


        


More information about the llvm-commits mailing list