[PATCH] Fix sra_explode_bitfield_assignment

Richard Guenther richard.guenther@gmail.com
Fri Dec 5 17:16:00 GMT 2008


On Fri, Dec 5, 2008 at 5:32 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> Hi!
>
> The PR middle-end/37248 patch I've just posted regressed bf64-1.c
> test at -O[23s] on x86_64-linux, -fno-tree-sra fixed that.
>
> The problem is that SRA is expecting that unsigned_type_for (and
> lang_hooks.types.type_for_size) will return a type with
> TYPE_PRECISION it was asking for, but it can return a larger type.
> So for a signed 52 bit bitfield, it just casted the signed:52
> value to (unsigned long) and so no masking of the topmost 12 bits
> was performed.
>
> Fixed thusly, bootstrapped/regtested on x86_64-linux, ok for trunk?

Ok.

Thanks,
Richard.

> 2008-12-05  Jakub Jelinek  <jakub@redhat.com>
>
>        * tree-sra.c (sra_explode_bitfield_assignment): Always
>        call unsigned_type_for, if the precision is higher than
>        needed, call build_nonstandard_integer_type.
>
> --- gcc/tree-sra.c.jj   2008-12-03 16:32:17.000000000 +0100
> +++ gcc/tree-sra.c      2008-12-05 13:23:59.000000000 +0100
> @@ -3013,11 +3013,9 @@ sra_explode_bitfield_assignment (tree va
>
>          infld = fld->replacement;
>
> -         type = TREE_TYPE (infld);
> +         type = unsigned_type_for (TREE_TYPE (infld));
>          if (TYPE_PRECISION (type) != TREE_INT_CST_LOW (flen))
> -           type = lang_hooks.types.type_for_size (TREE_INT_CST_LOW (flen), 1);
> -         else
> -           type = unsigned_type_for (type);
> +           type = build_nonstandard_integer_type (TREE_INT_CST_LOW (flen), 1);
>
>          if (TREE_CODE (infld) == BIT_FIELD_REF)
>            {
>
>        Jakub
>



More information about the Gcc-patches mailing list