On Thu, Jul 21, 2011 at 5:57 AM, DJ Delorie <d...@redhat.com> wrote:
>
> In this PR, a cast to a volatile type is lost during forwprop1,
> resulting in the wrong access semantics being used for a memory-mapped
> peripheral register.  Checking for loss of volatile in this patch
> solves the problem, but I don't know if this is the right place to put
> such a test - it could go in tree-ssa-forwprop.c also, to be specific
> to this bug.
>
> Comments?

The patch is not correct, it papers over a problem elsewhere (maybe
in forwprop).

I can't btw reproduce the issue on either the 4.5 or the 4.6 branch or trunk
with the testcase from the PR.  I always get

  v_2 ={v} st_1(D)->ptr;

in the .optimized tree dump which correctly states this is a volatile load.

So - if there is an issue on some target then it is to be found in either
RTL expansion code or target specific code, not in the tree optimizers.

On x86_64 I again see a correct

(insn 6 5 0 t.c:7 (set (reg/v:SI 58 [ v ])
        (mem/s/v:SI (reg/v/f:DI 60 [ st ]) [3 st_1(D)->ptr+0 S4 A8])) -1 (nil))

btw. (notice MEM_VOLATILE).

Richard.

> Index: tree-ssa.c
> ===================================================================
> --- tree-ssa.c  (revision 176495)
> +++ tree-ssa.c  (working copy)
> @@ -1274,12 +1274,18 @@ useless_type_conversion_p (tree outer_ty
>
>       /* If the outer type is (void *), the conversion is not necessary.  */
>       if (VOID_TYPE_P (TREE_TYPE (outer_type)))
>        return true;
>     }
>
> +  /* Do not lose casts to volatile qualified types.  */
> +  if ((TYPE_VOLATILE (outer_type)
> +       != TYPE_VOLATILE (inner_type))
> +      && TYPE_VOLATILE (outer_type))
> +    return false;
> +
>   /* From now on qualifiers on value types do not matter.  */
>   inner_type = TYPE_MAIN_VARIANT (inner_type);
>   outer_type = TYPE_MAIN_VARIANT (outer_type);
>
>   if (inner_type == outer_type)
>     return true;
>

Reply via email to