public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jeff Law <jeffreyalaw@gmail.com>
To: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Subject: [committed] Add missing splitter for H8
Date: Mon, 17 Oct 2022 17:25:39 -0600	[thread overview]
Message-ID: <b0111671-f8c5-0daf-8fe6-03a38055e9b0@gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 768 bytes --]

While testing a minor optimization on the H8 my builds failed due to 
failure to split a zero-extended memory load.    That particular pattern 
is a bit special on the H8 in that it's split at assembly time primarily 
to get the length computations correct.  Arguably that alternative 
should go away completely, but I haven't really looked into that.

Anyway, with the final-asm split we obviously need to match a 
define_split somewhere.  But none was ever written after adding CCZN 
optimizations.  So if we had a zero extend of a memory operand and it 
was used to eliminate a compare, then we'd abort at final asm time.


Regression tested (in conjunction with various other in-progress 
patches) on H8 without regressions.


Installed on the trunk.


Jeff

[-- Attachment #2: P --]
[-- Type: text/plain, Size: 2147 bytes --]

commit 43ee3f64cb519f2675fa1771007d4aa3baba944f
Author: Jeff Law <jeffreyalaw@gmail.com>
Date:   Mon Oct 17 19:19:25 2022 -0400

    Add missing splitter for H8
    
    While testing a minor optimization on the H8 my builds failed due to
    failure to split a zero-extended memory load.    That particular pattern
    is a bit special on the H8 in that it's split at assembly time primarily
    to get the length computations correct.  Arguably that alternative should
    go away completely, but I haven't really looked into that.
    
    Anyway, with the final-asm split we obviously need to match a define_split
    somewhere.  But none was ever written after adding CCZN optimizations.  So
    if we had a zero extend of a memory operand and it was used to eliminate
    a compare, then we'd abort at final asm time.
    
    Regression tested (in conjunction with various other in-progress patches) on
    H8 without regressions.
    
    gcc/
            * config/h8300/extensions.md (CCZN setting zero extended load): Add
            missing splitter.

diff --git a/gcc/config/h8300/extensions.md b/gcc/config/h8300/extensions.md
index 74647c79cd8..7149dc0ac52 100644
--- a/gcc/config/h8300/extensions.md
+++ b/gcc/config/h8300/extensions.md
@@ -47,6 +47,24 @@
     operands[2] = gen_rtx_REG (QImode, REGNO (operands[0]));
   })
 
+;; Similarly, but setting cczn.
+(define_split
+  [(set (reg:CCZN CC_REG)
+	(compare:CCZN
+	  (zero_extend:HI (match_operand:QI 1 "general_operand_src" ""))
+	  (const_int 0)))
+   (set (match_operand:HI 0 "register_operand" "")
+        (zero_extend:HI (match_dup 1)))]
+  "!REG_P (operands[1]) && reload_completed"
+  [(parallel [(set (match_dup 2) (match_dup 1))
+	      (clobber (reg:CC CC_REG))])
+   (parallel [(set (reg:CCZN CC_REG)
+		   (compare:CCZN (zero_extend:HI (match_dup 2)) (const_int 0)))
+	      (set (match_dup 0) (zero_extend:HI (match_dup 2)))])]
+  {
+    operands[2] = gen_rtx_REG (QImode, REGNO (operands[0]));
+  })
+
 (define_insn "*zero_extendqisi2"
   [(set (match_operand:SI 0 "register_operand" "=r,r")
 	(zero_extend:SI (match_operand:QI 1 "general_operand_src" "0,g>")))]

                 reply	other threads:[~2022-10-17 23:25 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b0111671-f8c5-0daf-8fe6-03a38055e9b0@gmail.com \
    --to=jeffreyalaw@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).