Commit fd8bf76c by Segher Boessenkool Committed by Segher Boessenkool

rs6000: Improve scc isel

If we have a negative condition we can use a literal 0 in the isel,
instead of having to load it into a register.  If the condition is from
a comparison with an immediate we can change e.g. LT to LE and adjust
the immediate, saving a li instruction.


	* config/rs6000/rs6000.md (<code><GPR:mode><GPR2:mode>2_isel): Change
	LT/GT/LTU/GTU to LE/GE/LEU/GEU where possible.

From-SVN: r255186
parent 2ac1a8d8
2017-11-27 Segher Boessenkool <segher@kernel.crashing.org>
* config/rs6000/rs6000.md (<code><GPR:mode><GPR2:mode>2_isel): Change
LT/GT/LTU/GTU to LE/GE/LEU/GEU where possible.
2017-11-27 Michael Meissner <meissner@linux.vnet.ibm.com> 2017-11-27 Michael Meissner <meissner@linux.vnet.ibm.com>
PR middle_end/82333 PR middle_end/82333
...@@ -12333,8 +12333,34 @@ ...@@ -12333,8 +12333,34 @@
"&& 1" "&& 1"
[(pc)] [(pc)]
{ {
if (<CODE> == NE || <CODE> == LE || <CODE> == GE rtx_code code = <CODE>;
|| <CODE> == LEU || <CODE> == GEU) if (CONST_INT_P (operands[2]) && code != EQ && code != NE)
{
HOST_WIDE_INT val = INTVAL (operands[2]);
if (code == LT && val != -0x8000)
{
code = LE;
val--;
}
if (code == GT && val != 0x7fff)
{
code = GE;
val++;
}
if (code == LTU && val != 0)
{
code = LEU;
val--;
}
if (code == GTU && val != 0xffff)
{
code = GEU;
val++;
}
operands[2] = GEN_INT (val);
}
if (code == NE || code == LE || code == GE || code == LEU || code == GEU)
operands[3] = const0_rtx; operands[3] = const0_rtx;
else else
{ {
...@@ -12353,14 +12379,16 @@ ...@@ -12353,14 +12379,16 @@
rtx c1 = gen_rtx_COMPARE (<UNS>mode, operands[1], operands[2]); rtx c1 = gen_rtx_COMPARE (<UNS>mode, operands[1], operands[2]);
emit_insn (gen_rtx_SET (operands[5], c1)); emit_insn (gen_rtx_SET (operands[5], c1));
rtx c2 = gen_rtx_fmt_ee (<CODE>, <GPR:MODE>mode, operands[5], const0_rtx); rtx c2 = gen_rtx_fmt_ee (code, <GPR:MODE>mode, operands[5], const0_rtx);
rtx x = gen_rtx_IF_THEN_ELSE (<GPR:MODE>mode, c2, operands[4], operands[3]); rtx x = gen_rtx_IF_THEN_ELSE (<GPR:MODE>mode, c2, operands[4], operands[3]);
emit_move_insn (operands[0], x); emit_move_insn (operands[0], x);
DONE; DONE;
} }
[(set (attr "cost") [(set (attr "cost")
(if_then_else (match_test "<CODE> == NE || <CODE> == LE || <CODE> == GE (if_then_else (match_test "(CONST_INT_P (operands[2]) && <CODE> != EQ)
|| <CODE> == NE
|| <CODE> == LE || <CODE> == GE
|| <CODE> == LEU || <CODE> == GEU") || <CODE> == LEU || <CODE> == GEU")
(const_string "9") (const_string "9")
(const_string "10")))]) (const_string "10")))])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment