Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't create a constant node for Vector64 #105538

Merged
merged 2 commits into from
Jul 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 5 additions & 13 deletions src/mono/mono/mini/simd-intrinsics.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 = true;
gboolean some_const = false;

guint8 cns_vec[16];
Expand All @@ -1352,10 +1351,8 @@ emit_vector_create_elementwise (
if (vector_size == 16) {
for (int i = 0; i < param_count; ++i) {
if (!is_const (args[i])) {
all_const = false;
break;
Comment on lines -1355 to -1356
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was the remaining issue.

Mono only supports 128-bit xconst today, but we're still trying to handle the case where only some inputs are constant; such as Vector128.Create(1, 2, x, 4). This was early exiting in the case that not all inputs were constant so in the main loop below we ended up getting Vector128.Create(1, 2, x, 0) instead.

Fixed it to not early exit and only skip parameters if some were constant; which lets us get the correct value instead.

continue;
}

some_const = true;

if (type_enum_is_float (etype->type)) {
Expand Down Expand Up @@ -1418,10 +1415,6 @@ emit_vector_create_elementwise (
}
}

if (all_const) {
return emit_xconst_v128 (cfg, vklass, (guint8*)cns_vec);
}

MonoInst *ins;

if (some_const) {
Expand All @@ -1431,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;
}

Expand Down Expand Up @@ -1484,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: {
Expand Down
Loading