[llvm] Explain partial byte extraction logic. (PR #92868)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 10 23:19:48 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-nvptx
Author: Johannes Reifferscheid (jreiffers)
<details>
<summary>Changes</summary>
This is a follow-up to #<!-- -->92506.
---
Full diff: https://github.com/llvm/llvm-project/pull/92868.diff
1 Files Affected:
- (modified) llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp (+4)
``````````diff
diff --git a/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp b/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
index f63697916d902..c30368a60c126 100644
--- a/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
+++ b/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
@@ -1851,6 +1851,10 @@ void NVPTXAsmPrinter::bufferLEByte(const Constant *CPV, int Bytes,
auto AddIntToBuffer = [AggBuffer, Bytes](const APInt &Val) {
size_t NumBytes = (Val.getBitWidth() + 7) / 8;
SmallVector<unsigned char, 16> Buf(NumBytes);
+ // `extractBitsAsZExtValue` does not allow the extraction of bits beyond the
+ // input's bit width, and i1 arrays may not have a length that is a multuple
+ // of 8. We handle the last byte separately, so we never request out of
+ // bounds bits.
for (unsigned I = 0; I < NumBytes - 1; ++I) {
Buf[I] = Val.extractBitsAsZExtValue(8, I * 8);
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/92868
More information about the llvm-commits
mailing list