public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/c++-coroutines] cris: Use addi.b for additions where flags aren't inspected
@ 2020-07-13 20:18 Iain D Sandoe
  0 siblings, 0 replies; only message in thread
From: Iain D Sandoe @ 2020-07-13 20:18 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:ef07c7a5884c130b48e653993bfaaf1ae9e6dedd

commit ef07c7a5884c130b48e653993bfaaf1ae9e6dedd
Author: Hans-Peter Nilsson <hp@axis.com>
Date:   Wed Jul 8 23:59:12 2020 +0200

    cris: Use addi.b for additions where flags aren't inspected
    
    Comparing to the cc0 version of the CRIS port, I ran a few
    microbenchmarks, for example gcc.c-torture/execute/arith-rand.c,
    where there's sometimes an addition between an operation of
    interest and the test on the result.
    
    Unfortunately this patch doesn't remedy all the performance
    regression for that program.  But, this patch by itself helps
    and makes sense to commit separately: lots of addi.b in
    previously empty delay-slots, with functions shortened by one or
    a few insns, in libgcc.  I had an experience with the
    reload-related caveat of % on constraints, which is "fixed"
    documentationwise since long (soon 15 years ago;
    be3914df4cc8/r105517).  I removed an even older related FIXME.
    
    gcc:
            PR target/93372
            * config/cris/cris.md ("*add<mode>3_addi"): New splitter.
            ("*addi_b_<mode>"): New pattern.
            ("*addsi3<setnz>"): Remove stale %-related comment.
    
    gcc/testsuite:
            PR target/93372
            * gcc.target/cris/pr93372-45.c: New test.

Diff:
---
 gcc/config/cris/cris.md                    | 40 +++++++++++++++++++++++++++++-
 gcc/testsuite/gcc.target/cris/pr93372-45.c | 13 ++++++++++
 2 files changed, 52 insertions(+), 1 deletion(-)

diff --git a/gcc/config/cris/cris.md b/gcc/config/cris/cris.md
index 074f5234402..efafb5b1be1 100644
--- a/gcc/config/cris/cris.md
+++ b/gcc/config/cris/cris.md
@@ -973,7 +973,6 @@
 ;; The last constraint is due to that after reload, the '%' is not
 ;; honored, and canonicalization doesn't care about keeping the same
 ;; register as in destination.  This will happen after insn splitting.
-;; gcc <= 2.7.2.  FIXME: Check for gcc-2.9x
 
  ""
 {
@@ -1291,6 +1290,45 @@
   [(set_attr "slottable" "yes")
    (set_attr "cc" "none")])
 
+;; This pattern is usually generated after reload, so a '%' is
+;; ineffective; use explicit combinations.
+(define_insn "*addi_b_<mode>"
+  [(set (match_operand:BWD 0 "register_operand" "=r,r")
+	(plus:BWD
+	 (match_operand:BWD 1 "register_operand" "0,r")
+	 (match_operand:BWD 2 "register_operand" "r,0")))]
+  ""
+  "@
+   addi %2.b,%0
+   addi %1.b,%0"
+  [(set_attr "slottable" "yes")])
+
+;; Strip the dccr clobber from addM3 with register operands, if the
+;; next instruction isn't using it.
+;; Not clobbering dccr may let cmpelim match a later compare with a
+;; previous operation of interest.  This has to run before cmpelim so it
+;; can't be a peephole2.  See gcc.target/cris/pr93372-45.c for a
+;; test-case.
+(define_split ;; "*add<mode>3_addi"
+  [(parallel
+    [(set (match_operand:BWD 0 "register_operand")
+	  (plus:BWD
+	   (match_operand:BWD 1 "register_operand")
+	   (match_operand:BWD 2 "register_operand")))
+     (clobber (reg:CC CRIS_CC0_REGNUM))])]
+  "reload_completed"
+  [(set (match_dup 0) (plus:BWD (match_dup 1) (match_dup 2)))]
+{
+  rtx reg = operands[0];
+  rtx_insn *i = next_nonnote_nondebug_insn_bb (curr_insn);
+
+  while (i != NULL_RTX && (!INSN_P (i) || DEBUG_INSN_P (i)))
+    i = next_nonnote_nondebug_insn_bb (i);
+
+  if (i == NULL_RTX || reg_mentioned_p (reg, i) || BARRIER_P (i))
+    FAIL;
+})
+
 (define_insn "<u>mul<s><mode>3"
   [(set (match_operand:WD 0 "register_operand" "=r")
 	(mult:WD
diff --git a/gcc/testsuite/gcc.target/cris/pr93372-45.c b/gcc/testsuite/gcc.target/cris/pr93372-45.c
new file mode 100644
index 00000000000..4fb7a9ac6fc
--- /dev/null
+++ b/gcc/testsuite/gcc.target/cris/pr93372-45.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+/* { dg-final { scan-assembler-not {\tcmp|\ttest} } } */
+
+extern void foo(void);
+unsigned int x (unsigned int b, unsigned int a, unsigned int *c)
+{
+  unsigned int y = a & 15;
+  unsigned int z = y + b;
+  if (y == 0)
+    *c = z;
+  return z;
+}


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

only message in thread, other threads:[~2020-07-13 20:18 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-13 20:18 [gcc/devel/c++-coroutines] cris: Use addi.b for additions where flags aren't inspected Iain D Sandoe

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).