[PATCH] D157651: [RISCV] Rewrite CheckInvalidVLENandLMUL to avoid floating point.
Craig Topper via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 10 13:53:04 PDT 2023
craig.topper created this revision.
craig.topper added reviewers: 4vtomat, kito-cheng, reames, asb.
Herald added subscribers: jobnoorman, VincentWu, vkmr, luismarques, sameer.abuasal, s.egerton, Jim, benna, psnobl, rogfer01, shiva0217, simoncook, arichardson.
Herald added a project: All.
craig.topper requested review of this revision.
Herald added subscribers: cfe-commits, wangpc, eopXD.
Herald added a project: clang.
This avoids needing an FP value to represent LMUL.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D157651
Files:
clang/lib/Sema/SemaChecking.cpp
Index: clang/lib/Sema/SemaChecking.cpp
===================================================================
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -4473,14 +4473,22 @@
assert((EGW == 128 || EGW == 256) && "EGW can only be 128 or 256 bits");
// LMUL * VLEN >= EGW
- uint64_t ElemSize = Type->isRVVType(32, false) ? 32 : 64;
- uint64_t ElemCount = Type->isRVVType(1) ? 1 :
+ unsigned ElemSize = Type->isRVVType(32, false) ? 32 : 64;
+ unsigned ElemCount = Type->isRVVType(1) ? 1 :
Type->isRVVType(2) ? 2 :
Type->isRVVType(4) ? 4 :
Type->isRVVType(8) ? 8 :
16;
- float Lmul = (float)(ElemSize * ElemCount) / llvm::RISCV::RVVBitsPerBlock;
- uint64_t MinRequiredVLEN = std::max(EGW / Lmul, (float)ElemSize);
+
+ unsigned EGS = EGW / ElemSize;
+ // If EGS is more than our minimum number of elements we're done.
+ if (EGS <= ElemCount)
+ return false;
+
+ // We need vscale to be at least this value.
+ unsigned VScaleFactor = EGS / ElemCount;
+ // Vscale is VLEN/RVVBitsPerBlock.
+ unsigned MinRequiredVLEN = VScaleFactor * llvm::RISCV::RVVBitsPerBlock;
std::string RequiredExt = "zvl" + std::to_string(MinRequiredVLEN) + "b";
if (!TI.hasFeature(RequiredExt))
return S.Diag(TheCall->getBeginLoc(),
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D157651.549162.patch
Type: text/x-patch
Size: 1359 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230810/c40d5090/attachment.bin>
More information about the llvm-commits
mailing list