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 or branching when EQ/NE to zero in S[IF]mode
Date: Sun, 4 Jun 2023 05:46:13 -0700 [thread overview]
Message-ID: <CAMo8BfJyMfhaW2Ot-DxhtjTJYNxv-cVHm5zrxTKWv-cNLUtnkg@mail.gmail.com> (raw)
In-Reply-To: <a6428a06-f728-06a9-a530-36aa115291dc@yahoo.co.jp>
Hi Suwa-san,
On Sat, Jun 3, 2023 at 2:55 AM Takayuki 'January June' Suwa
<jjsuwa_sys3175@yahoo.co.jp> wrote:
>
> This patch optimizes the boolean evaluation of EQ/NE against zero
> by adding two insn_and_split patterns similar to SImode conditional
> store:
>
> "eq_zero":
> op0 = (op1 == 0) ? 1 : 0;
> op0 = clz(op1) >> 5; /* optimized (requires TARGET_NSA) */
>
> "movsicc_ne0_reg_0":
> op0 = (op1 != 0) ? op2 : 0;
> op0 = op2; if (op1 == 0) ? op0 = op1; /* optimized */
>
> These also work in SFmode by ignoring their sign bits, and further-
> more, the branch if EQ/NE against zero in SFmode is also done in the
> same manner.
>
> The reasons for this optimization in SFmode are:
>
> - Only zero values (negative or non-negative) contain no bits of 1
> with both the exponent and the mantissa.
> - EQ/NE comparisons involving NaNs produce no signal even if they
> are signaling.
> - Even if the use of IEEE 754 single-precision floating-point co-
> processor is configured (TARGET_HARD_FLOAT is true):
> 1. Load zero value to FP register
> 2. Possibly, additional FP move if the comparison target is
> an address register
> 3. FP equality check instruction
> 4. Read the boolean register containing the result, or condi-
> tional branch
> As noted above, a considerable number of instructions are still
> generated.
>
> gcc/ChangeLog:
>
> * config/xtensa/predicates.md (const_float_0_operand):
> Rename from obsolete "const_float_1_operand" and change the
> constant to compare.
> (cstoresf_cbranchsf_operand, cstoresf_cbranchsf_operator):
> New.
> * config/xtensa/xtensa.cc (xtensa_expand_conditional_branch):
> Add code for EQ/NE comparison with constant zero in SFmode.
> (xtensa_expand_scc): Added code to derive boolean evaluation
> of EQ/NE with constant zero for comparison in SFmode.
> (xtensa_rtx_costs): Change cost of CONST_DOUBLE with value
> zero inside "cbranchsf4" to 0.
> * config/xtensa/xtensa.md (cbranchsf4, cstoresf4):
> Change "match_operator" and the third "match_operand" to the
> ones mentioned above.
> (movsicc_ne0_reg_zero, eq_zero): New.
> ---
> gcc/config/xtensa/predicates.md | 19 ++++++++++--
> gcc/config/xtensa/xtensa.cc | 43 ++++++++++++++++++++++++++
> gcc/config/xtensa/xtensa.md | 53 +++++++++++++++++++++++++++++----
> 3 files changed, 106 insertions(+), 9 deletions(-)
This change results in a bunch of new testsuite failures
on configurations without FPU that are all ICEs:
+FAIL: gcc.c-torture/execute/bitfld-3.c -O1 execution test
+FAIL: gcc.dg/atomic/c11-atomic-exec-1.c -O1 (internal compiler
error: in extract_insn, at recog.cc:2791)
+FAIL: gcc.dg/atomic/c11-atomic-exec-1.c -O1 (test for excess errors)
+FAIL: gcc.dg/atomic/c11-atomic-exec-1.c -O2 (internal compiler
error: in extract_insn, at recog.cc:2791)
+FAIL: gcc.dg/atomic/c11-atomic-exec-1.c -O2 (test for excess errors)
+FAIL: gcc.dg/atomic/c11-atomic-exec-1.c -O3 -fomit-frame-pointer
-funroll-loops -fpeel-loops -ftracer -finline-functions (internal
compiler error: in extract_insn, at recog.cc:2791)
+FAIL: gcc.dg/atomic/c11-atomic-exec-1.c -O3 -fomit-frame-pointer
-funroll-loops -fpeel-loops -ftracer -finline-functions (test for
excess errors)
+FAIL: gcc.dg/atomic/c11-atomic-exec-1.c -O3 -g (internal compiler
error: in extract_insn, at recog.cc:2791)
+FAIL: gcc.dg/atomic/c11-atomic-exec-1.c -O3 -g (test for excess errors)
+FAIL: gcc.dg/atomic/c11-atomic-exec-1.c -Os (internal compiler
error: in extract_insn, at recog.cc:2791)
+FAIL: gcc.dg/atomic/c11-atomic-exec-1.c -Os (test for excess errors)
+FAIL: gcc.dg/atomic/c11-atomic-exec-1.c -O2 -flto
-fno-use-linker-plugin -flto-partition=none (internal compiler error:
in extract_insn, at recog.cc:2791)
+FAIL: gcc.dg/atomic/c11-atomic-exec-1.c -O2 -flto
-fno-use-linker-plugin -flto-partition=none (test for excess errors)
+FAIL: gcc.dg/atomic/c11-atomic-exec-1.c -O2 -flto
-fuse-linker-plugin -fno-fat-lto-objects (internal compiler error: in
extract_insn, at recog.cc:2791)
+FAIL: gcc.dg/atomic/c11-atomic-exec-1.c -O2 -flto
-fuse-linker-plugin -fno-fat-lto-objects (test for excess errors)
+FAIL: gcc.dg/atomic/c11-atomic-exec-3.c -O1 (internal compiler
error: in extract_insn, at recog.cc:2791)
+FAIL: gcc.dg/atomic/c11-atomic-exec-3.c -O1 (test for excess errors)
+FAIL: gcc.dg/atomic/c11-atomic-exec-3.c -O2 (internal compiler
error: in extract_insn, at recog.cc:2791)
+FAIL: gcc.dg/atomic/c11-atomic-exec-3.c -O2 (test for excess errors)
+FAIL: gcc.dg/atomic/c11-atomic-exec-3.c -O3 -fomit-frame-pointer
-funroll-loops -fpeel-loops -ftracer -finline-functions (internal
compiler error: in extract_insn, at recog.cc:2791)
+FAIL: gcc.dg/atomic/c11-atomic-exec-3.c -O3 -fomit-frame-pointer
-funroll-loops -fpeel-loops -ftracer -finline-functions (test for
excess errors)
+FAIL: gcc.dg/atomic/c11-atomic-exec-3.c -O3 -g (internal compiler
error: in extract_insn, at recog.cc:2791)
+FAIL: gcc.dg/atomic/c11-atomic-exec-3.c -O3 -g (test for excess errors)
+FAIL: gcc.dg/atomic/c11-atomic-exec-3.c -Os (internal compiler
error: in extract_insn, at recog.cc:2791)
+FAIL: gcc.dg/atomic/c11-atomic-exec-3.c -Os (test for excess errors)
+FAIL: gcc.dg/atomic/c11-atomic-exec-3.c -O2 -flto
-fno-use-linker-plugin -flto-partition=none (internal compiler error:
in extract_insn, at recog.cc:2791)
+FAIL: gcc.dg/atomic/c11-atomic-exec-3.c -O2 -flto
-fno-use-linker-plugin -flto-partition=none (test for excess errors)
+FAIL: gcc.dg/atomic/c11-atomic-exec-3.c -O2 -flto
-fuse-linker-plugin -fno-fat-lto-objects (internal compiler error: in
extract_insn, at recog.cc:2791)
+FAIL: gcc.dg/atomic/c11-atomic-exec-3.c -O2 -flto
-fuse-linker-plugin -fno-fat-lto-objects (test for excess errors)
+FAIL: gcc.dg/atomic/pr65345-4.c -O1 (internal compiler error: in
extract_insn, at recog.cc:2791)
+FAIL: gcc.dg/atomic/pr65345-4.c -O1 (test for excess errors)
+FAIL: gcc.dg/atomic/pr65345-4.c -O2 (internal compiler error: in
extract_insn, at recog.cc:2791)
+FAIL: gcc.dg/atomic/pr65345-4.c -O2 (test for excess errors)
+FAIL: gcc.dg/atomic/pr65345-4.c -O3 -g (internal compiler error:
in extract_insn, at recog.cc:2791)
+FAIL: gcc.dg/atomic/pr65345-4.c -O3 -g (test for excess errors)
+FAIL: gcc.dg/atomic/pr65345-4.c -Os (internal compiler error: in
extract_insn, at recog.cc:2791)
+FAIL: gcc.dg/atomic/pr65345-4.c -Os (test for excess errors)
+FAIL: gcc.dg/atomic/pr65345-4.c -O2 -flto -fno-use-linker-plugin
-flto-partition=none (internal compiler error: in extract_insn, at
recog.cc:2791)
+FAIL: gcc.dg/atomic/pr65345-4.c -O2 -flto -fno-use-linker-plugin
-flto-partition=none (test for excess errors)
On configuration with FPU it results in ICEs during libgfortran build, all
with the similar diagnostic:
gcc/libgfortran/intrinsics/erfc_scaled_inc.c:179:1: error: unrecognizable insn:
179 | }
| ^
(insn 23 22 24 2 (set (reg:CC 18 b0)
(lt:CC (const_double:SF 0.0 [0x0.0p+0])
(reg/v:SF 96 [ x ])))
"gcc/libgfortran/intrinsics/erfc_scaled_inc.c":111:18 -1
(nil))
during RTL pass: vregs
--
Thanks.
-- Max
prev parent reply other threads:[~2023-06-04 12:46 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <a6428a06-f728-06a9-a530-36aa115291dc.ref@yahoo.co.jp>
2023-06-03 9:55 ` Takayuki 'January June' Suwa
2023-06-04 12:46 ` Max Filippov [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=CAMo8BfJyMfhaW2Ot-DxhtjTJYNxv-cVHm5zrxTKWv-cNLUtnkg@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).