public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* fminnm/fmaxnm generation in aarch64
       [not found] <4067c389-edc1-3858-e52c-8b9f167316a7@oracle.com>
@ 2018-05-07 17:03 ` Indu Bhagat
  2018-05-08  7:57   ` Andrew Haley
  2018-05-08 21:22   ` Joseph Myers
  0 siblings, 2 replies; 3+ messages in thread
From: Indu Bhagat @ 2018-05-07 17:03 UTC (permalink / raw)
  To: gcc

[Trying to get some feedback. I earlier posted on gcc-help a week ago]

In tree.def -

/* Minimum and maximum values.  When used with floating point, if both
    operands are zeros, or if either operand is NaN, then it is unspecified
    which of the two operands is returned as the result. */
DEFTREECODE (MIN_EXPR, "min_expr", tcc_binary, 2)
DEFTREECODE (MAX_EXPR, "max_expr", tcc_binary, 2)

I see that the compiler cannot simplify an expression like
((a<b)?a:b) into a MIN_EXPR for FP data types without additional flags
(-ffinite-math-only -fno-signed zeros flags).

Q1: It is not clear to me what is the fundamental reason of the
     "unspecified behaviour" of MIN_EXPR/MAX_EXPR in case of floating point
     operands ?

(For the sake of discussing what I write hereafter, assume that
fminnm/fmaxnm instructions offer better performance than fcsel/fcmp). So, two
further questions:

Q2. If one wants the compiler to generate fminnm/fmaxnm instructions, while
     conforming with IEEE standard, the way to do that will be to use math
     builtins fmin()/fmax(). Is this correct understanding?

Q3. What will it take for the compiler transform high-level language
     floating point construct like ((a<b)?a:b) to a fminnm/fmaxnm insn for
     aarch64 targets?

Thanks!

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: fminnm/fmaxnm generation in aarch64
  2018-05-07 17:03 ` fminnm/fmaxnm generation in aarch64 Indu Bhagat
@ 2018-05-08  7:57   ` Andrew Haley
  2018-05-08 21:22   ` Joseph Myers
  1 sibling, 0 replies; 3+ messages in thread
From: Andrew Haley @ 2018-05-08  7:57 UTC (permalink / raw)
  To: gcc

On 07/05/18 18:08, Indu Bhagat wrote:
> [Trying to get some feedback. I earlier posted on gcc-help a week ago]
> 
> In tree.def -
> 
> /* Minimum and maximum values.  When used with floating point, if both
>     operands are zeros, or if either operand is NaN, then it is unspecified
>     which of the two operands is returned as the result. */
> DEFTREECODE (MIN_EXPR, "min_expr", tcc_binary, 2)
> DEFTREECODE (MAX_EXPR, "max_expr", tcc_binary, 2)
> 
> I see that the compiler cannot simplify an expression like
> ((a<b)?a:b) into a MIN_EXPR for FP data types without additional flags
> (-ffinite-math-only -fno-signed zeros flags).
> 
> Q1: It is not clear to me what is the fundamental reason of the
>      "unspecified behaviour" of MIN_EXPR/MAX_EXPR in case of floating point
>      operands ?
> 
> (For the sake of discussing what I write hereafter, assume that
> fminnm/fmaxnm instructions offer better performance than fcsel/fcmp). So, two
> further questions:
> 
> Q2. If one wants the compiler to generate fminnm/fmaxnm instructions, while
>      conforming with IEEE standard, the way to do that will be to use math
>      builtins fmin()/fmax(). Is this correct understanding?

Yes.

> Q3. What will it take for the compiler transform high-level language
>      floating point construct like ((a<b)?a:b) to a fminnm/fmaxnm insn for
>      aarch64 targets?

You'd have to use -ffast-math or .ffinite-math-only.  The meaning of the expression
((a<b)?a:b) is not the same as fminnm.  It would be incorrect for GCC to translate
that expression into fminnm.

-- 
Andrew Haley
Java Platform Lead Engineer
Red Hat UK Ltd. <https://www.redhat.com>
EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: fminnm/fmaxnm generation in aarch64
  2018-05-07 17:03 ` fminnm/fmaxnm generation in aarch64 Indu Bhagat
  2018-05-08  7:57   ` Andrew Haley
@ 2018-05-08 21:22   ` Joseph Myers
  1 sibling, 0 replies; 3+ messages in thread
From: Joseph Myers @ 2018-05-08 21:22 UTC (permalink / raw)
  To: Indu Bhagat; +Cc: gcc

On Mon, 7 May 2018, Indu Bhagat wrote:

> Q2. If one wants the compiler to generate fminnm/fmaxnm instructions, while
>     conforming with IEEE standard, the way to do that will be to use math
>     builtins fmin()/fmax(). Is this correct understanding?

For IEEE 754-2008 minNum / maxNum operations, which those instructions 
correspond to and fmin and fmax bind to, yes.  For IEEE 754-2018 (in 
progress), there are different minimum / maximum operations, which don't 
match those AArch64 instructions (but some do match RISC-V instructions), 
and there are new proposed corresponding C functions such as fmaximum and 
fminimum_num (I don't know of implementations of those functions).

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-05-08 21:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <4067c389-edc1-3858-e52c-8b9f167316a7@oracle.com>
2018-05-07 17:03 ` fminnm/fmaxnm generation in aarch64 Indu Bhagat
2018-05-08  7:57   ` Andrew Haley
2018-05-08 21:22   ` Joseph Myers

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).