S/390: PR68015 Fix ICE in s390_emit_compare
authorAndreas Krebbel <krebbel@linux.vnet.ibm.com>
Thu, 22 Oct 2015 08:24:01 +0000 (08:24 +0000)
committerAndreas Krebbel <krebbel@gcc.gnu.org>
Thu, 22 Oct 2015 08:24:01 +0000 (08:24 +0000)
gcc/ChangeLog:

2015-10-22  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>

PR target/68015
* config/s390/s390.md (mov<mode>cc): Emit compare only if we don't
already have a comparison result.

gcc/testsuite/ChangeLog:

2015-10-22  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>

PR target/68015
* gcc.target/s390/pr68015.c: New test.

From-SVN: r229163

gcc/ChangeLog
gcc/config/s390/s390.md
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/s390/pr68015.c [new file with mode: 0644]

index 11116c42605012e641f7e820bd98d0e0adf932fc..7385acdc788b6b524eb171f5ec564b976156df5c 100644 (file)
@@ -1,3 +1,9 @@
+2015-10-22  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>
+
+       PR target/68015
+       * config/s390/s390.md (mov<mode>cc): Emit compare only if we don't
+       already have a comparison result.
+
 2015-10-22  Ramana Radhakrishnan  <ramana.radhakrishnan@arm.com>
 
        PR target/63304
index 182245928811b102e92ac356f3c96cfdc7bd772f..ea65c746fca0f6394cfba6821303fa606d5e1dd9 100644 (file)
                          (match_operand:GPR 2 "nonimmediate_operand" "")
                          (match_operand:GPR 3 "nonimmediate_operand" "")))]
   "TARGET_Z196"
-  "operands[1] = s390_emit_compare (GET_CODE (operands[1]),
-                                    XEXP (operands[1], 0), XEXP (operands[1], 1));")
+{
+  /* Emit the comparison insn in case we do not already have a comparison result.  */
+  if (!s390_comparison (operands[1], VOIDmode))
+    operands[1] = s390_emit_compare (GET_CODE (operands[1]),
+                                    XEXP (operands[1], 0),
+                                    XEXP (operands[1], 1));
+})
 
 ; locr, loc, stoc, locgr, locg, stocg
 (define_insn_and_split "*mov<mode>cc"
index 3bcbe96c5f1d842360a9bd0c81edc7534a6afcd9..4f54df62c182d60eff61b1b1efc9c880d26a800d 100644 (file)
@@ -1,3 +1,8 @@
+2015-10-22  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>
+
+       PR target/68015
+       * gcc.target/s390/pr68015.c: New test.
+
 2015-10-22  Andre Vieira  <andre.simoesdiasvieira@arm.com>
 
        PR testsuite/67948
diff --git a/gcc/testsuite/gcc.target/s390/pr68015.c b/gcc/testsuite/gcc.target/s390/pr68015.c
new file mode 100644 (file)
index 0000000..b0d1f35
--- /dev/null
@@ -0,0 +1,24 @@
+/* { dg-compile } */
+/* { dg-options "-O2 -march=z196" } */
+
+extern long useme (long, ...);
+
+void
+foo (void)
+{
+  long secs = useme (41);
+  long utc_secs = useme (42);
+  long h, m;
+
+  utc_secs = useme (42);
+  h = secs / 3600;
+  m = secs / 60;
+  if (utc_secs >= 86400)
+    {
+      m = 59;
+      h--;
+      if (h < 0)
+       h = 23;
+    }
+  useme (h, m);
+}