public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Segher Boessenkool <segher@kernel.crashing.org>
To: "Paul A. Clarke" <pc@us.ibm.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH 1/6] rs6000: Support SSE4.1 "round" intrinsics
Date: Wed, 18 Aug 2021 17:46:58 -0500	[thread overview]
Message-ID: <20210818224658.GL1583@gate.crashing.org> (raw)
In-Reply-To: <20210809202355.568303-2-pc@us.ibm.com>

On Mon, Aug 09, 2021 at 03:23:50PM -0500, Paul A. Clarke wrote:
> Suppress exceptions (when specified), by saving, manipulating, and
> restoring the FPSCR.  Similarly, save, set, and restore the floating-point
> rounding mode when required.
> 
> No attempt is made to optimize writing the FPSCR (by checking if the new
> value would be the same), other than using lighter weight instructions
> when possible.

There are __builtin_set_fpscr_rn and friends, please use those, those
are optimised for any platform.

> 	* config/rs6000/smmintrin.h (_mm_ceil_pd, _mm_ceil_ps, _mm_ceil_sd,
> 	_mm_ceil_ss, _mm_floor_pd, _mm_floor_ps, _mm_floor_sd, _mm_floor_ss):
> 	Convert from function to macro.

Please explain why you regress this (not in the changelog of course).

> +/* Rounding mode macros. */
> +#define _MM_FROUND_TO_NEAREST_INT       0x00
> +#define _MM_FROUND_TO_ZERO              0x01
> +#define _MM_FROUND_TO_POS_INF           0x02
> +#define _MM_FROUND_TO_NEG_INF           0x03
> +#define _MM_FROUND_CUR_DIRECTION        0x04

You can just write "0" .. "4", heh.

> +
> +#define _MM_FROUND_NINT		\
> +  (_MM_FROUND_TO_NEAREST_INT | _MM_FROUND_RAISE_EXC)
> +#define _MM_FROUND_FLOOR	\
> +  (_MM_FROUND_TO_NEG_INF | _MM_FROUND_RAISE_EXC)
> +#define _MM_FROUND_CEIL		\
> +  (_MM_FROUND_TO_POS_INF | _MM_FROUND_RAISE_EXC)
> +#define _MM_FROUND_TRUNC	\
> +  (_MM_FROUND_TO_ZERO | _MM_FROUND_RAISE_EXC)
> +#define _MM_FROUND_RINT		\
> +  (_MM_FROUND_CUR_DIRECTION | _MM_FROUND_RAISE_EXC)
> +#define _MM_FROUND_NEARBYINT	\
> +  (_MM_FROUND_CUR_DIRECTION | _MM_FROUND_NO_EXC)

All these macro definitions will comfortably fit on one line.

> +__inline __m128d
> +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
> +_mm_round_pd (__m128d __A, int __rounding)
> +{

Non-static inline is not what you want, esp. with gnu-inline?  Or, what
is the goal, and why can you not do it with modern inline?

> +  __v2df __r;
> +  union {
> +    double __fr;
> +    long long __fpscr;
> +  } __save, __tmp;
> +
> +  if (__rounding & _MM_FROUND_NO_EXC)
> +  {

Wrong indent.  This code is very hard to read because of that.

If you figure that gee, it would be a nice if we had a builtin for
mffsce, then please make one?  :-)

> +    case _MM_FROUND_TO_NEAREST_INT:
> +      __tmp.__fr = __builtin_mffsl ();
> +      __attribute__((fallthrough));

Space before (.

> +    case _MM_FROUND_TO_NEAREST_INT |_MM_FROUND_NO_EXC:

Space after |.

Please fix these things and resend.


Segher

  parent reply	other threads:[~2021-08-18 22:48 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-09 20:23 [PATCH 0/6] rs6000: Support more SSE4.1 intrinsics Paul A. Clarke
2021-08-09 20:23 ` [PATCH 1/6] rs6000: Support SSE4.1 "round" intrinsics Paul A. Clarke
2021-08-18 19:01   ` Bill Schmidt
2021-08-18 22:22     ` Segher Boessenkool
2021-08-18 22:46   ` Segher Boessenkool [this message]
2021-08-19 18:16     ` Paul A. Clarke
2021-08-19 19:47       ` Segher Boessenkool
2021-08-09 20:23 ` [PATCH 2/6] rs6000: Support SSE4.1 "min" and "max" intrinsics Paul A. Clarke
2021-08-18 19:08   ` Bill Schmidt
2021-08-09 20:23 ` [PATCH 3/6] rs6000: Simplify some SSE4.1 "test" intrinsics Paul A. Clarke
2021-08-18 19:10   ` Bill Schmidt
2021-08-09 20:23 ` [PATCH 4/6] rs6000: Support SSE4.1 "cvt" intrinsics Paul A. Clarke
2021-08-18 19:19   ` Bill Schmidt
2021-08-09 20:23 ` [PATCH 5/6] rs6000: Support more SSE4.1 "cmp", "mul", "pack" intrinsics Paul A. Clarke
2021-08-18 19:21   ` Bill Schmidt
2021-08-09 20:23 ` [PATCH 6/6] rs6000: Guard some x86 intrinsics implementations Paul A. Clarke
2021-08-18 19:27   ` Bill Schmidt

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=20210818224658.GL1583@gate.crashing.org \
    --to=segher@kernel.crashing.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=pc@us.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).