aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@arm.com>2019-09-05 07:50:07 +0000
committerRichard Sandiford <rsandifo@gcc.gnu.org>2019-09-05 07:50:07 +0000
commit359f25f8e224cb398a732d2e7b499d6e8385a007 (patch)
tree5109160ca8dba4f4958a7f6f70770e84d87df17d /gcc
parentefd9a01b59eec33ff0bbba585a6e92c5a0234ed4 (diff)
downloadgcc-359f25f8e224cb398a732d2e7b499d6e8385a007.zip
gcc-359f25f8e224cb398a732d2e7b499d6e8385a007.tar.gz
gcc-359f25f8e224cb398a732d2e7b499d6e8385a007.tar.bz2
Force IFN_LOAD/STORE_LANES operands to be memory (PR91577)
This patch uses the workaround Richi suggested in the PR: make discover_nonconstant_array_refs mark the source of an IFN_LOAD_LANES call and the destination of an IFN_STORE_LANES call as addressable, so that they don't end up being REG rtxes during expansion. I had to move the discover_nonconstant_array_refs call outside the currently_expanding_to_rtl block since otherwise mark_addressable just queues the decision for later. 2019-09-05 Richard Sandiford <richard.sandiford@arm.com> gcc/ PR middle-end/91577 * cfgexpand.c (discover_nonconstant_array_refs): Force the source of an IFN_LOAD_LANES call and the destination of an IFN_STORE_LANES call to be in memory. (pass_expand::execute): Call discover_nonconstant_array_refs before setting currently_expanding_to_rtl. gcc/testsuite/ PR middle-end/91577 * gfortran.dg/pr91577.f90: New test, taken from temporary_1.f90. From-SVN: r275399
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog9
-rw-r--r--gcc/cfgexpand.c25
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gfortran.dg/pr91577.f9028
4 files changed, 63 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index f620ffd..ee8c244 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,12 @@
+2019-09-05 Richard Sandiford <richard.sandiford@arm.com>
+
+ PR middle-end/91577
+ * cfgexpand.c (discover_nonconstant_array_refs): Force the source
+ of an IFN_LOAD_LANES call and the destination of an IFN_STORE_LANES
+ call to be in memory.
+ (pass_expand::execute): Call discover_nonconstant_array_refs before
+ setting currently_expanding_to_rtl.
+
2019-09-04 Caroline Tice <cmtice@google.com>
* opts.c (finish_options): Disallow -fvtable-verify and -flto to be
diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c
index 33af991..5a93447 100644
--- a/gcc/cfgexpand.c
+++ b/gcc/cfgexpand.c
@@ -6155,7 +6155,24 @@ discover_nonconstant_array_refs (void)
{
gimple *stmt = gsi_stmt (gsi);
if (!is_gimple_debug (stmt))
- walk_gimple_op (stmt, discover_nonconstant_array_refs_r, NULL);
+ {
+ walk_gimple_op (stmt, discover_nonconstant_array_refs_r, NULL);
+ gcall *call = dyn_cast <gcall *> (stmt);
+ if (call && gimple_call_internal_p (call))
+ switch (gimple_call_internal_fn (call))
+ {
+ case IFN_LOAD_LANES:
+ /* The source must be a MEM. */
+ mark_addressable (gimple_call_arg (call, 0));
+ break;
+ case IFN_STORE_LANES:
+ /* The destination must be a MEM. */
+ mark_addressable (gimple_call_lhs (call));
+ break;
+ default:
+ break;
+ }
+ }
}
}
@@ -6353,6 +6370,9 @@ pass_expand::execute (function *fun)
avoid_deep_ter_for_debug (gsi_stmt (gsi), 0);
}
+ /* Mark arrays indexed with non-constant indices with TREE_ADDRESSABLE. */
+ discover_nonconstant_array_refs ();
+
/* Make sure all values used by the optimization passes have sane
defaults. */
reg_renumber = 0;
@@ -6387,9 +6407,6 @@ pass_expand::execute (function *fun)
Also, final expects a note to appear there. */
emit_note (NOTE_INSN_DELETED);
- /* Mark arrays indexed with non-constant indices with TREE_ADDRESSABLE. */
- discover_nonconstant_array_refs ();
-
targetm.expand_to_rtl_hook ();
crtl->init_stack_alignment ();
fun->cfg->max_jumptable_ents = 0;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 11d6fab..ce3a385 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2019-09-05 Richard Sandiford <richard.sandiford@arm.com>
+
+ PR middle-end/91577
+ * gfortran.dg/pr91577.f90: New test, taken from temporary_1.f90.
+
2019-09-04 Steven G. Kargl <kargl@gcvc.gnu.org>
PR fortran/91650
diff --git a/gcc/testsuite/gfortran.dg/pr91577.f90 b/gcc/testsuite/gfortran.dg/pr91577.f90
new file mode 100644
index 0000000..8c31d37
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr91577.f90
@@ -0,0 +1,28 @@
+! { dg-do run }
+! { dg-additional-options "--param max-completely-peel-loop-nest-depth=1" }
+! PR 27662. Don't zero the first stride to indicate a temporary. It
+! may be used later.
+program pr27662
+ implicit none
+ real(kind=kind(1.0d0)), dimension (2, 2):: x, y, z;
+ integer i, j
+ x(1,1) = 1.d0
+ x(2,1) = 0.d0
+ x(1,2) = 0.d0
+ x(2,2) = 1.d0
+ z = matmul (x, transpose (test ()))
+ do i = 1, size (x, 1)
+ do j = 1, size (x, 2)
+ if (x (i, j) .ne. z (i, j)) STOP 1
+ end do
+ end do
+
+contains
+ function test () result (res)
+ real(kind=kind(1.0d0)), dimension(2,2) :: res
+ res(1,1) = 1.d0
+ res(2,1) = 0.d0
+ res(1,2) = 0.d0
+ res(2,2) = 1.d0
+ end function
+end