aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMartin Jambor <mjambor@suse.cz>2016-05-20 23:04:31 +0200
committerMartin Jambor <jamborm@gcc.gnu.org>2016-05-20 23:04:31 +0200
commitc91a0948c3d72d8625111b5c5b6a0392c8830bb5 (patch)
treef3ee0dbb42bb38da5e7953b8f8168c1ce28cb200 /gcc
parent4727d4c6a81774e9b1de91a5e7089c6d17cc6d37 (diff)
downloadgcc-c91a0948c3d72d8625111b5c5b6a0392c8830bb5.zip
gcc-c91a0948c3d72d8625111b5c5b6a0392c8830bb5.tar.gz
gcc-c91a0948c3d72d8625111b5c5b6a0392c8830bb5.tar.bz2
[PR 70884] Constant pool SRA fix
2016-05-20 Martin Jambor <mjambor@suse.cz> PR tree-optimization/70884 * tree-sra.c (initialize_constant_pool_replacements): Do not check should_scalarize_away_bitmap and cannot_scalarize_away_bitmap bits. (sort_and_splice_var_accesses): Do not consider multiple scalar reads of constant pool data as a reason for scalarization. testsuite/ * gcc.dg/tree-ssa/pr70919.c: New test. From-SVN: r236544
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/pr70919.c46
-rw-r--r--gcc/tree-sra.c54
4 files changed, 86 insertions, 27 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 8d6d3c4..dc38a17 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+2016-05-20 Martin Jambor <mjambor@suse.cz>
+
+ PR tree-optimization/70884
+ * tree-sra.c (initialize_constant_pool_replacements): Do not check
+ should_scalarize_away_bitmap and cannot_scalarize_away_bitmap bits.
+ (sort_and_splice_var_accesses): Do not consider multiple scalar reads
+ of constant pool data as a reason for scalarization.
+
2016-05-20 Eric Botcazou <ebotcazou@adacore.com>
* config/arm/arm.c (arm_expand_prologue): Set the stack usage to 0
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index cdb5fea..b4ae113 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2016-05-20 Martin Jambor <mjambor@suse.cz>
+
+ PR tree-optimization/70884
+ * gcc.dg/tree-ssa/pr70919.c: New test.
+
2016-05-20 Bill Seurer <seurer@linux.vnet.ibm.com>
* gcc.target/powerpc/vec-adde.c: Change dejagnu options, fix code
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr70919.c b/gcc/testsuite/gcc.dg/tree-ssa/pr70919.c
new file mode 100644
index 0000000..bed0ab3
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr70919.c
@@ -0,0 +1,46 @@
+/* { dg-do run } */
+/* { dg-options "-O" } */
+
+#pragma pack(1)
+struct S0
+{
+ int f0:24;
+};
+
+struct S1
+{
+ int f1;
+} a;
+
+int b, c;
+
+char
+fn1 (struct S1 p1)
+{
+ return 0;
+}
+
+int
+main ()
+{
+ c = fn1 (a);
+ if (b)
+ {
+ struct S0 f[3][9] =
+ { { { 0 }, { 0 }, { 1 }, { 1 }, { 0 }, { 0 }, { 0 }, { 1 }, { 1 } },
+ { { 0 }, { 0 }, { 1 }, { 1 }, { 0 }, { 0 }, { 0 }, { 1 }, { 1 } },
+ { { 0 }, { 0 }, { 1 }, { 1 }, { 0 }, { 0 }, { 0 }, { 1 }, { 1 } }
+ };
+ b = f[1][8].f0;
+ }
+ struct S0 g[3][9] =
+ { { { 0 }, { 0 }, { 1 }, { 1 }, { 0 }, { 0 }, { 0 }, { 1 }, { 1 } },
+ { { 0 }, { 0 }, { 1 }, { 1 }, { 0 }, { 0 }, { 0 }, { 1 }, { 1 } },
+ { { 0 }, { 0 }, { 1 }, { 1 }, { 0 }, { 0 }, { 0 }, { 1 }, { 1 } }
+ };
+
+ if (g[1][8].f0 != 1)
+ __builtin_abort ();
+
+ return 0;
+}
diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c
index 936d3a6..7c0e90d 100644
--- a/gcc/tree-sra.c
+++ b/gcc/tree-sra.c
@@ -2074,7 +2074,8 @@ sort_and_splice_var_accesses (tree var)
access->grp_scalar_write = grp_scalar_write;
access->grp_assignment_read = grp_assignment_read;
access->grp_assignment_write = grp_assignment_write;
- access->grp_hint = multiple_scalar_reads || total_scalarization;
+ access->grp_hint = total_scalarization
+ || (multiple_scalar_reads && !constant_decl_p (var));
access->grp_total_scalarization = total_scalarization;
access->grp_partial_lhs = grp_partial_lhs;
access->grp_unscalarizable_region = unscalarizable_region;
@@ -3559,32 +3560,31 @@ initialize_constant_pool_replacements (void)
unsigned i;
EXECUTE_IF_SET_IN_BITMAP (candidate_bitmap, 0, i, bi)
- if (bitmap_bit_p (should_scalarize_away_bitmap, i)
- && !bitmap_bit_p (cannot_scalarize_away_bitmap, i))
- {
- tree var = candidate (i);
- if (!constant_decl_p (var))
- continue;
- vec<access_p> *access_vec = get_base_access_vector (var);
- if (!access_vec)
- continue;
- for (unsigned i = 0; i < access_vec->length (); i++)
- {
- struct access *access = (*access_vec)[i];
- if (!access->replacement_decl)
- continue;
- gassign *stmt = gimple_build_assign (
- get_access_replacement (access), unshare_expr (access->expr));
- if (dump_file && (dump_flags & TDF_DETAILS))
- {
- fprintf (dump_file, "Generating constant initializer: ");
- print_gimple_stmt (dump_file, stmt, 0, 1);
- fprintf (dump_file, "\n");
- }
- gsi_insert_after (&gsi, stmt, GSI_NEW_STMT);
- update_stmt (stmt);
- }
- }
+ {
+ tree var = candidate (i);
+ if (!constant_decl_p (var))
+ continue;
+ vec<access_p> *access_vec = get_base_access_vector (var);
+ if (!access_vec)
+ continue;
+ for (unsigned i = 0; i < access_vec->length (); i++)
+ {
+ struct access *access = (*access_vec)[i];
+ if (!access->replacement_decl)
+ continue;
+ gassign *stmt
+ = gimple_build_assign (get_access_replacement (access),
+ unshare_expr (access->expr));
+ if (dump_file && (dump_flags & TDF_DETAILS))
+ {
+ fprintf (dump_file, "Generating constant initializer: ");
+ print_gimple_stmt (dump_file, stmt, 0, 1);
+ fprintf (dump_file, "\n");
+ }
+ gsi_insert_after (&gsi, stmt, GSI_NEW_STMT);
+ update_stmt (stmt);
+ }
+ }
seq = gsi_seq (gsi);
if (seq)