From 7477de01a8c9c4f496d6f4daea90255ec0aad272 Mon Sep 17 00:00:00 2001 From: Andreas Krebbel Date: Thu, 22 Oct 2015 08:24:01 +0000 Subject: [PATCH] S/390: PR68015 Fix ICE in s390_emit_compare gcc/ChangeLog: 2015-10-22 Andreas Krebbel PR target/68015 * config/s390/s390.md (movcc): Emit compare only if we don't already have a comparison result. gcc/testsuite/ChangeLog: 2015-10-22 Andreas Krebbel PR target/68015 * gcc.target/s390/pr68015.c: New test. From-SVN: r229163 --- gcc/ChangeLog | 6 ++++++ gcc/config/s390/s390.md | 9 +++++++-- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.target/s390/pr68015.c | 24 ++++++++++++++++++++++++ 4 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.target/s390/pr68015.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 11116c42605..7385acdc788 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2015-10-22 Andreas Krebbel + + PR target/68015 + * config/s390/s390.md (movcc): Emit compare only if we don't + already have a comparison result. + 2015-10-22 Ramana Radhakrishnan PR target/63304 diff --git a/gcc/config/s390/s390.md b/gcc/config/s390/s390.md index 18224592881..ea65c746fca 100644 --- a/gcc/config/s390/s390.md +++ b/gcc/config/s390/s390.md @@ -6108,8 +6108,13 @@ (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 "*movcc" diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3bcbe96c5f1..4f54df62c18 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-10-22 Andreas Krebbel + + PR target/68015 + * gcc.target/s390/pr68015.c: New test. + 2015-10-22 Andre Vieira 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 index 00000000000..b0d1f35ad1a --- /dev/null +++ b/gcc/testsuite/gcc.target/s390/pr68015.c @@ -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); +} -- 2.30.2