[llvm] [AMDGPU][GlobalIsel] Add register bank legalization rules for fptoi and itofp (PR #176300)

Syadus Sefat via llvm-commits llvm-commits at lists.llvm.org
Sat Jan 17 23:29:21 PST 2026


================
@@ -475,6 +475,18 @@ let SubtargetPredicate = HasSALUFloatInsts, AddedComplexity = 9 in {
                  (S_CVT_I32_F32 $src0)>;
     def : GCNPat<(i16 (UniformUnaryFrag<fp_to_uint> f32:$src0)),
                  (S_CVT_U32_F32 $src0)>;
+
+    // f16 -> i32 : form chain f16 -> f32 -> i32
+    def : GCNPat<(i32 (UniformUnaryFrag<fp_to_sint> f16:$src0)),
+                 (S_CVT_I32_F32 (S_CVT_F32_F16 $src0))>;
+    def : GCNPat<(i32 (UniformUnaryFrag<fp_to_uint> f16:$src0)),
+                 (S_CVT_U32_F32 (S_CVT_F32_F16 $src0))>;
+
+    // i32 -> f16 : form chain i32 -> f32 -> f16
+    def : GCNPat<(f16 (UniformUnaryFrag<sint_to_fp> i32:$src0)),
+                 (S_CVT_F16_F32 (S_CVT_F32_I32 $src0))>;
+    def : GCNPat<(f16 (UniformUnaryFrag<uint_to_fp> i32:$src0)),
+                 (S_CVT_F16_F32 (S_CVT_F32_U32 $src0))>;
----------------
mssefat wrote:

I have created a pre-commit NFC PR for the tests: https://github.com/llvm/llvm-project/pull/176630
I will follow-up with td change once it is approved. 

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


More information about the llvm-commits mailing list