[llvm] [AMDGPU] Gate runtime unroll of LDS loops instead of overriding it (PR #222853)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 11 04:03:39 PDT 2026


================
@@ -0,0 +1,57 @@
+; RUN: opt -mtriple=amdgpu-- -passes=loop-unroll -S %s | FileCheck %s --check-prefixes=CHECK,DEFAULT
+; RUN: opt -mtriple=amdgpu-- -passes=loop-unroll -amdgpu-unroll-runtime-local=false -S %s | FileCheck %s --check-prefixes=CHECK,NOLOCAL
+
+; -amdgpu-unroll-runtime-local gates runtime unrolling per loop, based on
+; whether that loop touches local (LDS, addrspace(3)) memory. With the knob
+; off, only the LDS loop is suppressed; the global-memory loop is unaffected.
+;
+;                     knob=true (default)   knob=false
+;   %lds.loop            unrolled              NOT unrolled
+;   %global.loop         unrolled              unrolled (knob has no effect)
+
+ at lds = internal unnamed_addr addrspace(3) global [256 x i32] poison, align 4
+
+; CHECK-LABEL: @two_loops(
+define void @two_loops(ptr addrspace(1) %out, i32 %n, i32 %m) {
+entry:
+  %cmp = icmp sgt i32 %n, 0
+  br i1 %cmp, label %lds.loop, label %global.preheader
+
+; The LDS loop: gated by the knob. Its runtime-unroll epilogue block
+; (lds.loop.epil) appears only when the knob is on.
+;
+; DEFAULT: lds.loop.epil:
+;
+; NOLOCAL-NOT: lds.loop.epil
----------------
arsenm wrote:

Avoid -NOT checks, check what's really emitted 

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


More information about the llvm-commits mailing list