[llvm] select v_sat_pk from two i16 or v2i16 (PR #121124)

Joe Nash via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 8 06:49:44 PST 2025


================
@@ -3298,6 +3301,32 @@ def : GCNPat <
   (v2i16 (V_LSHL_OR_B32_e64 $src1, (i32 16), (i32 (V_AND_B32_e64 (i32 (V_MOV_B32_e32 (i32 0xffff))), $src0))))
 >;
 
+multiclass V_SAT_PK_Pat<Instruction inst> {
+  def: GCNPatIgnoreCopies<
+    (i16 (conc_lo_u8_i16 (clamp_s16_u8 i16:$lo), (clamp_s16_u8 i16:$hi))),
+    (inst
+      (V_LSHL_OR_B32_e64 VRegSrc_32:$hi, (S_MOV_B32 (i32 16)),
+      VRegSrc_32:$lo))
+  >;
+
+  def: GCNPatIgnoreCopies<
+    (i16 (conc_lo_u8_i16 (clamp_s16_u8 i16:$lo), (smax i16:$hi, (i16 0)))),
+    (inst
+      (V_LSHL_OR_B32_e64 VRegSrc_32:$hi, (S_MOV_B32 (i32 16)),
+      VRegSrc_32:$lo))
+  >;
+
+  def: GCNPatIgnoreCopies<
+    (i16 (conc_lo_v2i16_i16 (clamp_v2i16_u8 v2i16:$src))),
+    (inst VRegSrc_32:$src)
+  >;
+}
+
+let OtherPredicates = [NotHasTrue16BitInsts] in {
+  defm : V_SAT_PK_Pat<V_SAT_PK_U8_I16_e64>;
+} // End OtherPredicates = [NotHasTrue16BitInsts]
+defm : V_SAT_PK_Pat<V_SAT_PK_U8_I16_fake16_e64>;
----------------
Sisyph wrote:

This should have let True16Predicate = UseFakeTrue16Insts
But the test changes look good, thanks!

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


More information about the llvm-commits mailing list