[llvm] [RISCV] Use uint32_t for NumOfVReg in getVLENFactoredAmount. (PR #84110)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 5 20:15:27 PST 2024
https://github.com/topperc updated https://github.com/llvm/llvm-project/pull/84110
>From 70378874e62579f875b8c14bb90224c759b107d5 Mon Sep 17 00:00:00 2001
From: Craig Topper <craig.topper at sifive.com>
Date: Tue, 5 Mar 2024 19:52:19 -0800
Subject: [PATCH 1/2] [RISCV] Use uint32_t for NumOfVReg in
getVLENFactoredAmount.
The rest of the code pretty much assumed this anyway.
---
llvm/lib/Target/RISCV/RISCVInstrInfo.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp b/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
index 2abe015c9f9cdc..53b27f694bc378 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
@@ -3059,7 +3059,7 @@ void RISCVInstrInfo::getVLENFactoredAmount(MachineFunction &MF,
"Reserve the stack by the multiple of one vector size.");
MachineRegisterInfo &MRI = MF.getRegInfo();
- int64_t NumOfVReg = Amount / 8;
+ uint32_t NumOfVReg = Amount / 8;
BuildMI(MBB, II, DL, get(RISCV::PseudoReadVLENB), DestReg).setMIFlag(Flag);
assert(isInt<32>(NumOfVReg) &&
@@ -3137,7 +3137,7 @@ void RISCVInstrInfo::getVLENFactoredAmount(MachineFunction &MF,
.setMIFlag(Flag);
uint32_t PrevShiftAmount = 0;
for (uint32_t ShiftAmount = 0; NumOfVReg >> ShiftAmount; ShiftAmount++) {
- if (NumOfVReg & (1LL << ShiftAmount)) {
+ if (NumOfVReg & (1U << ShiftAmount)) {
if (ShiftAmount)
BuildMI(MBB, II, DL, get(RISCV::SLLI), DestReg)
.addReg(DestReg, RegState::Kill)
>From 44d932d8259c1230d3b64f584a7d2d7fe577e10a Mon Sep 17 00:00:00 2001
From: Craig Topper <craig.topper at sifive.com>
Date: Tue, 5 Mar 2024 20:14:48 -0800
Subject: [PATCH 2/2] fixup! Reorder an assert
---
llvm/lib/Target/RISCV/RISCVInstrInfo.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp b/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
index 53b27f694bc378..ef0d7cbc835d0d 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
@@ -3059,11 +3059,11 @@ void RISCVInstrInfo::getVLENFactoredAmount(MachineFunction &MF,
"Reserve the stack by the multiple of one vector size.");
MachineRegisterInfo &MRI = MF.getRegInfo();
+ assert(isInt<32>(Amount / 8) &&
+ "Expect the number of vector registers within 32-bits.");
uint32_t NumOfVReg = Amount / 8;
BuildMI(MBB, II, DL, get(RISCV::PseudoReadVLENB), DestReg).setMIFlag(Flag);
- assert(isInt<32>(NumOfVReg) &&
- "Expect the number of vector registers within 32-bits.");
if (llvm::has_single_bit<uint32_t>(NumOfVReg)) {
uint32_t ShiftAmount = Log2_32(NumOfVReg);
if (ShiftAmount == 0)
More information about the llvm-commits
mailing list