On Thu, Aug 27, 2026 at 7:33 PM Matthias Kretz <[email protected]> wrote:
>
> Tested on x86_64-linux-gnu. OK for trunk? I assume we we don't backport these
> kind of changes, right?
>
> (Patch is attached because my mail client wanted to modify the inline patch.)
>
> ------------------- 8< ------------------
>
> From: Matthias Kretz <[email protected]>
>
> floor, ceil, and trunc are compiled to vrounds[sd] and vrndscales[sdh]
> with flag_trapping_math. The packed instructions were only allowed with
> !flag_trapping_math, even though there is no observable difference from
> executing vroundss 4 times or vroundps once.
>
> According to ISO 60559, "these operations shall not signal any exception
> except for signaling NaN input". Consequently, the vector instructions
> with ROUND_NO_EXC are doing exactly that.
Ok.

>
> The 'round' function still requires !flag_trapping_math because it uses
> a floating-point add, which can signal inexact (at least).
>
> gcc/ChangeLog:
>
>         PR target/127055
>         * config/i386/sse.md (floor<mode>2): Drop !flag_trapping_math.
>         (lfloor<mode><sseintvecmodelower>2): Likewise.
>         (ceil<mode>2): Likewise.
>         (lceil<mode><sseintvecmodelower>2): Likewise.
>         (btrunc<mode>2): Likewise.
>
> gcc/testsuite/ChangeLog:
>
>         * gcc.target/i386/avx-pr127055.c: New test.
>         * gcc.target/i386/avx512f-pr127055.c: New test.
>         * gcc.target/i386/avx512fp16-pr127055.c: New test.
>         * gcc.target/i386/sse4_1-pr127055.c: New test.
>
> Signed-off-by: Matthias Kretz <[email protected]>
> ---
>  gcc/config/i386/sse.md                        | 14 ++---
>  gcc/testsuite/gcc.target/i386/avx-pr127055.c  | 11 ++++
>  .../gcc.target/i386/avx512f-pr127055.c        | 11 ++++
>  .../gcc.target/i386/avx512fp16-pr127055.c     | 32 ++++++++++
>  .../gcc.target/i386/sse4_1-pr127055.c         | 61 +++++++++++++++++++
>  5 files changed, 122 insertions(+), 7 deletions(-)
>  create mode 100644 gcc/testsuite/gcc.target/i386/avx-pr127055.c
>  create mode 100644 gcc/testsuite/gcc.target/i386/avx512f-pr127055.c
>  create mode 100644 gcc/testsuite/gcc.target/i386/avx512fp16-pr127055.c
>  create mode 100644 gcc/testsuite/gcc.target/i386/sse4_1-pr127055.c
>
>
> --
> ──────────────────────────────────────────────────────────────────────────
>  Dr. Matthias Kretz                           https://mattkretz.github.io
>  GSI Helmholtz Center for Heavy Ion Research               https://gsi.de
>  std::simd
> ──────────────────────────────────────────────────────────────────────────



-- 
BR,
Hongtao

Reply via email to