[llvm] [SDAG][NVPTX] Cache control metadata support and lowering (PR #204067)

Yonah Goldberg via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 3 19:46:25 PDT 2026


YonahGoldberg wrote:

I read through all the AI suggestions and implemented some of the fixes:

1. **NVPTXForwardParams leaves a dead mov.b64 in the emitted PTX**: This actually only happens at O0, but I fixed it anyway in `NVPTXForwaredParams.cpp`
2. **getMemCacheHintMetadata can read out of bounds**: This can only happen if the verifier doesn't run. Generally I think we can assume the verifier will run for things like choosing `cast` over `dyn_cast`, but in this case I agree, we shouldn't have out of bounds reads no matter what, so I fixed.
3. **Diagnostics are subtarget-dependent**: Previously I had inconsistent behavior. The question is if I should emit a parsing warning on a cache hint metadata that would've been ignored anyway because it is not valid for the subtarget. I fixed it so that we always emit the parse warning.
4. **nvvm.l2_cache_hint is constant-only, and that may not be usable**: Yeah, if we want to support dynamic cache hints we would need an intrinsic. Nothing to do for this.
5. **Unsupported-hint drops are entirely silent**: This is fine, silently dropping metadata is the norm.
6. **CachePolicy should be a RegisterOperand**: We don't use RegisterOperand anywhere else in the file, so I don't think we should use it.
7. **printEvictionAndPrefetchHint silently ignores an unknown modifier**: I put an `llvm_unreachable` at the end.
8. **Literal tab characters in NVPTXIntrinsics.td**: fixed, inserted explicit `\t`
9. **The reformatted asm format strings are hard to read**: Valid, added `defvar CacheHintQualifiers`.
10. **MMOMetadata — take arsenm's aggregate-init suggestion**: it wants me to use `{.AAInfo = NewAAInfo, .MemCacheHint = DstMemCacheHint}`, but this is C++20 syntax, so I can't use it.
11. **Pass MMOMetadata by const reference**: Agreed, fixed.
12. **llvm-reduce drops the hint**: I'll fix this in a follow up.
13. **getMemCacheHintMetadata's OperandNo is overloaded**: Adjusted the header comment to explain that this could be an operand number or argument index.
14. **hasL2Prefetch64B() and hasL2Prefetch128B() are identical**: I think this is fine.

https://github.com/llvm/llvm-project/pull/204067


More information about the llvm-commits mailing list