aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Bruel <christian.bruel@st.com>2008-04-17 08:49:16 +0200
committerChristian Bruel <chrbr@gcc.gnu.org>2008-04-17 08:49:16 +0200
commitd60819f8688af24e3a0cf4264bc0b3e1a06a6255 (patch)
tree904456220c567db29ff3e66eadb71b509ced5766
parentca4ceacbbb7fc11529779b585677026796fce2bc (diff)
downloadgcc-d60819f8688af24e3a0cf4264bc0b3e1a06a6255.zip
gcc-d60819f8688af24e3a0cf4264bc0b3e1a06a6255.tar.gz
gcc-d60819f8688af24e3a0cf4264bc0b3e1a06a6255.tar.bz2
fix SH long long compare
From-SVN: r134380
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/config/sh/sh.c8
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.dg/long-long-compare-1.c126
4 files changed, 143 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 57d334c..4efd1c0 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2008-04-17 Christian Bruel <christian.bruel@st.com>
+
+ * config/sh/sh.c (expand_cbranchdi4): Use original operands for
+ msw_skip comparison.
+
2008-04-16 Jakub Jelinek <jakub@redhat.com>
PR c/35739
diff --git a/gcc/config/sh/sh.c b/gcc/config/sh/sh.c
index d020ccd..6b20ee3 100644
--- a/gcc/config/sh/sh.c
+++ b/gcc/config/sh/sh.c
@@ -1685,6 +1685,14 @@ expand_cbranchdi4 (rtx *operands, enum rtx_code comparison)
{
rtx taken_label = operands[3];
+ /* Operands were possibly modified, but msw_skip doesn't expect this.
+ Always use the original ones. */
+ if (msw_taken != CODE_FOR_nothing)
+ {
+ operands[1] = op1h;
+ operands[2] = op2h;
+ }
+
operands[3] = skip_label = gen_label_rtx ();
expand_cbranchsi4 (operands, msw_skip, msw_skip_prob);
operands[3] = taken_label;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index b7349e2..4ac7a44 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2008-04-17 Christian Bruel <christian.bruel@st.com>
+
+ * gcc.dg/dicomp.c: New testcase.
+
2008-04-16 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR fortran/35724
diff --git a/gcc/testsuite/gcc.dg/long-long-compare-1.c b/gcc/testsuite/gcc.dg/long-long-compare-1.c
new file mode 100644
index 0000000..c650cb1
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/long-long-compare-1.c
@@ -0,0 +1,126 @@
+/* Problem only noticed on SH for -mcbranchdi DImode comparison with constants.
+ * Target dependant failure but test valid for alls. */
+/* { dg-do run } */
+/* { dg-options "-O0" } */
+/* { dg-options "-O0 -mcbranchdi" { target sh4-*-* } } */
+
+extern void abort(void);
+extern void exit(int);
+
+int test2(long long n)
+{
+ if (n < 2)
+ return 1;
+ return 0;
+}
+
+int test1(long long n)
+{
+ if (n < 1)
+ return 1;
+ return 0;
+}
+
+int test0(long long n)
+{
+ if (n < 0)
+ return 1;
+ return 0;
+}
+
+int test1n(long long n)
+{
+ if (n < -1LL)
+ return 1;
+ return 0;
+}
+
+int test2n(long long n)
+{
+ if (n < -2LL)
+ return 1;
+ return 0;
+}
+
+int main()
+{
+ if (test2n (-1LL))
+ abort ();
+
+ if (test2n (-2LL))
+ abort ();
+
+ if (test2n (0LL))
+ abort ();
+
+ if (test2n (1LL))
+ abort ();
+
+ if (test2n (2LL))
+ abort ();
+
+ if (test1n (-1LL))
+ abort ();
+
+ if (!test1n (-2LL))
+ abort ();
+
+ if (test1n (0LL))
+ abort ();
+
+ if (test1n (1LL))
+ abort ();
+
+ if (test1n (2LL))
+ abort ();
+
+ if (!test0 (-1LL))
+ abort ();
+
+ if (!test0 (-2LL))
+ abort ();
+
+ if (test0 (0LL))
+ abort ();
+
+ if (test0 (1LL))
+ abort ();
+
+ if (test0 (2LL))
+ abort ();
+
+ if (!test2 (-1LL))
+ abort ();
+
+ if (!test2 (-2LL))
+ abort ();
+
+ if (!test2 (0LL))
+ abort ();
+
+ if (!test2 (1LL))
+ abort ();
+
+ if (test2 (2LL))
+ abort ();
+
+ if (!test1 (-1LL))
+ abort ();
+
+ if (!test1 (-2LL))
+ abort ();
+
+ if (!test1 (0LL))
+ abort ();
+
+ if (test1 (1LL))
+ abort ();
+
+ if (test1 (2LL))
+ abort ();
+
+ exit (0);
+}
+
+
+