From: Segher Boessenkool <segher@kernel.crashing.org>
To: HAO CHEN GUI <guihaoc@linux.ibm.com>
Cc: gcc-patches <gcc-patches@gcc.gnu.org>, David <dje.gcc@gmail.com>,
Bill Schmidt <wschmidt@linux.ibm.com>
Subject: Re: [PATCH, rs6000] Implement mffscrni pattern
Date: Mon, 20 Dec 2021 17:14:31 -0600 [thread overview]
Message-ID: <20211220231431.GW614@gate.crashing.org> (raw)
In-Reply-To: <f235bea0-f3f2-9464-7be7-4a2b07b1489b@linux.ibm.com>
Hi!
On Mon, Dec 20, 2021 at 01:55:51PM +0800, HAO CHEN GUI wrote:
> * config/rs6000/rs6000-call.c
> (rs6000_expand_set_fpscr_rn_builtin): Not copy argument to a reg if
> it's a constant. The pattern for constant can be recognized now.
(Two spaces after full stop).
> +;; Return 1 if op is an unsigned 2-bit constant integer.
> +(define_predicate "u2bit_cint_operand"
> + (and (match_code "const_int")
> + (match_test "INTVAL (op) >= 0 && INTVAL (op) <= 3")))
Simple project for anyone: use IN_RANGE more :-)
> --- a/gcc/config/rs6000/rs6000.md
> +++ b/gcc/config/rs6000/rs6000.md
> @@ -177,6 +177,7 @@ (define_c_enum "unspecv"
> UNSPECV_MFFS ; Move from FPSCR
> UNSPECV_MFFSL ; Move from FPSCR light instruction version
> UNSPECV_MFFSCRN ; Move from FPSCR float rounding mode
> + UNSPECV_MFFSCRNI ; Move from FPSCR float rounding mode with imm
Why can this not just use the existing UNSPECV_MFFSCRN? That way, an
mffsrcn can automatically morph into an mffscrni if the argument is a
constant integer, etc.
> @@ -6333,9 +6342,15 @@ (define_expand "rs6000_set_fpscr_rn"
> new rounding mode bits from operands[0][62:63] into FPSCR[62:63]. */
> if (TARGET_P9_MISC)
> {
> - rtx src_df = force_reg (DImode, operands[0]);
> - src_df = simplify_gen_subreg (DFmode, src_df, DImode, 0);
> - emit_insn (gen_rs6000_mffscrn (tmp_df, src_df));
> + if (CONST_INT_P (operands[0])
> + && const_0_to_3_operand (operands[0], VOIDmode))
const_0_to_3_operand already checks that CONST_INT_P is true (so you
do not need to test the latter separately).
> @@ -6357,7 +6372,8 @@ (define_expand "rs6000_set_fpscr_rn"
> rtx tmp_di = gen_reg_rtx (DImode);
>
> /* Extract new RN mode from operand. */
> - emit_insn (gen_anddi3 (tmp_rn, operands[0], GEN_INT (0x3)));
> + rtx op0 = convert_to_mode (DImode, operands[0], false);
> + emit_insn (gen_anddi3 (tmp_rn, op0, GEN_INT (0x3)));
Please write 3 as 3. Not as 0x0003, not as 0x03, not as 0x3. I realise
you just copied this, but :-)
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/powerpc/mffscrni_p9.c
> @@ -0,0 +1,9 @@
> +/* { dg-do compile { target { has_arch_pwr9 } } } */
Don't do that? Instead, use -mdejagnu-cpu=power9. This will give more
coverage, and also will make us need less future test maintenance (if on
Power28 we will generate different code for this, for example).
> +void __attribute__ ((noinline)) wrap_set_fpscr_rn (int val)
> +{
> + __builtin_set_fpscr_rn (val);
> +}
Should be noipa, not just noinline?
Segher
next prev parent reply other threads:[~2021-12-20 23:15 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-20 5:55 HAO CHEN GUI
2021-12-20 15:55 ` David Edelsohn
2021-12-20 23:14 ` Segher Boessenkool [this message]
-- strict thread matches above, loose matches on Subject: below --
2021-12-17 2:43 HAO CHEN GUI
2021-12-18 3:33 ` David Edelsohn
2021-12-18 21:25 ` Segher Boessenkool
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=20211220231431.GW614@gate.crashing.org \
--to=segher@kernel.crashing.org \
--cc=dje.gcc@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=guihaoc@linux.ibm.com \
--cc=wschmidt@linux.ibm.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).