public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Uros Bizjak <ubizjak@gmail.com>
To: Roger Sayle <roger@nextmovesoftware.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [x86 PATCH] PR target/31985: Improve memory operand use with doubleword add.
Date: Fri, 16 Jun 2023 09:13:26 +0200	[thread overview]
Message-ID: <CAFULd4Y9TVbsk3Ks_DS-R+EEVM3usa4ypgR2=X42gT8R__WrWQ@mail.gmail.com> (raw)
In-Reply-To: <006701d99fd5$63e988c0$2bbc9a40$@nextmovesoftware.com>

On Fri, Jun 16, 2023 at 12:04 AM Roger Sayle <roger@nextmovesoftware.com> wrote:
>
>
> Hi Uros,
>
> > On the 7th June 2023, Uros Bizkak wrote:
> > The register allocator considers the instruction-to-be-split as one instruction, so it
> > can allocate output register to match an input register (or a register that forms an
> > input address), So, you have to either add an early clobber to the output, or
> > somehow prevent output to clobber registers in the second pattern.
>
> This implements your suggestion of adding an early clobber to the output, a
> one character ('&') change from the previous version of this patch.  Retested
> with make bootstrap and make -k check, with and without -m32, to confirm
> there are no issues, and this still fixes the pr31985.c test case.
>
> As you've suggested, I'm also working on improving STV in this area.
>
> Ok for mainline?
>
>
> 2023-06-15  Roger Sayle  <roger@nextmovesoftware.com>
>             Uros Bizjak  <ubizjak@gmail.com>
>
> gcc/ChangeLog
>         PR target/31985
>         * config/i386/i386.md (*add<dwi>3_doubleword_concat): New
>         define_insn_and_split combine *add<dwi>3_doubleword with a
>         *concat<mode><dwi>3 for more efficient lowering after reload.
>
> gcc/testsuite/ChangeLog
>         PR target/31985
>         * gcc.target/i386/pr31985.c: New test case.

OK with a small change below.

Thanks,
Uros.

+(define_insn_and_split "*add<dwi>3_doubleword_concat"
+  [(set (match_operand:<DWI> 0 "register_operand" "=&r")
+ (plus:<DWI>
+  (any_or_plus:<DWI>
+    (ashift:<DWI>
+      (zero_extend:<DWI>
+ (match_operand:DWIH 2 "nonimmediate_operand" "rm"))
+      (match_operand:<DWI> 3 "const_int_operand"))

The above mode should be QImode, all shifts have QImode on x86.

+    (zero_extend:<DWI>
+      (match_operand:DWIH 4 "nonimmediate_operand" "rm")))
+  (match_operand:<DWI> 1 "register_operand" "0")))
+   (clobber (reg:CC FLAGS_REG))]
+  "INTVAL (operands[3]) == <MODE_SIZE> * BITS_PER_UNIT"
+  "#"
+  "&& reload_completed"
+  [(parallel [(set (reg:CCC FLAGS_REG)
+   (compare:CCC
+     (plus:DWIH (match_dup 1) (match_dup 4))
+     (match_dup 1)))
+      (set (match_dup 0)
+   (plus:DWIH (match_dup 1) (match_dup 4)))])
+   (parallel [(set (match_dup 5)
+   (plus:DWIH
+     (plus:DWIH
+       (ltu:DWIH (reg:CC FLAGS_REG) (const_int 0))
+       (match_dup 6))
+     (match_dup 2)))
+      (clobber (reg:CC FLAGS_REG))])]
+ "split_double_mode (<DWI>mode, &operands[0], 2, &operands[0], &operands[5]);")
+

> Roger
> --
>

      reply	other threads:[~2023-06-16  7:13 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-06 23:05 Roger Sayle
2023-06-07  6:32 ` Uros Bizjak
2023-06-07  7:07   ` Uros Bizjak
2023-06-15 22:04     ` Roger Sayle
2023-06-16  7:13       ` Uros Bizjak [this message]

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='CAFULd4Y9TVbsk3Ks_DS-R+EEVM3usa4ypgR2=X42gT8R__WrWQ@mail.gmail.com' \
    --to=ubizjak@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=roger@nextmovesoftware.com \
    /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).