diff --git a/llvm/lib/Target/AMDGPU/MIMGInstructions.td b/llvm/lib/Target/AMDGPU/MIMGInstructions.td --- a/llvm/lib/Target/AMDGPU/MIMGInstructions.td +++ b/llvm/lib/Target/AMDGPU/MIMGInstructions.td @@ -981,15 +981,19 @@ int Max = !if(!empty(!tail(range)), Min, !head(!tail(range))); } -class MIMG_Sampler_AddrSizes { +class MIMG_Sampler_AddrSizes { // List of all possible numbers of address words, taking all combinations of // A16 and image dimension into account (note: no MSAA, since this is for // sample/gather ops). list AllNumAddrWords = !foreach(dw, !if(sample.Gradients, - !if(!eq(sample.LodOrClamp, ""), - [2, 3, 4, 5, 6, 7, 8, 9], - [2, 3, 4, 5, 6, 7, 8, 9, 10]), + !if(isG16, + !if(!eq(sample.LodOrClamp, ""), + [2, 3, 4, 5, 6, 7], + [2, 3, 4, 5, 6, 7, 8]), + !if(!eq(sample.LodOrClamp, ""), + [2, 3, 4, 5, 6, 7, 8, 9], + [2, 3, 4, 5, 6, 7, 8, 9, 10])), !if(!eq(sample.LodOrClamp, ""), [1, 2, 3], [1, 2, 3, 4])), @@ -1028,8 +1032,8 @@ multiclass MIMG_Sampler_Src_Helper { - foreach addr = MIMG_Sampler_AddrSizes.MachineInstrs in { + bit ExtendedImageInst = 1, bit isG16 = 0> { + foreach addr = MIMG_Sampler_AddrSizes.MachineInstrs in { let VAddrDwords = addr.NumWords in { if op.HAS_GFX10M then { def _V # addr.NumWords @@ -1051,7 +1055,7 @@ } } - foreach addr = MIMG_Sampler_AddrSizes.NSAInstrs in { + foreach addr = MIMG_Sampler_AddrSizes.NSAInstrs in { let VAddrDwords = addr.NumWords in { if op.HAS_GFX10M then { def _V # addr.NumWords # _nsa_gfx10 @@ -1087,15 +1091,15 @@ let BaseOpcode = !cast(NAME), WQM = wqm, mayLoad = !not(isGetLod) in { let VDataDwords = 1 in - defm _V1 : MIMG_Sampler_Src_Helper; + defm _V1 : MIMG_Sampler_Src_Helper; let VDataDwords = 2 in - defm _V2 : MIMG_Sampler_Src_Helper; + defm _V2 : MIMG_Sampler_Src_Helper; let VDataDwords = 3 in - defm _V3 : MIMG_Sampler_Src_Helper; + defm _V3 : MIMG_Sampler_Src_Helper; let VDataDwords = 4 in - defm _V4 : MIMG_Sampler_Src_Helper; + defm _V4 : MIMG_Sampler_Src_Helper; let VDataDwords = 5 in - defm _V5 : MIMG_Sampler_Src_Helper; + defm _V5 : MIMG_Sampler_Src_Helper; } }