aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaz Kojima <kkojima@gcc.gnu.org>2008-11-10 23:10:10 +0000
committerKaz Kojima <kkojima@gcc.gnu.org>2008-11-10 23:10:10 +0000
commitbefc25099bbedd2d49f23f929b6c441894c8cb5c (patch)
tree292694d71a3f5f7fd4b1552de056e460c88e7e39
parent3fe8e64bc222e8149cb623fb47d25e74124e98ab (diff)
downloadgcc-befc25099bbedd2d49f23f929b6c441894c8cb5c.zip
gcc-befc25099bbedd2d49f23f929b6c441894c8cb5c.tar.gz
gcc-befc25099bbedd2d49f23f929b6c441894c8cb5c.tar.bz2
re PR rtl-optimization/37514 (Wrong code generated for 20021120-1.c with -O3 -fomit-frame-pointer on sh4)
PR rtl-optimization/37514 * config/sh/sh.h (OPTIMIZATION_OPTIONS): Set flag_ira_share_spill_slots to 2 if it's already non-zero. (OVERRIDE_OPTIONS): Clear flag_ira_share_spill_slots if flag_ira_share_spill_slots is 2. * gcc.target/sh/pr37514.c: New test. From-SVN: r141752
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/config/sh/sh.h9
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.target/sh/pr37514.c65
4 files changed, 86 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index a300ed4..18d73af 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+2008-11-10 Kaz Kojima <kkojima@gcc.gnu.org>
+
+ PR rtl-optimization/37514
+ * config/sh/sh.h (OPTIMIZATION_OPTIONS): Set
+ flag_ira_share_spill_slots to 2 if it's already non-zero.
+ (OVERRIDE_OPTIONS): Clear flag_ira_share_spill_slots if
+ flag_ira_share_spill_slots is 2.
+
2008-11-10 Kevin Buettner <kevinb@redhat.com>
* config/m32c/prologue.md (prologue_enter_16): Set FB to SP - 2.
diff --git a/gcc/config/sh/sh.h b/gcc/config/sh/sh.h
index 6a4ccb0..0ec9ac9 100644
--- a/gcc/config/sh/sh.h
+++ b/gcc/config/sh/sh.h
@@ -496,6 +496,9 @@ do { \
the user explicitly requested this to be on or off. */ \
if (flag_schedule_insns > 0) \
flag_schedule_insns = 2; \
+ /* Likewise for flag_ira_share_spill_slots. */ \
+ if (flag_ira_share_spill_slots > 0) \
+ flag_ira_share_spill_slots = 2; \
\
set_param_value ("simultaneous-prefetches", 2); \
} while (0)
@@ -730,6 +733,12 @@ do { \
} \
} \
\
+ /* FIXME. Currently -fira-share-spill-slots causes a wrong code \
+ problem PR 37514, though the compiler generates lengthy codes \
+ in some cases without it. */ \
+ if (flag_ira_share_spill_slots == 2) \
+ flag_ira_share_spill_slots = 0; \
+ \
if (align_loops == 0) \
align_loops = 1 << (TARGET_SH5 ? 3 : 2); \
if (align_jumps == 0) \
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 55ba2e4..393e9e9 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2008-11-10 Kaz Kojima <kkojima@gcc.gnu.org>
+
+ * gcc.target/sh/pr37514.c: New test.
+
2008-11-10 Eric Botcazou <ebotcazou@adacore.com>
* g++.dg/other/anon5.C: Skip on Solaris.
diff --git a/gcc/testsuite/gcc.target/sh/pr37514.c b/gcc/testsuite/gcc.target/sh/pr37514.c
new file mode 100644
index 0000000..fa68ebe
--- /dev/null
+++ b/gcc/testsuite/gcc.target/sh/pr37514.c
@@ -0,0 +1,65 @@
+/* This is essentially gcc.c-torture/execute/20021120-1.c run with
+ -O3 -fomit-frame-pointer -fira-share-spill-slots. */
+/* { dg-do run { target "sh*-*-*" } } */
+/* { dg-options "-O3 -fomit-frame-pointer -fira-share-spill-slots" } */
+
+/* Macros to emit "L Nxx R" for each octal number xx between 000 and 037. */
+#define OP1(L, N, R, I, J) L N##I##J R
+#define OP2(L, N, R, I) \
+ OP1(L, N, R, 0, I), OP1(L, N, R, 1, I), \
+ OP1(L, N, R, 2, I), OP1(L, N, R, 3, I)
+#define OP(L, N, R) \
+ OP2(L, N, R, 0), OP2(L, N, R, 1), OP2(L, N, R, 2), OP2(L, N, R, 3), \
+ OP2(L, N, R, 4), OP2(L, N, R, 5), OP2(L, N, R, 6), OP2(L, N, R, 7)
+
+/* Declare 32 unique variables with prefix N. */
+#define DECLARE(N) OP (, N,)
+
+/* Copy 32 variables with prefix N from the array at ADDR.
+ Leave ADDR pointing to the end of the array. */
+#define COPYIN(N, ADDR) OP (, N, = *(ADDR++))
+
+/* Likewise, but copy the other way. */
+#define COPYOUT(N, ADDR) OP (*(ADDR++) =, N,)
+
+/* Add the contents of the array at ADDR to 32 variables with prefix N.
+ Leave ADDR pointing to the end of the array. */
+#define ADD(N, ADDR) OP (, N, += *(ADDR++))
+
+volatile double gd[32];
+volatile float gf[32];
+
+extern void abort (void);
+
+static void foo (int n)
+{
+ double DECLARE(d);
+ float DECLARE(f);
+ volatile double *pd;
+ volatile float *pf;
+ int i;
+
+ pd = gd; COPYIN (d, pd);
+ for (i = 0; i < n; i++)
+ {
+ pf = gf; COPYIN (f, pf);
+ pd = gd; ADD (d, pd);
+ pd = gd; ADD (d, pd);
+ pd = gd; ADD (d, pd);
+ pf = gf; COPYOUT (f, pf);
+ }
+ pd = gd; COPYOUT (d, pd);
+}
+
+int main ()
+{
+ int i;
+
+ for (i = 0; i < 32; i++)
+ gd[i] = i, gf[i] = i;
+ foo (1);
+ for (i = 0; i < 32; i++)
+ if (gd[i] != i * 4 || gf[i] != i)
+ abort ();
+ return 0;
+}