[all-commits] [llvm/llvm-project] d24a67: [LowerMemIntrinsics] Optimize memset lowering (#16...

Fabian Ritter via All-commits all-commits at lists.llvm.org
Wed Feb 4 04:35:35 PST 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: d24a6754ce8bf980dfc294dbc359bb8528db48b8
      https://github.com/llvm/llvm-project/commit/d24a6754ce8bf980dfc294dbc359bb8528db48b8
  Author: Fabian Ritter <fabian.ritter at amd.com>
  Date:   2026-02-04 (Wed, 04 Feb 2026)

  Changed paths:
    M llvm/include/llvm/Transforms/Utils/LowerMemIntrinsics.h
    M llvm/lib/CodeGen/PreISelIntrinsicLowering.cpp
    M llvm/lib/Target/AMDGPU/AMDGPULowerBufferFatPointers.cpp
    M llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp
    M llvm/lib/Target/NVPTX/NVPTXLowerAggrCopies.cpp
    M llvm/lib/Target/SPIRV/SPIRVPrepareFunctions.cpp
    M llvm/lib/Transforms/Utils/LowerMemIntrinsics.cpp
    M llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.memset.ll
    M llvm/test/CodeGen/AMDGPU/local-stack-alloc-block-sp-reference.ll
    M llvm/test/CodeGen/AMDGPU/lower-buffer-fat-pointers-mem-transfer.ll
    M llvm/test/CodeGen/AMDGPU/lower-mem-intrinsics-threshold.ll
    M llvm/test/CodeGen/AMDGPU/lower-mem-intrinsics.ll
    M llvm/test/CodeGen/AMDGPU/memintrinsic-unroll.ll
    A llvm/test/CodeGen/AMDGPU/memset-param-combinations.ll
    M llvm/test/CodeGen/NVPTX/lower-aggr-copies.ll
    M llvm/test/CodeGen/SPIRV/llvm-intrinsics/memset.ll
    M llvm/test/Transforms/PreISelIntrinsicLowering/AMDGPU/expand-mem-intrinsics.ll
    M llvm/test/Transforms/PreISelIntrinsicLowering/X86/memset-inline-non-constant-len.ll

  Log Message:
  -----------
  [LowerMemIntrinsics] Optimize memset lowering (#169040)

This patch changes the memset lowering to match the optimized memcpy lowering.
The memset lowering now queries TTI.getMemcpyLoopLoweringType for a preferred
memory access type. If that type is larger than a byte, the memset is lowered
into two loops: a main loop that stores a sufficiently wide vector splat of the
SetValue with the preferred memory access type and a residual loop that covers
the remaining bytes individually. If the memset size is statically known, the
residual loop is replaced by a sequence of stores.

This improves memset performance on gfx1030 (AMDGPU) in microbenchmarks by
around 7-20x.

I'm planning similar treatment for memset.pattern as a follow-up PR.

For SWDEV-543208.



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