[all-commits] [llvm/llvm-project] f180ce: [SDAG][NVPTX] Cache control metadata support and l...

Yonah Goldberg via All-commits all-commits at lists.llvm.org
Thu Aug 6 15:56:11 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: f180ce951b1a93c8998b029ad9b0649bb92552c8
      https://github.com/llvm/llvm-project/commit/f180ce951b1a93c8998b029ad9b0649bb92552c8
  Author: Yonah Goldberg <ygoldberg at nvidia.com>
  Date:   2026-08-06 (Thu, 06 Aug 2026)

  Changed paths:
    M llvm/include/llvm/CodeGen/CodeGenCommonISel.h
    M llvm/include/llvm/CodeGen/GlobalISel/GenericMachineInstrs.h
    M llvm/include/llvm/CodeGen/MachineFunction.h
    M llvm/include/llvm/CodeGen/MachineMemOperand.h
    M llvm/include/llvm/CodeGen/SelectionDAG.h
    M llvm/include/llvm/CodeGen/SelectionDAGNodes.h
    M llvm/lib/CodeGen/CodeGenCommonISel.cpp
    M llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
    M llvm/lib/CodeGen/MIRParser/MILexer.cpp
    M llvm/lib/CodeGen/MIRParser/MILexer.h
    M llvm/lib/CodeGen/MIRParser/MIParser.cpp
    M llvm/lib/CodeGen/MachineFunction.cpp
    M llvm/lib/CodeGen/MachineOperand.cpp
    M llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
    M llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
    M llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
    M llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
    M llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
    M llvm/lib/Target/AMDGPU/SIISelLowering.cpp
    M llvm/lib/Target/Hexagon/HexagonISelLowering.cpp
    M llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXInstPrinter.cpp
    M llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXInstPrinter.h
    M llvm/lib/Target/NVPTX/NVPTX.h
    M llvm/lib/Target/NVPTX/NVPTXForwardParams.cpp
    M llvm/lib/Target/NVPTX/NVPTXISelDAGToDAG.cpp
    M llvm/lib/Target/NVPTX/NVPTXInstrInfo.td
    M llvm/lib/Target/NVPTX/NVPTXIntrinsics.td
    M llvm/lib/Target/NVPTX/NVPTXSubtarget.h
    M llvm/lib/Target/PowerPC/PPCISelLowering.cpp
    M llvm/lib/Target/RISCV/RISCVISelLowering.cpp
    M llvm/test/CodeGen/MIR/NVPTX/floating-point-immediate-operands.mir
    A llvm/test/CodeGen/MIR/X86/mem-cache-hint-error.mir
    A llvm/test/CodeGen/MIR/X86/mem-cache-hint-undefined-metadata.mir
    A llvm/test/CodeGen/MIR/X86/mem-cache-hint.mir
    M llvm/test/CodeGen/MIR/X86/memory-operands.mir
    M llvm/test/CodeGen/NVPTX/address-folder.mir
    A llvm/test/CodeGen/NVPTX/cache-hint-atomics.ll
    A llvm/test/CodeGen/NVPTX/cache-hint-cache-policy.ll
    A llvm/test/CodeGen/NVPTX/cache-hint-intrinsics.ll
    A llvm/test/CodeGen/NVPTX/cache-hint-invalid.ll
    A llvm/test/CodeGen/NVPTX/cache-hint-load-store.ll
    A llvm/test/CodeGen/NVPTX/cache-hint-sm-version.ll
    A llvm/test/CodeGen/NVPTX/cache-hint-transforms.ll
    M llvm/test/CodeGen/NVPTX/machinelicm-no-preheader.mir
    M llvm/test/CodeGen/NVPTX/proxy-reg-erasure.mir
    M llvm/test/DebugInfo/NVPTX/inlinedAt_2.mir
    M llvm/tools/llvm-reduce/ReducerWorkItem.cpp
    M llvm/unittests/CodeGen/GlobalISel/GISelAliasTest.cpp
    M llvm/unittests/CodeGen/GlobalISel/KnownBitsTest.cpp
    M llvm/unittests/CodeGen/GlobalISel/KnownBitsVectorTest.cpp
    M llvm/unittests/CodeGen/GlobalISel/MachineIRBuilderTest.cpp
    M llvm/unittests/Target/AArch64/AArch64SelectionDAGTest.cpp

  Log Message:
  -----------
  [SDAG][NVPTX] Cache control metadata support and lowering (#204067)

This is the follow up for commit
https://github.com/llvm/llvm-project/commit/0fc5d0ab0cea3afe32592f24af17b5d7e02c9dfe,
which added IR support for cache hint metadata, as described in
https://discourse.llvm.org/t/rfc-composable-and-extensible-memory-cache-control-hints-in-llvm-ir/89443.

See previous https://github.com/llvm/llvm-project/pull/175901 that I
closed in favor of this one.

This PR adds support in SelectionDAG and lowering in NVPTX.

Supported cache hints:

L1 eviction: L1::evict_first, L1::evict_last, L1::evict_unchanged,
L1::no_allocate (requires SM 70+)
L2 eviction: L2::evict_first, L2::evict_last (requires SM 70+)
L2 prefetch: L2::64B, L2::128B (SM 75+), L2::256B (SM 80+)
L2::cache_hint with 64-bit cache policy descriptor (SM 80+, PTX 7.4+)

L1 eviction: L1::evict_first, L1::evict_last, L1::evict_unchanged,
L1::no_allocate (requires SM 70+ and PTX 7.4+)
L2 eviction: L2::evict_first, L2::evict_last (requires SM 100+, PTX
8.8+, and a 256-bit .v8.b32 or .v4.b64 memory operation)
L2 prefetch: L2::64B, L2::128B (requires SM 75+ and PTX 7.4+), L2::256B
(requires SM 80+ and PTX 7.4+)
L2 cache policy: L2::cache_hint with a 64-bit cache policy descriptor
(requires SM 80+ and PTX 7.4+)

I know this is a fairly large PR, but I needed to plug the support all
the way through the backend. I supposed I could add machinery in
SelectionDAG as an initial PR, but I'm not sure if that makes sense. I
implemented lowering on load + store + memcpy. I supposed memcpy can go
in a follow-up, but it doesn't really reduce the size that much.

TODO:
- implement support in global ISEL
- Implement lowering in NVPTX for atomics + other intrinsics
(llvm.masked.load/store)
- Better handling of cache hint metadata in legalization. Today we will
often drop the metadata. If we legalize a wide vector load into a bunch
of smaller loads, for example, we should preserve the metadata.
- Preserve L2 eviction metadata for suitably aligned, 32-byte-multiple
memcpy operations

Design decisions:
- I encoded the metadata in the MachineMemOperand. I hope it's ok to
increase the size. I think this is the best place because similar
information (atomic info, range metadata, etc...) is all stored there.
- When the metadata node values (strings which are target dependent) are
not valid for NVPTX, I call `ctx.emitError` to emit a diagnostic. I
think this is best because we wouldn't want front-ends to accidentally
emit incorrect metadata and for it to silently be dropped.

Co-authored-by: Fiigii <feipeng.compiler at gmail.com>

Assisted by AI



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list