[llvm] [SPIR-V][NFC] More efficient getPaddedLen (PR #105823)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 23 05:41:49 PDT 2024
https://github.com/bwlodarcz created https://github.com/llvm/llvm-project/pull/105823
Quick fix with small performance improvement for getPaddedLen function.
>From c756958fa58e5b75cab2601cc6d4577ec8ab0152 Mon Sep 17 00:00:00 2001
From: "Wlodarczyk, Bertrand" <bertrand.wlodarczyk at intel.com>
Date: Fri, 23 Aug 2024 14:34:16 +0200
Subject: [PATCH] [SPIR-V][NFC] More efficient getPaddedLen
Quick fix with small performance improvement for getPaddedLen function.
---
llvm/lib/Target/SPIRV/SPIRVUtils.cpp | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
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) {
More information about the llvm-commits
mailing list