This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH, PR 61090] Pass gsi to build_ref_for_model in sra_modify_expr
- From: Martin Jambor <mjambor at suse dot cz>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Cc: Richard Biener <rguenther at suse dot de>
- Date: Thu, 15 May 2014 16:34:47 +0200
- Subject: [PATCH, PR 61090] Pass gsi to build_ref_for_model in sra_modify_expr
- Authentication-results: sourceware.org; auth=none
Hi,
my patch switching to more correct alias introduced an error into the
call of build_ref_for_model also in sra_modify_expr (when avoiding
VIEW_CONVERT_EXPR). We are no longer using access->base as the base
for the memory expression being built, but rather the original
expression from the source. This means we may encounter an ARRAY_REF
and need an iterator for producing potential extra statements.
Fixed simply by the following patch which provides the iterator we
have at hand. Bootstrapped and tested on x86_64-linux. OK for trunk?
Thanks,
Martin
2014-05-14 Martin Jambor <mjambor@suse.cz>
PR tree-optimization/61090
* tree-sra.c (sra_modify_expr): Pass the current gsi to
build_ref_for_model.
testsuite/
* gcc.dg/tree-ssa/pr61090.c: New test.
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr61090.c b/gcc/testsuite/gcc.dg/tree-ssa/pr61090.c
new file mode 100644
index 0000000..fff2895
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr61090.c
@@ -0,0 +1,21 @@
+/* { dg-do compile } */
+/* { dg-options "-O" } */
+
+struct i {
+ int c;
+};
+
+static int
+p(struct i a)
+{
+ return 0;
+}
+
+void
+h(void)
+{
+ struct i z[] = {{ 0 }};
+ int e[] = {};
+ int x;
+ e[0] = p(z[x]) + z[x].c;
+}
diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c
index 72c485b..ef6c966 100644
--- a/gcc/tree-sra.c
+++ b/gcc/tree-sra.c
@@ -2812,7 +2812,7 @@ sra_modify_expr (tree *expr, gimple_stmt_iterator *gsi, bool write)
{
tree ref;
- ref = build_ref_for_model (loc, orig_expr, 0, access, NULL, false);
+ ref = build_ref_for_model (loc, orig_expr, 0, access, gsi, false);
if (write)
{