[llvm] [AMDGPU] Fix negative immediate offset for unbuffered smem loads (PR #79553)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 9 08:32:08 PST 2024
================
@@ -2096,21 +2099,47 @@ bool AMDGPUDAGToDAGISel::SelectSMRDBaseOffset(SDValue Addr, SDValue &SBase,
}
if (!N0 || !N1)
return false;
+
+ bool Selected = false;
if (SelectSMRDOffset(N1, SOffset, Offset, Imm32Only, IsBuffer)) {
SBase = N0;
- return true;
- }
- if (SelectSMRDOffset(N0, SOffset, Offset, Imm32Only, IsBuffer)) {
+ Selected = true;
+ } else if (SelectSMRDOffset(N0, SOffset, Offset, Imm32Only, IsBuffer)) {
SBase = N1;
+ Selected = true;
+ }
+
+ if (Selected) {
+ // For unbuffered smem loads, it is illegal and undefined for the Immediate
+ // Offset to be negative if the resulting (Offset + (M0 or SOffset or zero)
+ // is negative. Handle the case where the Immediate Offset is negative and
+ // there is no SOffset.
+ //
+ // FIXME: Also handle M0 or SOffset case?
----------------
arsenm wrote:
Not sure what the fixme is about; I also doubt the rules are different if it's m0 or a numbered SGPR
https://github.com/llvm/llvm-project/pull/79553
More information about the llvm-commits
mailing list