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?
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;