On 27/9/26 10:59, Richard Henderson wrote:
Signed-off-by: Richard Henderson <[email protected]>
---
  include/tcg/tcg-op-common.h  |  2 --
  include/tcg/tcg-op-def.h.inc |  1 +
  tcg/tcg-op.c                 | 35 +++++++++++++++--------------------
  3 files changed, 16 insertions(+), 22 deletions(-)


+void tcg_gen_abs(TCGType type, TCGTemp *dst, TCGTemp *src)
+{
+    g_autoptr(TCGTemp) tmp = tcg_temp_new_ebb(type);
+
+    if (tcg_op_supported(INDEX_op_smax, type, 0)) {
+        tcg_gen_neg(type, tmp, src);
+        tcg_gen_smax(type, dst, tmp, src);

This patch is doing 2 distinct changes, generic expansion of ABS
and use of SMAX. Can we have the SMAX use in a following patch?
Otherwise:

Reviewed-by: Philippe Mathieu-Daudé <[email protected]>

+    } else {
+        int width = tcg_type_size(type) * 8;
+        tcg_gen_sari(type, tmp, src, width - 1);
+        tcg_gen_xor(type, dst, src, tmp);
+        tcg_gen_sub(type, dst, dst, tmp);
+    }
+}
+
  void tcg_gen_add(TCGType type, TCGTemp *dst, TCGTemp *src1, TCGTemp *src2)
  {
      tcg_gen_op_ttt(INDEX_op_add, type, dst, src1, src2);
@@ -1377,16 +1392,6 @@ void tcg_gen_ussub_i32(TCGv_i32 ret, TCGv_i32 a, 
TCGv_i32 b)
      tcg_temp_free_i32(t);
  }
-void tcg_gen_abs_i32(TCGv_i32 ret, TCGv_i32 a)
-{
-    TCGv_i32 t = tcg_temp_ebb_new_i32();
-
-    tcg_gen_sari_i32(t, a, 31);
-    tcg_gen_xor_i32(ret, a, t);
-    tcg_gen_sub_i32(ret, ret, t);
-    tcg_temp_free_i32(t);
-}


Reply via email to