public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [cris-decc0 14/14] cris: Enable "neg" to set condition codes.
@ 2020-02-12  7:05 Hans-Peter Nilsson
  0 siblings, 0 replies; only message in thread
From: Hans-Peter Nilsson @ 2020-02-12  7:05 UTC (permalink / raw)
  To: gcc-patches

* config/cris/cris.c (cris_select_cc_mode): Return CC_NZmode for
NEG too.  Correct comment.
* config/cris/cris.md ("<anz>neg<mode>2<setnz>"): Rename from
"neg<mode>2".

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  | 8 ++++----
 gcc/config/cris/cris.md | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/gcc/config/cris/cris.c b/gcc/config/cris/cris.c
index d0807adc8..2bad9393c 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 <setnz> (and the
        anonymization prefix <anz> 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 1e895a375..081041fa2 100644
--- a/gcc/config/cris/cris.md
+++ b/gcc/config/cris/cris.md
@@ -1734,7 +1734,7 @@ (define_insn "*expanded_negsf2"
 ;; No "negdi2" although we could make one up that may be faster than
 ;; the one in libgcc.
 
-(define_insn "neg<mode>2"
+(define_insn "<anz>neg<mode>2<setnz>"
   [(set (match_operand:BWD 0 "register_operand" "=r")
 	(neg:BWD (match_operand:BWD 1 "register_operand" "r")))
    (clobber (reg:CC CRIS_CC0_REGNUM))]
-- 
2.11.0

brgds, H-P

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-02-12  7:05 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-12  7:05 [cris-decc0 14/14] cris: Enable "neg" to set condition codes Hans-Peter Nilsson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).