tcg/optimize: Move fold_cmp_vec, fold_cmpsel_vec into alphabetic sort

The big comment just above says functions should be sorted.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
Richard Henderson 2024-12-09 14:09:49 -06:00
parent 7d3c63aca1
commit 29f6586f61

View File

@ -1619,6 +1619,36 @@ static bool fold_call(OptContext *ctx, TCGOp *op)
return true;
}
static bool fold_cmp_vec(OptContext *ctx, TCGOp *op)
{
/* Canonicalize the comparison to put immediate second. */
if (swap_commutative(NO_DEST, &op->args[1], &op->args[2])) {
op->args[3] = tcg_swap_cond(op->args[3]);
}
return finish_folding(ctx, op);
}
static bool fold_cmpsel_vec(OptContext *ctx, TCGOp *op)
{
/* If true and false values are the same, eliminate the cmp. */
if (args_are_copies(op->args[3], op->args[4])) {
return tcg_opt_gen_mov(ctx, op, op->args[0], op->args[3]);
}
/* Canonicalize the comparison to put immediate second. */
if (swap_commutative(NO_DEST, &op->args[1], &op->args[2])) {
op->args[5] = tcg_swap_cond(op->args[5]);
}
/*
* Canonicalize the "false" input reg to match the destination,
* so that the tcg backend can implement "move if true".
*/
if (swap_commutative(op->args[0], &op->args[4], &op->args[3])) {
op->args[5] = tcg_invert_cond(op->args[5]);
}
return finish_folding(ctx, op);
}
static bool fold_count_zeros(OptContext *ctx, TCGOp *op)
{
uint64_t z_mask, s_mask;
@ -2519,36 +2549,6 @@ static bool fold_setcond2(OptContext *ctx, TCGOp *op)
return tcg_opt_gen_movi(ctx, op, op->args[0], i);
}
static bool fold_cmp_vec(OptContext *ctx, TCGOp *op)
{
/* Canonicalize the comparison to put immediate second. */
if (swap_commutative(NO_DEST, &op->args[1], &op->args[2])) {
op->args[3] = tcg_swap_cond(op->args[3]);
}
return finish_folding(ctx, op);
}
static bool fold_cmpsel_vec(OptContext *ctx, TCGOp *op)
{
/* If true and false values are the same, eliminate the cmp. */
if (args_are_copies(op->args[3], op->args[4])) {
return tcg_opt_gen_mov(ctx, op, op->args[0], op->args[3]);
}
/* Canonicalize the comparison to put immediate second. */
if (swap_commutative(NO_DEST, &op->args[1], &op->args[2])) {
op->args[5] = tcg_swap_cond(op->args[5]);
}
/*
* Canonicalize the "false" input reg to match the destination,
* so that the tcg backend can implement "move if true".
*/
if (swap_commutative(op->args[0], &op->args[4], &op->args[3])) {
op->args[5] = tcg_invert_cond(op->args[5]);
}
return finish_folding(ctx, op);
}
static bool fold_sextract(OptContext *ctx, TCGOp *op)
{
uint64_t z_mask, s_mask, s_mask_old;