diff options
author | Segher Boessenkool <segher@kernel.crashing.org> | 2017-04-04 02:10:02 +0200 |
---|---|---|
committer | Segher Boessenkool <segher@gcc.gnu.org> | 2017-04-04 02:10:02 +0200 |
commit | 833bbf60ce6414801d3a381a2a4b1f244bd0d969 (patch) | |
tree | 00a63283331bcb8c6dec0cee8f6b8600a0a657bf | |
parent | 5764ee3c8491e3ecff855a319f781a66fca2484e (diff) | |
download | gcc-833bbf60ce6414801d3a381a2a4b1f244bd0d969.zip gcc-833bbf60ce6414801d3a381a2a4b1f244bd0d969.tar.gz gcc-833bbf60ce6414801d3a381a2a4b1f244bd0d969.tar.bz2 |
simplify-rtx: Fix compare of comparisons (PR60818)
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.
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.
From-SVN: r246666
-rw-r--r-- | gcc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/simplify-rtx.c | 6 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.c-torture/compile/pr60818.c | 5 |
4 files changed, 20 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index a92c3a5..4d113af 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2017-04-04 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. + 2017-04-03 Jonathan Wakely <jwakely@redhat.com> * alias.c (base_alias_check): Fix typo in comment. diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c index 640ccb7..cff7e4d 100644 --- a/gcc/simplify-rtx.c +++ b/gcc/simplify-rtx.c @@ -2306,10 +2306,10 @@ simplify_binary_operation_1 (enum rtx_code code, machine_mode mode, 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/ChangeLog b/gcc/testsuite/ChangeLog index 4a05eba..9ac0c0b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-04-04 Segher Boessenkool <segher@kernel.crashing.org> + + PR rtl-optimization/60818 + * gcc.c-torture/compile/pr60818.c: New testcase. + 2017-04-03 Jonathan Wakely <jwakely@redhat.com> * g++.old-deja/g++.benjamin/scope02.C: Fix typo in comment. 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); +} |