[llvm] [SPIR-V][NFC] More efficient getPaddedLen (PR #105823)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 23 05:42:19 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-spir-v
Author: None (bwlodarcz)
<details>
<summary>Changes</summary>
Quick fix with small performance improvement for getPaddedLen function.
---
Full diff: https://github.com/llvm/llvm-project/pull/105823.diff
1 Files Affected:
- (modified) llvm/lib/Target/SPIRV/SPIRVUtils.cpp (+1-2)
``````````diff
diff --git a/llvm/lib/Target/SPIRV/SPIRVUtils.cpp b/llvm/lib/Target/SPIRV/SPIRVUtils.cpp
index 927683ad7e32be..68f166d0bef4ea 100644
--- a/llvm/lib/Target/SPIRV/SPIRVUtils.cpp
+++ b/llvm/lib/Target/SPIRV/SPIRVUtils.cpp
@@ -44,8 +44,7 @@ static uint32_t convertCharsToWord(const StringRef &Str, unsigned i) {
// Get length including padding and null terminator.
static size_t getPaddedLen(const StringRef &Str) {
- const size_t Len = Str.size() + 1;
- return (Len % 4 == 0) ? Len : Len + (4 - (Len % 4));
+ return Str.size() + 4 & ~3;
}
void addStringImm(const StringRef &Str, MCInst &Inst) {
``````````
</details>
https://github.com/llvm/llvm-project/pull/105823
More information about the llvm-commits
mailing list