Skip to content

Commit ea3f2af

Browse files
committed
tcg/s390x: Implement TCG_TARGET_HAS_cmpsel_vec
This is via expansion; don't actually set TCG_TARGET_HAS_cmpsel_vec. Signed-off-by: Richard Henderson <[email protected]>
1 parent 9bca986 commit ea3f2af

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

tcg/s390x/tcg-target.c.inc

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2869,6 +2869,7 @@ int tcg_can_emit_vec_op(TCGOpcode opc, TCGType type, unsigned vece)
28692869
case INDEX_op_xor_vec:
28702870
return 1;
28712871
case INDEX_op_cmp_vec:
2872+
case INDEX_op_cmpsel_vec:
28722873
case INDEX_op_rotrv_vec:
28732874
return -1;
28742875
case INDEX_op_mul_vec:
@@ -2931,6 +2932,21 @@ static void expand_vec_cmp(TCGType type, unsigned vece, TCGv_vec v0,
29312932
}
29322933
}
29332934

2935+
static void expand_vec_cmpsel(TCGType type, unsigned vece, TCGv_vec v0,
2936+
TCGv_vec c1, TCGv_vec c2,
2937+
TCGv_vec v3, TCGv_vec v4, TCGCond cond)
2938+
{
2939+
TCGv_vec t = tcg_temp_new_vec(type);
2940+
2941+
if (expand_vec_cmp_noinv(type, vece, t, c1, c2, cond)) {
2942+
/* Invert the sense of the compare by swapping arguments. */
2943+
tcg_gen_bitsel_vec(vece, v0, t, v4, v3);
2944+
} else {
2945+
tcg_gen_bitsel_vec(vece, v0, t, v3, v4);
2946+
}
2947+
tcg_temp_free_vec(t);
2948+
}
2949+
29342950
static void expand_vec_sat(TCGType type, unsigned vece, TCGv_vec v0,
29352951
TCGv_vec v1, TCGv_vec v2, TCGOpcode add_sub_opc)
29362952
{
@@ -2972,7 +2988,7 @@ void tcg_expand_vec_op(TCGOpcode opc, TCGType type, unsigned vece,
29722988
TCGArg a0, ...)
29732989
{
29742990
va_list va;
2975-
TCGv_vec v0, v1, v2, t0;
2991+
TCGv_vec v0, v1, v2, v3, v4, t0;
29762992

29772993
va_start(va, a0);
29782994
v0 = temp_tcgv_vec(arg_temp(a0));
@@ -2984,6 +3000,12 @@ void tcg_expand_vec_op(TCGOpcode opc, TCGType type, unsigned vece,
29843000
expand_vec_cmp(type, vece, v0, v1, v2, va_arg(va, TCGArg));
29853001
break;
29863002

3003+
case INDEX_op_cmpsel_vec:
3004+
v3 = temp_tcgv_vec(arg_temp(va_arg(va, TCGArg)));
3005+
v4 = temp_tcgv_vec(arg_temp(va_arg(va, TCGArg)));
3006+
expand_vec_cmpsel(type, vece, v0, v1, v2, v3, v4, va_arg(va, TCGArg));
3007+
break;
3008+
29873009
case INDEX_op_rotrv_vec:
29883010
t0 = tcg_temp_new_vec(type);
29893011
tcg_gen_neg_vec(vece, t0, v2);

0 commit comments

Comments
 (0)