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
This commit is contained in:
Segher Boessenkool 2017-04-04 02:10:02 +02:00 committed by Segher Boessenkool
parent 5764ee3c84
commit 833bbf60ce
4 changed files with 20 additions and 3 deletions

View File

@ -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.

View File

@ -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;

View File

@ -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.

View File

@ -0,0 +1,5 @@
int
lx (int oi, int mb)
{
return (oi < mb) < (mb < oi);
}