From 46c6109be32709dbd264714a285bae9e41d9777f Mon Sep 17 00:00:00 2001 From: pvanhout Date: Thu, 25 Sep 2025 11:15:30 +0200 Subject: [PATCH] [AMDGPU][gfx1250] Check for GloballyAddressableScratch in mayAccessScratchThroughFlat --- llvm/lib/Target/AMDGPU/SIInstrInfo.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp b/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp index 044ea866342c2..a98dc3fe7552f 100644 --- a/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp +++ b/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp @@ -4319,8 +4319,10 @@ bool SIInstrInfo::mayAccessScratchThroughFlat(const MachineInstr &MI) const { if (!isFLAT(MI) || isFLATGlobal(MI)) return false; - // If scratch is not initialized, we can never access it. - if (MI.getMF()->getFunction().hasFnAttribute("amdgpu-no-flat-scratch-init")) + // If scratch is not initialized, we can never access it unless the target has + // the ability to access scratch outside its own thread. + if (!ST.hasGloballyAddressableScratch() && + MI.getMF()->getFunction().hasFnAttribute("amdgpu-no-flat-scratch-init")) return false; // SCRATCH instructions always access scratch.