From 789917a8a8532db325aecfa4e496dbddab34f5b4 Mon Sep 17 00:00:00 2001 From: Tanner Gooding Date: Thu, 25 Jul 2024 21:51:18 -0700 Subject: [PATCH 1/2] Don't create a constant node for Vector64 --- src/mono/mono/mini/simd-intrinsics.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/mono/mono/mini/simd-intrinsics.c b/src/mono/mono/mini/simd-intrinsics.c index 54588a2f2dfdf..e25ae72f08a92 100644 --- a/src/mono/mono/mini/simd-intrinsics.c +++ b/src/mono/mono/mini/simd-intrinsics.c @@ -1342,7 +1342,7 @@ emit_vector_create_elementwise ( // optimizations can be enabled. This includes recognizing partial constants // and only performing the minimal number of inserts required - gboolean all_const = true; + gboolean all_const = false; gboolean some_const = false; guint8 cns_vec[16]; @@ -1350,6 +1350,8 @@ emit_vector_create_elementwise ( int vector_size = mono_class_value_size (vklass, NULL); if (vector_size == 16) { + all_const = true; + for (int i = 0; i < param_count; ++i) { if (!is_const (args[i])) { all_const = false; From 1c9a79cb4be6b17475f5e8ee0f2011b44d8249e3 Mon Sep 17 00:00:00 2001 From: Tanner Gooding Date: Fri, 26 Jul 2024 15:31:23 -0700 Subject: [PATCH 2/2] Ensure we process all arguments so the some_const case is correct --- src/mono/mono/mini/simd-intrinsics.c | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/src/mono/mono/mini/simd-intrinsics.c b/src/mono/mono/mini/simd-intrinsics.c index e25ae72f08a92..b387323b19312 100644 --- a/src/mono/mono/mini/simd-intrinsics.c +++ b/src/mono/mono/mini/simd-intrinsics.c @@ -1342,7 +1342,6 @@ emit_vector_create_elementwise ( // optimizations can be enabled. This includes recognizing partial constants // and only performing the minimal number of inserts required - gboolean all_const = false; gboolean some_const = false; guint8 cns_vec[16]; @@ -1350,14 +1349,10 @@ emit_vector_create_elementwise ( int vector_size = mono_class_value_size (vklass, NULL); if (vector_size == 16) { - all_const = true; - for (int i = 0; i < param_count; ++i) { if (!is_const (args[i])) { - all_const = false; - break; + continue; } - some_const = true; if (type_enum_is_float (etype->type)) { @@ -1420,10 +1415,6 @@ emit_vector_create_elementwise ( } } - if (all_const) { - return emit_xconst_v128 (cfg, vklass, (guint8*)cns_vec); - } - MonoInst *ins; if (some_const) { @@ -1433,11 +1424,11 @@ emit_vector_create_elementwise ( } for (int i = 0; i < param_count; ++i) { - if (!is_const (args[i]) || (vector_size != 16)) { - ins = emit_vector_insert_element (cfg, vklass, ins, etype->type, args[i], i, TRUE); + if (some_const && is_const (args[i])) { + continue; } + ins = emit_vector_insert_element (cfg, vklass, ins, etype->type, args[i], i, TRUE); } - return ins; } @@ -1486,8 +1477,7 @@ emit_vector_create_scalar ( } else { g_assert (arg0->opcode == OP_I8CONST); cns_val = arg0->inst_l; - -} + } switch (etype->type) { case MONO_TYPE_I1: case MONO_TYPE_U1: {