public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/98309] New: [AVX512] Missing expander for ldexpm3.
@ 2020-12-16  5:58 crazylht at gmail dot com
  2021-08-11  2:19 ` [Bug target/98309] " cvs-commit at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: crazylht at gmail dot com @ 2020-12-16  5:58 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98309

            Bug ID: 98309
           Summary: [AVX512] Missing expander for ldexpm3.
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: crazylht at gmail dot com
                CC: hjl.tools at gmail dot com, wwwhhhyyy333 at gmail dot com
  Target Milestone: ---
            Target: x86_64-*-* i?86-*-*

Cat test.c

#include<math.h>
double
foo (double r, int n)
{
    return ldexp(r, n);
}

gcc -Ofast -mavx512f generate

        jmp     ldexp

But it could be better with

        vcvtsi2sd xmm16, xmm16, edi
        vscalefsd xmm0, xmm0, xmm16
        ret  

Similar for ldexpf, except there could be some precison loss in the conversion
from 32-bit integer to float.
Also the instruction vscalefsd would response for situations
  1.the result overflow or underflow.
  2.the operands is NAN

SCALE(SRC1, SRC2)
{
; Check for denormal operands
TMP_SRC2 := SRC2
TMP_SRC1 := SRC1
IF (SRC2 is denormal AND MXCSR.DAZ) THEN TMP_SRC2=0
IF (SRC1 is denormal AND MXCSR.DAZ) THEN TMP_SRC1=0
/* SRC2 is a 64 bits floating-point value */
DEST[63:0] := TMP_SRC1[63:0] * POW(2, Floor(TMP_SRC2[63:0]))
}

So limit both expander under flag_unsafe_math_optimizations?
Similar for vector version.



cut from Intel SDM
VSCALEFPD—Scale Packed Float64 Values With Float64 Values
-----------------------
Performs a floating-point scale of the packed double-precision floating-point
value in the first source operand by
multiplying it by 2 power of the double-precision floating-point value in
second source operand.
The equation of this operation is given by:
xmm1 := xmm2*2 floor(xmm3) . ------------------------ Here



Floor(xmm3) means maximum integer value ≤ xmm3.
If the result cannot be represented in double precision, then the proper
overflow response (for positive scaling
operand), or the proper underflow response (for negative scaling operand) is
issued. The overflow and underflow
responses are dependent on the rounding mode (for IEEE-compliant rounding), as
well as on other settings in
MXCSR (exception mask bits, FTZ bit), and on the SAE bit.
EVEX encoded version: The first source operand is an XMM register. The second
source operand is an XMM register
or a memory location. The destination operand is an XMM register conditionally
updated with writemask k1.

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

* [Bug target/98309] [AVX512] Missing expander for ldexpm3.
  2020-12-16  5:58 [Bug target/98309] New: [AVX512] Missing expander for ldexpm3 crazylht at gmail dot com
@ 2021-08-11  2:19 ` cvs-commit at gcc dot gnu.org
  2021-08-11  2:22 ` crazylht at gmail dot com
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-08-11  2:19 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98309

--- Comment #1 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by hongtao Liu <liuhongt@gcc.gnu.org>:

https://gcc.gnu.org/g:05a03f3986db25cb5076b409f4048e9dbb5dbfdf

commit r12-2844-g05a03f3986db25cb5076b409f4048e9dbb5dbfdf
Author: liuhongt <hongtao.liu@intel.com>
Date:   Tue Aug 10 19:00:18 2021 +0800

    Extend ldexp{s,d}f3 to vscalefs{s,d} when TARGET_AVX512F and
TARGET_SSE_MATH.

    gcc/ChangeLog:

            PR target/98309
            * config/i386/i386.md (ldexp<mode>3): Extend to vscalefs[sd]
            when TARGET_AVX512F and TARGET_SSE_MATH.

    gcc/testsuite/ChangeLog:

            PR target/98309
            * gcc.target/i386/pr98309-1.c: New test.
            * gcc.target/i386/pr98309-2.c: New test.

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

* [Bug target/98309] [AVX512] Missing expander for ldexpm3.
  2020-12-16  5:58 [Bug target/98309] New: [AVX512] Missing expander for ldexpm3 crazylht at gmail dot com
  2021-08-11  2:19 ` [Bug target/98309] " cvs-commit at gcc dot gnu.org
