From: Hans-Peter Nilsson Date: Thu, 6 Feb 2020 17:12:11 +0000 (+0100) Subject: cris: Enable "neg" to set condition codes. X-Git-Tag: upstream/12.2.0~16719 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a33649e66640b35fc69f7f7f47346614a12b12d9;p=platform%2Fupstream%2Fgcc.git cris: Enable "neg" to set condition codes. While gcc seems to prefer transforming tests on the result of reversible operations, into tests on the original, it also can work with the destination, if allocated to the same register as it commonly-enough is. The re-use is easily covered in a test-case. (N.B.: the value 0x80000000 appears to be considered invalid and unimportant.) Spotted as a "microregression" in libgcc when comparing to the cc0 version. gcc: * config/cris/cris.c (cris_select_cc_mode): Return CC_NZmode for NEG too. Correct comment. * config/cris/cris.md ("neg2"): Rename from "neg2". --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 8f14fdb..178973f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -167,6 +167,11 @@ Handle output of CC_ZnNmode. ("*b_reversed"): Ditto. + * config/cris/cris.c (cris_select_cc_mode): Return CC_NZmode for + NEG too. Correct comment. + * config/cris/cris.md ("neg2"): Rename from + "neg2". + 2020-05-08 Vladimir Makarov * ira-color.c (update_costs_from_allocno): Remove diff --git a/gcc/config/cris/cris.c b/gcc/config/cris/cris.c index d0807ad..2bad939 100644 --- a/gcc/config/cris/cris.c +++ b/gcc/config/cris/cris.c @@ -1531,9 +1531,9 @@ cris_select_cc_mode (enum rtx_code op, rtx x, rtx y) return CCmode; /* If we have a comparison that doesn't have to look at V or C, check - operand x; if it looks like a binary operator, return CC_NZmode, - else CCmode, so we only use CC_NZmode for the cases where we don't - actually have both V and C valid. */ + operand x; if it's a valid operator, return CC_NZmode, else CCmode, + so we only use CC_NZmode for the cases where we don't actually have + both V and C valid. */ if (op == EQ || op == NE || op == GTU || op == LEU || op == LT || op == GE) { @@ -1542,7 +1542,7 @@ cris_select_cc_mode (enum rtx_code op, rtx x, rtx y) /* Mentioning the rtx_code here is required but not sufficient: the insn also needs to be decorated with (and the anonymization prefix for a named pattern). */ - return e == PLUS || e == MINUS || e == MULT || e == NOT + return e == PLUS || e == MINUS || e == MULT || e == NOT || e == NEG ? CC_NZmode : CCmode; } diff --git a/gcc/config/cris/cris.md b/gcc/config/cris/cris.md index 1e895a3..081041f 100644 --- a/gcc/config/cris/cris.md +++ b/gcc/config/cris/cris.md @@ -1734,7 +1734,7 @@ ;; No "negdi2" although we could make one up that may be faster than ;; the one in libgcc. -(define_insn "neg2" +(define_insn "neg2" [(set (match_operand:BWD 0 "register_operand" "=r") (neg:BWD (match_operand:BWD 1 "register_operand" "r"))) (clobber (reg:CC CRIS_CC0_REGNUM))]