[llvm] [RISCV] Correct the precedence in isVRegClass (PR #116579)

Brandon Wu via llvm-commits llvm-commits at lists.llvm.org
Sun Nov 17 23:04:11 PST 2024


https://github.com/4vtomat created https://github.com/llvm/llvm-project/pull/116579

Right shift has higher precedence than bitwise and, so it should be
parentheses around & operator. This case works as expected because
IsVRegClassShift is 0, other cases will fail.


>From 0a5a9827c5238f1b75157fb3a29e82a87a8a32ab Mon Sep 17 00:00:00 2001
From: Brandon Wu <brandon.wu at sifive.com>
Date: Sun, 17 Nov 2024 22:59:43 -0800
Subject: [PATCH] [RISCV] Correct the precedence in isVRegClass

Right shift has higher precedence than bitwise and, so it should be
parentheses around & operator. This case works as expected because
IsVRegClassShift is 0, other cases will fail.
---
 llvm/lib/Target/RISCV/RISCVRegisterInfo.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/lib/Target/RISCV/RISCVRegisterInfo.h b/llvm/lib/Target/RISCV/RISCVRegisterInfo.h
index 6ddb1eb9c14d5e..3ab79694e175c8 100644
--- a/llvm/lib/Target/RISCV/RISCVRegisterInfo.h
+++ b/llvm/lib/Target/RISCV/RISCVRegisterInfo.h
@@ -39,7 +39,7 @@ enum {
 
 /// \returns the IsVRegClass for the register class.
 static inline bool isVRegClass(uint64_t TSFlags) {
-  return TSFlags & IsVRegClassShiftMask >> IsVRegClassShift;
+  return (TSFlags & IsVRegClassShiftMask) >> IsVRegClassShift;
 }
 
 /// \returns the LMUL for the register class.



More information about the llvm-commits mailing list