@ 2021-08-11  2:22 ` crazylht at gmail dot com
  2021-08-12 19:20 ` cvs-commit at gcc dot gnu.org
  2021-08-16  9:42 ` crazylht at gmail dot com
  3 siblings, 0 replies; 5+ messages in thread
From: crazylht at gmail dot com @ 2021-08-11  2:22 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98309

--- Comment #2 from Hongtao.liu <crazylht at gmail dot com> ---
Although avx512 have vscalefps/d, vectorizer failed at 
```
      /* We can only handle calls with arguments of the same type.  */
      if (rhs_type
          && !types_compatible_p (rhs_type, TREE_TYPE (op)))
        {
          if (dump_enabled_p ())
            dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
                             "argument types differ.\n");
          return false;
        }
```

since __builtin_ldexp is defined as BT_FN_DOUBLE_DOUBLE_INT with 2 different
type arguments.

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

* [Bug target/98309] [AVX512] Missing expander for ldexpm3.
  2020-12-16  5:58 [Bug target/98309] New: [AVX512] Missing expander for ldexpm3 crazylht at gmail dot com
  2021-08-11  2:19 ` [Bug target/98309] " cvs-commit at gcc dot gnu.org
  2021-08-11  2:22 ` crazylht at gmail dot com
@ 2021-08-12 19:20 ` cvs-commit at gcc dot gnu.org
  2021-08-16  9:42 ` crazylht at gmail dot com
  3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-08-12 19:20 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98309

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Uros Bizjak <uros@gcc.gnu.org>:

https://gcc.gnu.org/g:8c8df06e46493f6cb55333db72fa1802279b48b4

commit r12-2888-g8c8df06e46493f6cb55333db72fa1802279b48b4
Author: Uros Bizjak <ubizjak@gmail.com>
Date:   Thu Aug 12 21:18:46 2021 +0200

    [i386] Introduce scalar version of avx512f_vmscalef.

    2021-08-12  Uroš Bizjak  <ubizjak@gmail.com>

    gcc/
            PR target/98309
            * config/i386/i386.md (avx512f_scalef<mode>2): New insn pattern.
            (ldexp<mode>3): Use avx512f_scalef<mode>2.
            (UNSPEC_SCALEF): Move from ...
            * config/i386/sse.md (UNSPEC_SCALEF): ... here.

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

* [Bug target/98309] [AVX512] Missing expander for ldexpm3.
  2020-12-16  5:58 [Bug target/98309] New: [AVX512] Missing expander for ldexpm3 crazylht at gmail dot com
                   ` (2 preceding siblings ...)
  2021-08-12 19:20 ` cvs-commit at gcc dot gnu.org
@ 2021-08-16  9:42 ` crazylht at gmail dot com
  3 siblings, 0 replies; 5+ messages in thread
From: crazylht at gmail dot com @ 2021-08-16  9:42 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98309

Hongtao.liu <crazylht at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #4 from Hongtao.liu <crazylht at gmail dot com> ---
Fixed in GCC12.

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

end of thread, other threads:[~2021-08-16  9:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-16  5:58 [Bug target/98309] New: [AVX512] Missing expander for ldexpm3 crazylht at gmail dot com
2021-08-11  2:19 ` [Bug target/98309] " cvs-commit at gcc dot gnu.org
2021-08-11  2:22 ` crazylht at gmail dot com
2021-08-12 19:20 ` cvs-commit at gcc dot gnu.org
2021-08-16  9:42 ` crazylht at gmail dot com

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