This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Restore removal of useless masking in store_field after expand-from-SSA


On Tue, May 5, 2009 at 9:36 PM, Adam Nemet <anemet@caviumnetworks.com> wrote:
> This fixes the last MIPS failure (gcc.target/mips/ins-2.c) after
> expand-from-SSA.
>
> When expading a bit-field store we need to look at the defining gimple
> statement for the redundant masking conversion. ?The reason is that LHS of the
> assignment is not a gimple reg so RHS can't include a useful conversion.
>
> Bootstrapping and regtesting on mips64octeon-linux. ?OK if it passes?

Ok.

Thanks,
Richard.

> Adam
>
>
> ? ? ? ?* expr.c (get_def_for_expr): Move it up in the file.
> ? ? ? ?(store_field): When expanding a bit-field store, look at the
> ? ? ? ?defining gimple stmt for the masking conversion.
>
> --- expr.c~ ? ? 2009-05-02 17:31:40.000000000 -0700
> +++ expr.c ? ? ?2009-05-05 00:38:22.000000000 -0700
> @@ -2249,6 +2249,26 @@ use_group_regs (rtx *call_fusage, rtx re
> ? ? ? ?use_reg (call_fusage, reg);
> ? ? }
> ?}
> +
> +/* Return the defining gimple statement for SSA_NAME NAME if it is an
> + ? assigment and the code of the expresion on the RHS is CODE. ?Return
> + ? NULL otherwise. ?*/
> +
> +static gimple
> +get_def_for_expr (tree name, enum tree_code code)
> +{
> + ?gimple def_stmt;
> +
> + ?if (TREE_CODE (name) != SSA_NAME)
> + ? ?return NULL;
> +
> + ?def_stmt = get_gimple_for_ssa_name (name);
> + ?if (!def_stmt
> + ? ? ?|| gimple_assign_rhs_code (def_stmt) != code)
> + ? ?return NULL;
> +
> + ?return def_stmt;
> +}
>
>
> ?/* Determine whether the LEN bytes generated by CONSTFUN can be
> @@ -5776,22 +5796,25 @@ store_field (rtx target, HOST_WIDE_INT b
> ? ? ? ? ?&& compare_tree_int (TYPE_SIZE (TREE_TYPE (exp)), bitsize) != 0))
> ? ? {
> ? ? ? rtx temp;
> + ? ? ?gimple nop_def;
>
> ? ? ? /* If EXP is a NOP_EXPR of precision less than its mode, then that
> ? ? ? ? implies a mask operation. ?If the precision is the same size as
> ? ? ? ? the field we're storing into, that mask is redundant. ?This is
> ? ? ? ? particularly common with bit field assignments generated by the
> ? ? ? ? C front end. ?*/
> - ? ? ?if (TREE_CODE (exp) == NOP_EXPR)
> + ? ? ?nop_def = get_def_for_expr (exp, NOP_EXPR);
> + ? ? ?if (nop_def)
> ? ? ? ?{
> ? ? ? ? ?tree type = TREE_TYPE (exp);
> ? ? ? ? ?if (INTEGRAL_TYPE_P (type)
> ? ? ? ? ? ? ?&& TYPE_PRECISION (type) < GET_MODE_BITSIZE (TYPE_MODE (type))
> ? ? ? ? ? ? ?&& bitsize == TYPE_PRECISION (type))
> ? ? ? ? ? ?{
> - ? ? ? ? ? ? type = TREE_TYPE (TREE_OPERAND (exp, 0));
> + ? ? ? ? ? ? tree op = gimple_assign_rhs1 (nop_def);
> + ? ? ? ? ? ? type = TREE_TYPE (op);
> ? ? ? ? ? ? ?if (INTEGRAL_TYPE_P (type) && TYPE_PRECISION (type) >= bitsize)
> - ? ? ? ? ? ? ? exp = TREE_OPERAND (exp, 0);
> + ? ? ? ? ? ? ? exp = op;
> ? ? ? ? ? ?}
> ? ? ? ?}
>
> @@ -6992,26 +7015,6 @@ expand_constructor (tree exp, rtx target
> ? return target;
> ?}
>
> -/* Return the defining gimple statement for SSA_NAME NAME if it is an
> - ? assigment and the code of the expresion on the RHS is CODE. ?Return
> - ? NULL otherwise. ?*/
> -
> -static gimple
> -get_def_for_expr (tree name, enum tree_code code)
> -{
> - ?gimple def_stmt;
> -
> - ?if (TREE_CODE (name) != SSA_NAME)
> - ? ?return NULL;
> -
> - ?def_stmt = get_gimple_for_ssa_name (name);
> - ?if (!def_stmt
> - ? ? ?|| gimple_assign_rhs_code (def_stmt) != code)
> - ? ?return NULL;
> -
> - ?return def_stmt;
> -}
> -
>
> ?/* expand_expr: generate code for computing expression EXP.
> ? ?An rtx for the computed value is returned. ?The value is never null.
>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]