xionghu luo <[email protected]> writes:
> @@ -2658,6 +2659,43 @@ expand_vect_cond_mask_optab_fn (internal_fn, gcall
> *stmt, convert_optab optab)
>
> #define expand_vec_cond_mask_optab_fn expand_vect_cond_mask_optab_fn
>
> +/* Expand VEC_SET internal functions. */
> +
> +static void
> +expand_vec_set_optab_fn (internal_fn, gcall *stmt, convert_optab optab)
> +{
> + tree lhs = gimple_call_lhs (stmt);
> + tree op0 = gimple_call_arg (stmt, 0);
> + tree op1 = gimple_call_arg (stmt, 1);
> + tree op2 = gimple_call_arg (stmt, 2);
> + rtx target = expand_expr (lhs, NULL_RTX, VOIDmode, EXPAND_WRITE);
> + rtx src = expand_expr (op0, NULL_RTX, VOIDmode, EXPAND_WRITE);
I'm not sure about the expand_expr here. ISTM that op0 is a normal
input and so should be expanded by expand_normal rather than
EXPAND_WRITE. Also:
> +
> + machine_mode outermode = TYPE_MODE (TREE_TYPE (op0));
> + scalar_mode innermode = GET_MODE_INNER (outermode);
> +
> + rtx value = expand_expr (op1, NULL_RTX, VOIDmode, EXPAND_NORMAL);
> + rtx pos = expand_expr (op2, NULL_RTX, VOIDmode, EXPAND_NORMAL);
> +
> + class expand_operand ops[3];
> + enum insn_code icode = optab_handler (optab, outermode);
> +
> + if (icode != CODE_FOR_nothing)
> + {
> + pos = convert_to_mode (E_SImode, pos, 0);
> +
> + create_fixed_operand (&ops[0], src);
...this would mean that if SRC happens to be a MEM, the pattern
must also accept a MEM.
ISTM that we're making more work for ourselves by not “fixing” the optab
to have a natural pure-input + pure-output interface. :-) But if we
stick with the current optab interface, I think we need to:
- create a temporary register
- move SRC into the temporary register before the insn
- use create_fixed_operand with the temporary register for operand 0
- move the temporary register into TARGET after the insn
> + create_input_operand (&ops[1], value, innermode);
> + create_input_operand (&ops[2], pos, GET_MODE (pos));
For this I think we should use convert_operand_from on the original “pos”,
so that the target gets to choose what the mode of the operand is.
Thanks,
Richard