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, 4.5] Make fwprop find out that non-virtual constant member pointers are non-virtual


2009/3/24 Martin Jambor <mjambor@suse.cz>:
> Hi,
>
> this is a second attempt to partially fix PR 3713 - partial in the
> sence that it does away with the rather embarrasing run-time
> condition, for more details see the thread that started with the first
> attempt:
>
> http://gcc.gnu.org/ml/gcc-patches/2009-03/msg00536.html
>
> The patch below takes the core of the fix to fold-const.c by partially
> undoing the fix ?for PR 35705. ?I believe that ?this shouls still work
> on any target on which member pointers work. ?I have not verified on a
> hppa yet because gcc61 was down ?until recently. ?I will test it there
> tomorrow. ?The hunks in tree-ssa-forwprop.c is not necessary (a tleast
> not for the ?test case), FRE would manage to get ?rid of the condition
> even without it. ?However, this way ?we get rid of it sooner (and hey,
> once we might be able to do so in the early fwprop).
>
> I have bootstrapped and tested this on x86_64-linux. ?Provided it does
> not reintroduce PR 35705, is it OK for 4.5?

This is ok for 4.5 if you check ...

> Thanks,
>
> Martin
>
> 2009-03-24 ?Martin Jambor ?<mjambor@suse.cz>
>
> ? ? ? ?* fold-const.c (get_pointer_modulus_and_residue): New parameter
> ? ? ? ?allow_func_align.
> ? ? ? ?(fold_binary): Allow function decl aligment consideration is the
> ? ? ? ?second argument is integer constant one.
> ? ? ? ?* tree-ssa-forwprop.c (simplify_bitwise_and): New function.
> ? ? ? ?(tree_ssa_forward_propagate_single_use_vars): Handle assing statements
> ? ? ? ?with BIT_AND_EXPR on the RHS by calling simplify_bitwise_and.
>
> Index: iinln/gcc/tree-ssa-forwprop.c
> ===================================================================
> --- iinln.orig/gcc/tree-ssa-forwprop.c
> +++ iinln/gcc/tree-ssa-forwprop.c
> @@ -147,6 +147,14 @@ along with GCC; see the file COPYING3.
>
> ? ? ?ptr2 = &x[index];
>
> + ?Or
> + ? ?ssa = (int) decl
> + ? ?res = ssa & 1
> +
> + ?Provided that decl has known alignment >= 2, will get turned into
> +
> + ? ?res = 0
> +
> ? We also propagate casts into SWITCH_EXPR and COND_EXPR conditions to
> ? allow us to remove the cast and {NOT_EXPR,NEG_EXPR} into a subsequent
> ? {NOT_EXPR,NEG_EXPR}.
> @@ -1124,6 +1132,42 @@ simplify_gimple_switch (gimple stmt)
> ? ? }
> ?}
>
> +/* Run bitwise and assignments throug the folder. ?If the first argument is an
> + ? ssa name that is itself a result of a typecast of an ADDR_EXPR to an
> + ? integer, feed the ADDR_EXPR to the folder rather than the ssa name.
> +*/
> +
> +static void
> +simplify_bitwise_and (gimple_stmt_iterator *gsi, gimple stmt)
> +{
> + ?tree res;
> + ?tree arg1 = gimple_assign_rhs1 (stmt);
> + ?tree arg2 = gimple_assign_rhs2 (stmt);

if (TREE_CODE (arg2) != INTEGER_CST)
  return;

> + ?if (TREE_CODE (arg1) == SSA_NAME && !SSA_NAME_IS_DEFAULT_DEF (arg1))
> + ? ?{
> + ? ? ?gimple def = SSA_NAME_DEF_STMT (arg1);
> +
> + ? ? ?if (gimple_assign_cast_p (def)
> + ? ? ? ? && INTEGRAL_TYPE_P (gimple_expr_type (def)))
> + ? ? ? {
> + ? ? ? ? tree op = gimple_assign_rhs1 (def);
> +
> + ? ? ? ? if (TREE_CODE (op) == ADDR_EXPR)
> + ? ? ? ? ? arg1 = op;
> + ? ? ? }
> + ? ?}
> +
> + ?res = fold_binary (BIT_AND_EXPR, TREE_TYPE (gimple_assign_lhs (stmt)),
> + ? ? ? ? ? ? ? ? ? ?arg1, arg2);
> + ?if (res)

and

&& is_gimple_min_invariant (res)

here.

Thanks,
Richard.


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