https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63375

--- Comment #4 from Martin Jambor <jamborm at gcc dot gnu.org> ---
SRA is indeed quite guilty, the following patch fixes it:

diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c
index 8259dba..fb24114 100644
--- a/gcc/tree-sra.c
+++ b/gcc/tree-sra.c
@@ -1064,6 +1064,11 @@ build_access_from_expr_1 (tree expr, gimple stmt, bool
write)
                               "component.");
       return NULL;
     }
+  if (TREE_THIS_VOLATILE (expr))
+    {
+      disqualify_base_of_expr (expr, "part of a volatile reference.");
+      return NULL;
+    }

   switch (TREE_CODE (expr))
     {

Nevertheless, it is apparently not the only culprit.  Even on trunk
with -fno-tree-sra we produce exactly the same assembly output.  From
a brief look at the dumps it seems that RTL fwprop1 is the pass moving
the load, however I have not had a look if it is its fault or if
expansion looses the volatility information somehow.

Reply via email to