From: Segher Boessenkool Date: Tue, 28 Nov 2017 00:17:16 +0000 (+0100) Subject: rs6000: Improve scc isel X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=fd8bf76c908297f96f240954c43732579bb95105;p=gcc.git 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 (2_isel): Change LT/GT/LTU/GTU to LE/GE/LEU/GEU where possible. From-SVN: r255186 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 10d5634b118..d3b2f5b363b 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2017-11-27 Segher Boessenkool + + * config/rs6000/rs6000.md (2_isel): Change + LT/GT/LTU/GTU to LE/GE/LEU/GEU where possible. + 2017-11-27 Michael Meissner PR middle_end/82333 diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md index 276ad8a32e8..c9b35c9104a 100644 --- a/gcc/config/rs6000/rs6000.md +++ b/gcc/config/rs6000/rs6000.md @@ -12333,8 +12333,34 @@ "&& 1" [(pc)] { - if ( == NE || == LE || == GE - || == LEU || == GEU) + rtx_code code = ; + 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; else { @@ -12353,14 +12379,16 @@ rtx c1 = gen_rtx_COMPARE (mode, operands[1], operands[2]); emit_insn (gen_rtx_SET (operands[5], c1)); - rtx c2 = gen_rtx_fmt_ee (, mode, operands[5], const0_rtx); + rtx c2 = gen_rtx_fmt_ee (code, mode, operands[5], const0_rtx); rtx x = gen_rtx_IF_THEN_ELSE (mode, c2, operands[4], operands[3]); emit_move_insn (operands[0], x); DONE; } [(set (attr "cost") - (if_then_else (match_test " == NE || == LE || == GE + (if_then_else (match_test "(CONST_INT_P (operands[2]) && != EQ) + || == NE + || == LE || == GE || == LEU || == GEU") (const_string "9") (const_string "10")))])