From: Max Filippov <jcmvbkbc@gmail.com>
To: "Takayuki 'January June' Suwa" <jjsuwa_sys3175@yahoo.co.jp>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] xtensa: Optimize boolean evaluation when SImode EQ/NE to zero if TARGET_MINMAX
Date: Tue, 5 Sep 2023 16:01:13 -0700 [thread overview]
Message-ID: <CAMo8BfL=JAiVHs44=Mgoy45xbsfQVC7q_qUur9Jxgi86Mu+q2g@mail.gmail.com> (raw)
In-Reply-To: <0164dc5a-35a7-2848-8153-5016f7582576@yahoo.co.jp>
Hi Suwa-san,
On Tue, Sep 5, 2023 at 2:29 AM Takayuki 'January June' Suwa
<jjsuwa_sys3175@yahoo.co.jp> wrote:
>
> This patch optimizes the boolean evaluation for equality to 0 in SImode
> using the MINU (Minimum Value Unsigned) machine instruction available
> when TARGET_MINMAX is configured, for example, (x != 0) to MINU(x, 1)
> and (x == 0) to (MINU(x, 1) ^ 1).
>
> /* example */
> int test0(int x) {
> return x == 0;
> }
> int test1(int x) {
> return x != 0;
> }
>
> ;; before
> test0:
> mov.n a10, a2
> movi.n a9, 1
> movi.n a2, 0
> moveqz a2, a9, a10
> ret.n
> test1:
> mov.n a10, a2
> movi.n a9, 1
> movi.n a2, 0
> movnez a2, a9, a10
> ret.n
>
> ;; after (prereq. TARGET_MINMAX)
> test0:
> movi.n a9, 1
> minu a2, a2, a9
> xor a2, a2, a9
> ret.n
ISTM that test0 could be done with movnez in the same three instructions:
movi a9, 1
movnez a2, a9, a2
xor a2, a2, a9
> test1:
> movi.n a9, 1
> minu a2, a2, a9
> ret.n
ISTM that test1 could be done with movnez in the same two instructions:
movi a9, 1
movnez a2, a9, a2
--
Thanks.
-- Max
next prev parent reply other threads:[~2023-09-05 23:01 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <0164dc5a-35a7-2848-8153-5016f7582576.ref@yahoo.co.jp>
2023-09-05 9:27 ` Takayuki 'January June' Suwa
2023-09-05 23:01 ` Max Filippov [this message]
2023-09-06 4:24 ` Takayuki 'January June' Suwa
2023-09-06 10:26 ` Max Filippov
2023-09-06 10:27 ` Max Filippov
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='CAMo8BfL=JAiVHs44=Mgoy45xbsfQVC7q_qUur9Jxgi86Mu+q2g@mail.gmail.com' \
--to=jcmvbkbc@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jjsuwa_sys3175@yahoo.co.jp \
/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).