[tree-ssa] CCP for bitfields [patch]

Richard Henderson rth@redhat.com
Mon Aug 19 16:44:00 GMT 2002


On Sun, Aug 18, 2002 at 09:44:45PM -0400, Diego Novillo wrote:
> +static tree
> +widen_bitfield (val, field, var)
> +     tree val;
> +     tree field;
> +     tree var;

What is the purpose of passing in VAR?  Isn't it only FIELD that 
is relevant?  That's where you get the width of the field...

> +      for (i = 0, mask = 0; i < field_size; i++)
> +	mask |= 1 << i;
> +
> +      wide_val = build (BIT_AND_EXPR, TREE_TYPE (var), val, 
> +			build_int_2 (mask, 0));

I see.  You are confused.  This should be

	low &= ~((HOST_WIDE_INT) -1 << field_size)
	wide_val = build_int_2 (mask, 0);

	TREE_TYPE (wide_val) = TREE_TYPE (field);

> +      for (i = 0, mask = 0; i < (var_size - field_size); i++)
> +	mask |= 1 << (var_size - i - 1);

Similarly,

	low |= (HOST_WIDE_INT) -1 << field_size;
	wide_val = build_int_2 (mask, -1);



r~



More information about the Gcc-patches mailing list