From: Segher Boessenkool <segher@kernel.crashing.org>
To: gcc-patches@gcc.gnu.org
Cc: Segher Boessenkool <segher@kernel.crashing.org>
Subject: [PATCH] simplify-rtx: Fix compare of comparisons (PR60818)
Date: Fri, 31 Mar 2017 22:50:00 -0000 [thread overview]
Message-ID: <b4afa84705ef48a3d170ae269e8fb92b69053333.1490995891.git.segher@kernel.crashing.org> (raw)
The function simplify_binary_operation_1 has code that does
/* Convert (compare (gt (flags) 0) (lt (flags) 0)) to (flags). */
but this transformation is only valid if "flags" has the same machine
mode as the outer compare. This fixes it.
Bootstrapped and tested on powerpc64-linux {-m32,-m64} (and tested the
new testcase with {-m32,-m64}{,-misel}). Is this okay for trunk?
Segher
2017-03-31 Segher Boessenkool <segher@kernel.crashing.org>
PR rtl-optimization/60818
* simplify-rtx.c (simplify_binary_operation_1): Do not replace
a compare of comparisons with the thing compared if this results
in a different machine mode.
gcc/testsuite/
PR rtl-optimization/60818
* gcc.c-torture/compile/pr60818.c: New testcase.
---
gcc/simplify-rtx.c | 6 +++---
gcc/testsuite/gcc.c-torture/compile/pr60818.c | 5 +++++
2 files changed, 8 insertions(+), 3 deletions(-)
create mode 100644 gcc/testsuite/gcc.c-torture/compile/pr60818.c
diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c
index 3022779..10c2800 100644
--- a/gcc/simplify-rtx.c
+++ b/gcc/simplify-rtx.c
@@ -2367,10 +2367,10 @@
return xop00;
if (REG_P (xop00) && REG_P (xop10)
- && GET_MODE (xop00) == GET_MODE (xop10)
&& REGNO (xop00) == REGNO (xop10)
- && GET_MODE_CLASS (GET_MODE (xop00)) == MODE_CC
- && GET_MODE_CLASS (GET_MODE (xop10)) == MODE_CC)
+ && GET_MODE (xop00) == mode
+ && GET_MODE (xop10) == mode
+ && GET_MODE_CLASS (mode) == MODE_CC)
return xop00;
}
break;
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr60818.c b/gcc/testsuite/gcc.c-torture/compile/pr60818.c
new file mode 100644
index 0000000..b6171bb
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/pr60818.c
@@ -0,0 +1,5 @@
+int
+lx (int oi, int mb)
+{
+ return (oi < mb) < (mb < oi);
+}
--
1.9.3
next reply other threads:[~2017-03-31 21:40 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-31 22:50 Segher Boessenkool [this message]
2017-04-03 17:01 ` Jeff Law
2017-04-03 17:19 ` Segher Boessenkool
2017-05-01 9:13 ` Segher Boessenkool
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b4afa84705ef48a3d170ae269e8fb92b69053333.1490995891.git.segher@kernel.crashing.org \
--to=segher@kernel.crashing.org \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).