Skip to content

Commit b1023d0

Browse files
author
segher
committed
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@255186 138bc75d-0d04-0410-961f-82ee72b054a4
1 parent 122fea3 commit b1023d0

File tree

2 files changed

+37
-4
lines changed

2 files changed

+37
-4
lines changed

gcc/ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2017-11-27 Segher Boessenkool <[email protected]>
2+
3+
* config/rs6000/rs6000.md (<code><GPR:mode><GPR2:mode>2_isel): Change
4+
LT/GT/LTU/GTU to LE/GE/LEU/GEU where possible.
5+
16
2017-11-27 Michael Meissner <[email protected]>
27

38
PR middle_end/82333

gcc/config/rs6000/rs6000.md

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12333,8 +12333,34 @@
1233312333
"&& 1"
1233412334
[(pc)]
1233512335
{
12336-
if (<CODE> == NE || <CODE> == LE || <CODE> == GE
12337-
|| <CODE> == LEU || <CODE> == GEU)
12336+
rtx_code code = <CODE>;
12337+
if (CONST_INT_P (operands[2]) && code != EQ && code != NE)
12338+
{
12339+
HOST_WIDE_INT val = INTVAL (operands[2]);
12340+
if (code == LT && val != -0x8000)
12341+
{
12342+
code = LE;
12343+
val--;
12344+
}
12345+
if (code == GT && val != 0x7fff)
12346+
{
12347+
code = GE;
12348+
val++;
12349+
}
12350+
if (code == LTU && val != 0)
12351+
{
12352+
code = LEU;
12353+
val--;
12354+
}
12355+
if (code == GTU && val != 0xffff)
12356+
{
12357+
code = GEU;
12358+
val++;
12359+
}
12360+
operands[2] = GEN_INT (val);
12361+
}
12362+
12363+
if (code == NE || code == LE || code == GE || code == LEU || code == GEU)
1233812364
operands[3] = const0_rtx;
1233912365
else
1234012366
{
@@ -12353,14 +12379,16 @@
1235312379
rtx c1 = gen_rtx_COMPARE (<UNS>mode, operands[1], operands[2]);
1235412380
emit_insn (gen_rtx_SET (operands[5], c1));
1235512381

12356-
rtx c2 = gen_rtx_fmt_ee (<CODE>, <GPR:MODE>mode, operands[5], const0_rtx);
12382+
rtx c2 = gen_rtx_fmt_ee (code, <GPR:MODE>mode, operands[5], const0_rtx);
1235712383
rtx x = gen_rtx_IF_THEN_ELSE (<GPR:MODE>mode, c2, operands[4], operands[3]);
1235812384
emit_move_insn (operands[0], x);
1235912385

1236012386
DONE;
1236112387
}
1236212388
[(set (attr "cost")
12363-
(if_then_else (match_test "<CODE> == NE || <CODE> == LE || <CODE> == GE
12389+
(if_then_else (match_test "(CONST_INT_P (operands[2]) && <CODE> != EQ)
12390+
|| <CODE> == NE
12391+
|| <CODE> == LE || <CODE> == GE
1236412392
|| <CODE> == LEU || <CODE> == GEU")
1236512393
(const_string "9")
1236612394
(const_string "10")))])

0 commit comments

Comments
 (0)