aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-sra.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2013-08-14 22:34:56 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2013-08-14 22:34:56 +0200
commit4ca890e22e169bdbb2399d0c6b7c98111164e86a (patch)
treebc091b34fe7a11663b0a6d55cd12119c1f69c179 /gcc/tree-sra.c
parenta7991d53a7672c78f554e31232dcdc0ef8b0e903 (diff)
downloadgcc-4ca890e22e169bdbb2399d0c6b7c98111164e86a.zip
gcc-4ca890e22e169bdbb2399d0c6b7c98111164e86a.tar.gz
gcc-4ca890e22e169bdbb2399d0c6b7c98111164e86a.tar.bz2
re PR middle-end/58145 (volatileness of write is discarded, perhaps in "lim1" related to loop optimizations)
PR tree-optimization/58145 * tree-sra.c (build_ref_for_offset): If prev_base has TREE_THIS_VOLATILE or TREE_SIDE_EFFECTS, propagate it to MEM_REF. * gcc.dg/pr58145-1.c: New test. * gcc.dg/pr58145-2.c: New test. From-SVN: r201748
Diffstat (limited to 'gcc/tree-sra.c')
-rw-r--r--gcc/tree-sra.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c
index 2bce848..8e3bb81 100644
--- a/gcc/tree-sra.c
+++ b/gcc/tree-sra.c
@@ -1466,6 +1466,7 @@ build_ref_for_offset (location_t loc, tree base, HOST_WIDE_INT offset,
{
tree prev_base = base;
tree off;
+ tree mem_ref;
HOST_WIDE_INT base_offset;
unsigned HOST_WIDE_INT misalign;
unsigned int align;
@@ -1516,7 +1517,12 @@ build_ref_for_offset (location_t loc, tree base, HOST_WIDE_INT offset,
if (align < TYPE_ALIGN (exp_type))
exp_type = build_aligned_type (exp_type, align);
- return fold_build2_loc (loc, MEM_REF, exp_type, base, off);
+ mem_ref = fold_build2_loc (loc, MEM_REF, exp_type, base, off);
+ if (TREE_THIS_VOLATILE (prev_base))
+ TREE_THIS_VOLATILE (mem_ref) = 1;
+ if (TREE_SIDE_EFFECTS (prev_base))
+ TREE_SIDE_EFFECTS (mem_ref) = 1;
+ return mem_ref;
}
/* Construct a memory reference to a part of an aggregate BASE at the given