This patch fixes a miscompilation of stage1 c-parser.o in an ARM bootstrap.
When an access to an enum field was SRAed, a component ref used the type
of the integer temporary variable instead of the type of the enum.
It therefore didn't alias other accesses to the same structure,
and was scheduled after a copy-load.

Tested on x86_64-linux-gnu, and by verifying that c-parser.o is correctly
compiled for ARM after the patch.  Martin says he's going to test on ia64
too (thanks) -- I'll add 50326 to the changelog if that goes OK.

OK to install if there are no regressions on ia64?

Richard


gcc/
        PR middle-end/50386
        * tree-sra.c (build_ref_for_model): Use the type of the field as
        the type of the COMPONENT_REF.

Index: gcc/tree-sra.c
===================================================================
--- gcc/tree-sra.c      2011-09-12 09:09:34.000000000 +0100
+++ gcc/tree-sra.c      2011-09-27 14:09:45.379960167 +0100
@@ -1504,7 +1504,7 @@ build_ref_for_model (location_t loc, tre
       offset -= TREE_INT_CST_LOW (DECL_FIELD_BIT_OFFSET (fld));
       exp_type = TREE_TYPE (TREE_OPERAND (model->expr, 0));
       t = build_ref_for_offset (loc, base, offset, exp_type, gsi, 
insert_after);
-      return fold_build3_loc (loc, COMPONENT_REF, model->type, t, fld,
+      return fold_build3_loc (loc, COMPONENT_REF, TREE_TYPE (fld), t, fld,
                              TREE_OPERAND (model->expr, 2));
     }
   else

Reply via email to