Skip to content

Commit 4ffb747

Browse files
authored
[SPIR-V][NFC] More efficient getPaddedLen (#105823)
Quick fix with small performance improvement for getPaddedLen function.
1 parent 0f85c3e commit 4ffb747

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

llvm/lib/Target/SPIRV/SPIRVUtils.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,7 @@ static uint32_t convertCharsToWord(const StringRef &Str, unsigned i) {
4545
}
4646

4747
// Get length including padding and null terminator.
48-
static size_t getPaddedLen(const StringRef &Str) {
49-
const size_t Len = Str.size() + 1;
50-
return (Len % 4 == 0) ? Len : Len + (4 - (Len % 4));
51-
}
48+
static size_t getPaddedLen(const StringRef &Str) { return Str.size() + 4 & ~3; }
5249

5350
void addStringImm(const StringRef &Str, MCInst &Inst) {
5451
const size_t PaddedLen = getPaddedLen(Str);

0 commit comments

Comments
 (0)