[llvm] [AMDGPU] Align GlobalISel with SelectionDAG for f16 to i1/i8 saturated conversions (PR #188019)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Tue May 12 08:24:18 PDT 2026


================
@@ -1209,9 +1208,12 @@ AMDGPULegalizerInfo::AMDGPULegalizerInfo(const GCNSubtarget &ST_,
   // clang-format off
   auto &FPToISat = getActionDefinitionsBuilder({G_FPTOSI_SAT, G_FPTOUI_SAT})
     .legalFor({{S32, S32}, {S32, S64}})
+    .legalFor(ST.has16BitInsts(),{{S16, S16}})
     .narrowScalarFor({{S64, S16}}, changeTo(0, S32));
+
+  // If available, widen i1 and i8 to i16, intead of i32 so v_cvt_i16/u16_f16 can be used.
   if (ST.has16BitInsts())
-    FPToISat.legalFor({{S16, S16}});
+    FPToISat.widenScalarFor({{S1, S16}, {S8, S16}}, changeTo(0, S16));
----------------
arsenm wrote:

clampScalar(0, 16)?

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


More information about the llvm-commits mailing list