Hi Richard,

on 2023/1/27 19:08, Richard Sandiford via Gcc-patches wrote:
> PR96373 points out that a predicated SVE loop currently converts
> trapping unconditional ops into unpredicated vector ops.  Doing
> the operation on inactive lanes can then raise an exception.
> 
> As discussed in the PR trail, we aren't 100% consistent about
> whether we preserve traps or not.  But the direction of travel
> is clearly to improve that rather than live with it.  This patch
> tries to do that for the SVE case.
> 
> Doing this regresses gcc.target/aarch64/sve/fabd_1.c.  I've added
> -fno-trapping-math for now and filed PR108571 to track it.
> A similar problem applies to fsubr_1.d.
> 
> I think this is likely to regress Power 10, since conditional
> operations are only available for masked loops.  I think we'll
> need to add -fno-trapping-math to any affected testcases,
> but I don't have a Power 10 system to test on.  Kewen, would you
> mind giving this a spin and seeing how bad the fallout is?
> 

Sorry for the late reply, I'm just back from vacation.

Thank you for fixing this and caring about Power10!

I tested your proposed patch on one Power10 machine (ppc64le),
it's bootstrapped but some test failures got exposed as below.

< FAIL: gcc.target/powerpc/p9-vec-length-epil-1.c scan-assembler-times 
\\\\mlxvl\\\\M 14
< FAIL: gcc.target/powerpc/p9-vec-length-epil-1.c scan-assembler-times 
\\\\mstxvl\\\\M 7
< FAIL: gcc.target/powerpc/p9-vec-length-epil-2.c scan-assembler-times 
\\\\mlxvl\\\\M 20
< FAIL: gcc.target/powerpc/p9-vec-length-epil-2.c scan-assembler-times 
\\\\mstxvl\\\\M 10
< FAIL: gcc.target/powerpc/p9-vec-length-epil-3.c scan-assembler-times 
\\\\mlxvl\\\\M 14
< FAIL: gcc.target/powerpc/p9-vec-length-epil-3.c scan-assembler-times 
\\\\mstxvl\\\\M 7
< FAIL: gcc.target/powerpc/p9-vec-length-epil-4.c scan-assembler-times 
\\\\mlxvl\\\\M 70
< FAIL: gcc.target/powerpc/p9-vec-length-epil-4.c scan-assembler-times 
\\\\mlxvx?\\\\M 120
< FAIL: gcc.target/powerpc/p9-vec-length-epil-4.c scan-assembler-times 
\\\\mstxvl\\\\M 70
< FAIL: gcc.target/powerpc/p9-vec-length-epil-4.c scan-assembler-times 
\\\\mstxvx?\\\\M 70
< FAIL: gcc.target/powerpc/p9-vec-length-epil-5.c scan-assembler-times 
\\\\mlxvl\\\\M 21
< FAIL: gcc.target/powerpc/p9-vec-length-epil-5.c scan-assembler-times 
\\\\mstxvl\\\\M 21
< FAIL: gcc.target/powerpc/p9-vec-length-epil-5.c scan-assembler-times 
\\\\mstxvx?\\\\M 21
< FAIL: gcc.target/powerpc/p9-vec-length-epil-6.c scan-assembler-times 
\\\\mlxvl\\\\M 10
< FAIL: gcc.target/powerpc/p9-vec-length-epil-6.c scan-assembler-times 
\\\\mlxvx?\\\\M 42
< FAIL: gcc.target/powerpc/p9-vec-length-epil-6.c scan-assembler-times 
\\\\mstxvl\\\\M 10
< FAIL: gcc.target/powerpc/p9-vec-length-epil-8.c scan-assembler-times 
\\\\mlxvl\\\\M 16
< FAIL: gcc.target/powerpc/p9-vec-length-epil-8.c scan-assembler-times 
\\\\mstxvl\\\\M 7
< FAIL: gcc.target/powerpc/p9-vec-length-full-1.c scan-assembler-not 
\\\\mlxvx\\\\M
< FAIL: gcc.target/powerpc/p9-vec-length-full-1.c scan-assembler-not 
\\\\mstxvx\\\\M
< FAIL: gcc.target/powerpc/p9-vec-length-full-1.c scan-assembler-times 
\\\\mlxvl\\\\M 20
< FAIL: gcc.target/powerpc/p9-vec-length-full-1.c scan-assembler-times 
\\\\mstxvl\\\\M 10
< FAIL: gcc.target/powerpc/p9-vec-length-full-2.c scan-assembler-not 
\\\\mlxvx\\\\M
< FAIL: gcc.target/powerpc/p9-vec-length-full-2.c scan-assembler-not 
\\\\mstxvx\\\\M
< FAIL: gcc.target/powerpc/p9-vec-length-full-2.c scan-assembler-times 
\\\\mlxvl\\\\M 20
< FAIL: gcc.target/powerpc/p9-vec-length-full-2.c scan-assembler-times 
\\\\mstxvl\\\\M 10
< FAIL: gcc.target/powerpc/p9-vec-length-full-3.c scan-assembler-times 
\\\\mlxvl\\\\M 14
< FAIL: gcc.target/powerpc/p9-vec-length-full-3.c scan-assembler-times 
\\\\mstxvl\\\\M 7
< FAIL: gcc.target/powerpc/p9-vec-length-full-4.c scan-assembler-not 
\\\\mlxvx\\\\M
< FAIL: gcc.target/powerpc/p9-vec-length-full-4.c scan-assembler-not 
\\\\mstxv\\\\M
< FAIL: gcc.target/powerpc/p9-vec-length-full-4.c scan-assembler-not 
\\\\mstxvx\\\\M
< FAIL: gcc.target/powerpc/p9-vec-length-full-4.c scan-assembler-times 
\\\\mlxvl\\\\M 70
< FAIL: gcc.target/powerpc/p9-vec-length-full-4.c scan-assembler-times 
\\\\mstxvl\\\\M 70
< FAIL: gcc.target/powerpc/p9-vec-length-full-5.c scan-assembler-not 
\\\\mlxvx\\\\M
< FAIL: gcc.target/powerpc/p9-vec-length-full-5.c scan-assembler-not 
\\\\mstxv\\\\M
< FAIL: gcc.target/powerpc/p9-vec-length-full-5.c scan-assembler-not 
\\\\mstxvx\\\\M
< FAIL: gcc.target/powerpc/p9-vec-length-full-5.c scan-assembler-times 
\\\\mlxvl\\\\M 21
< FAIL: gcc.target/powerpc/p9-vec-length-full-5.c scan-assembler-times 
\\\\mstxvl\\\\M 21
< FAIL: gcc.target/powerpc/p9-vec-length-full-6.c scan-assembler-times 
\\\\mlxvl\\\\M 10
< FAIL: gcc.target/powerpc/p9-vec-length-full-6.c scan-assembler-times 
\\\\mstxvl\\\\M 10
< FAIL: gcc.target/powerpc/p9-vec-length-full-6.c scan-assembler-times 
\\\\mstxvx?\\\\M 6
< FAIL: gcc.target/powerpc/p9-vec-length-full-8.c scan-assembler-times 
\\\\mlxvl\\\\M 30
< FAIL: gcc.target/powerpc/p9-vec-length-full-8.c scan-assembler-times 
\\\\mstxvl\\\\M 10

By checking several of them, it's due to that we don't vectorize
some loop having float type involved with partial vector any more.

As you suggested above, I fixed them with an extra option
"-fno-trapping-math" and verified all of them can pass again.
I also noticed that the original test case in PR96373 fails
on Power10 too, so I added one constructed case pr96373.c
into sub bucket gcc.target/powerpc for testing coverage
on Power.

One re-spin with the attached adjustment shows there is no
regression failure any more, and the new test case works well
on both ppc64 (P8) and ppc64le (P10) Linux.

BR,
Kewen
-----
From 5267731d8949c242b6188c3e9f7b0d561e6e092d Mon Sep 17 00:00:00 2001
From: Kewen Lin <li...@linux.ibm.com>
Date: Mon, 13 Feb 2023 17:07:50 +0800
Subject: [PATCH] rs6000 test cases adjustment

gcc/testsuite/ChangeLog:

        * gcc.target/powerpc/p9-vec-length-epil-1.c: Add -fno-trapping-math.
        * gcc.target/powerpc/p9-vec-length-epil-2.c: Likewise.
        * gcc.target/powerpc/p9-vec-length-epil-3.c: Likewise.
        * gcc.target/powerpc/p9-vec-length-epil-4.c: Likewise.
        * gcc.target/powerpc/p9-vec-length-epil-5.c: Likewise.
        * gcc.target/powerpc/p9-vec-length-epil-6.c: Likewise.
        * gcc.target/powerpc/p9-vec-length-epil-8.c: Likewise.
        * gcc.target/powerpc/p9-vec-length-full-1.c: Likewise.
        * gcc.target/powerpc/p9-vec-length-full-2.c: Likewise.
        * gcc.target/powerpc/p9-vec-length-full-3.c: Likewise.
        * gcc.target/powerpc/p9-vec-length-full-4.c: Likewise.
        * gcc.target/powerpc/p9-vec-length-full-5.c: Likewise.
        * gcc.target/powerpc/p9-vec-length-full-6.c: Likewise.
        * gcc.target/powerpc/p9-vec-length-full-8.c: Likewise.
        * gcc.target/powerpc/pr96373.c: New test.
---
 .../gcc.target/powerpc/p9-vec-length-epil-1.c |  2 +-
 .../gcc.target/powerpc/p9-vec-length-epil-2.c |  2 +-
 .../gcc.target/powerpc/p9-vec-length-epil-3.c |  2 +-
 .../gcc.target/powerpc/p9-vec-length-epil-4.c |  2 +-
 .../gcc.target/powerpc/p9-vec-length-epil-5.c |  2 +-
 .../gcc.target/powerpc/p9-vec-length-epil-6.c |  2 +-
 .../gcc.target/powerpc/p9-vec-length-epil-8.c |  2 +-
 .../gcc.target/powerpc/p9-vec-length-full-1.c |  2 +-
 .../gcc.target/powerpc/p9-vec-length-full-2.c |  2 +-
 .../gcc.target/powerpc/p9-vec-length-full-3.c |  2 +-
 .../gcc.target/powerpc/p9-vec-length-full-4.c |  2 +-
 .../gcc.target/powerpc/p9-vec-length-full-5.c |  2 +-
 .../gcc.target/powerpc/p9-vec-length-full-6.c |  2 +-
 .../gcc.target/powerpc/p9-vec-length-full-8.c |  2 +-
 gcc/testsuite/gcc.target/powerpc/pr96373.c    | 31 +++++++++++++++++++
 15 files changed, 45 insertions(+), 14 deletions(-)
 create mode 100644 gcc/testsuite/gcc.target/powerpc/pr96373.c

diff --git a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-1.c 
b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-1.c
index d248f091b52..dfcc0e95320 100644
--- a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-1.c
+++ b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-1.c
@@ -1,5 +1,5 @@
 /* { dg-do compile { target { lp64 && powerpc_p9vector_ok } } } */
-/* { dg-options "-mdejagnu-cpu=power9 -O2 -ftree-vectorize 
-fno-vect-cost-model -fno-unroll-loops" } */
+/* { dg-options "-mdejagnu-cpu=power9 -O2 -ftree-vectorize 
-fno-vect-cost-model -fno-unroll-loops -fno-trapping-math" } */
 
 /* { dg-additional-options "--param=vect-partial-vector-usage=1" } */
 
diff --git a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-2.c 
b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-2.c
index 9f78a447ec7..e63f1bf2372 100644
--- a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-2.c
+++ b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-2.c
@@ -1,5 +1,5 @@
 /* { dg-do compile { target { lp64 && powerpc_p9vector_ok } } } */
-/* { dg-options "-mdejagnu-cpu=power9 -O2 -ftree-vectorize 
-fno-vect-cost-model -fno-unroll-loops" } */
+/* { dg-options "-mdejagnu-cpu=power9 -O2 -ftree-vectorize 
-fno-vect-cost-model -fno-unroll-loops -fno-trapping-math" } */
 
 /* { dg-additional-options "--param=vect-partial-vector-usage=1" } */
 
diff --git a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-3.c 
b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-3.c
index a08797fcbca..4a99e3a3265 100644
--- a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-3.c
+++ b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-3.c
@@ -1,5 +1,5 @@
 /* { dg-do compile { target { lp64 && powerpc_p9vector_ok } } } */
-/* { dg-options "-mdejagnu-cpu=power9 -O2 -ftree-vectorize 
-fno-vect-cost-model -fno-unroll-loops" } */
+/* { dg-options "-mdejagnu-cpu=power9 -O2 -ftree-vectorize 
-fno-vect-cost-model -fno-unroll-loops -fno-trapping-math" } */
 
 /* { dg-additional-options "--param=vect-partial-vector-usage=1" } */
 
diff --git a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-4.c 
b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-4.c
index ad051fb1cef..9fbee6a4324 100644
--- a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-4.c
+++ b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-4.c
@@ -1,5 +1,5 @@
 /* { dg-do compile { target { lp64 && powerpc_p9vector_ok } } } */
-/* { dg-options "-mdejagnu-cpu=power9 -O2 -ftree-vectorize 
-fno-vect-cost-model -fno-unroll-loops" } */
+/* { dg-options "-mdejagnu-cpu=power9 -O2 -ftree-vectorize 
-fno-vect-cost-model -fno-unroll-loops -fno-trapping-math" } */
 
 /* { dg-additional-options "--param=vect-partial-vector-usage=1" } */
 
diff --git a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-5.c 
b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-5.c
index a24c30feeba..d023a998c3b 100644
--- a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-5.c
+++ b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-5.c
@@ -1,5 +1,5 @@
 /* { dg-do compile { target { lp64 && powerpc_p9vector_ok } } } */
-/* { dg-options "-mdejagnu-cpu=power9 -O2 -ftree-vectorize 
-fno-vect-cost-model -fno-unroll-loops" } */
+/* { dg-options "-mdejagnu-cpu=power9 -O2 -ftree-vectorize 
-fno-vect-cost-model -fno-unroll-loops -fno-trapping-math" } */
 
 /* { dg-additional-options "--param=vect-partial-vector-usage=1" } */
 
diff --git a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-6.c 
b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-6.c
index 4eaeb3b005f..dbce90757e3 100644
--- a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-6.c
+++ b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-6.c
@@ -1,5 +1,5 @@
 /* { dg-do compile { target { lp64 && powerpc_p9vector_ok } } } */
-/* { dg-options "-mdejagnu-cpu=power9 -O2 -ftree-vectorize 
-fno-vect-cost-model -fno-unroll-loops" } */
+/* { dg-options "-mdejagnu-cpu=power9 -O2 -ftree-vectorize 
-fno-vect-cost-model -fno-unroll-loops -fno-trapping-math" } */
 
 /* { dg-additional-options "--param=vect-partial-vector-usage=1" } */
 
diff --git a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-8.c 
b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-8.c
index 8b9c9107814..e56fd55f623 100644
--- a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-8.c
+++ b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-epil-8.c
@@ -1,5 +1,5 @@
 /* { dg-do compile { target { lp64 && powerpc_p9vector_ok } } } */
-/* { dg-options "-mdejagnu-cpu=power9 -O2 -ftree-vectorize 
-fno-vect-cost-model -fno-unroll-loops" } */
+/* { dg-options "-mdejagnu-cpu=power9 -O2 -ftree-vectorize 
-fno-vect-cost-model -fno-unroll-loops -fno-trapping-math" } */
 
 /* { dg-additional-options "--param=vect-partial-vector-usage=1" } */
 
diff --git a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-1.c 
b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-1.c
index 3336752edbb..f01f1c54fa5 100644
--- a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-1.c
+++ b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-1.c
@@ -1,5 +1,5 @@
 /* { dg-do compile { target { lp64 && powerpc_p9vector_ok } } } */
-/* { dg-options "-mdejagnu-cpu=power9 -O2 -ftree-vectorize 
-fno-vect-cost-model -fno-unroll-loops" } */
+/* { dg-options "-mdejagnu-cpu=power9 -O2 -ftree-vectorize 
-fno-vect-cost-model -fno-unroll-loops -fno-trapping-math" } */
 
 /* { dg-additional-options "--param=vect-partial-vector-usage=2" } */
 
diff --git a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-2.c 
b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-2.c
index 98abf8b33b1..f546e97fa7d 100644
--- a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-2.c
+++ b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-2.c
@@ -1,5 +1,5 @@
 /* { dg-do compile { target { lp64 && powerpc_p9vector_ok } } } */
-/* { dg-options "-mdejagnu-cpu=power9 -O2 -ftree-vectorize 
-fno-vect-cost-model -fno-unroll-loops" } */
+/* { dg-options "-mdejagnu-cpu=power9 -O2 -ftree-vectorize 
-fno-vect-cost-model -fno-unroll-loops -fno-trapping-math" } */
 
 /* { dg-additional-options "--param=vect-partial-vector-usage=2" } */
 
diff --git a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-3.c 
b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-3.c
index 0881d1a960a..65142b3fecd 100644
--- a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-3.c
+++ b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-3.c
@@ -1,5 +1,5 @@
 /* { dg-do compile { target { lp64 && powerpc_p9vector_ok } } } */
-/* { dg-options "-mdejagnu-cpu=power9 -O2 -ftree-vectorize 
-fno-vect-cost-model -fno-unroll-loops" } */
+/* { dg-options "-mdejagnu-cpu=power9 -O2 -ftree-vectorize 
-fno-vect-cost-model -fno-unroll-loops -fno-trapping-math" } */
 
 /* { dg-additional-options "--param=vect-partial-vector-usage=2" } */
 
diff --git a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-4.c 
b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-4.c
index 8ce3dc19a60..a4cc7aafaeb 100644
--- a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-4.c
+++ b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-4.c
@@ -1,5 +1,5 @@
 /* { dg-do compile { target { lp64 && powerpc_p9vector_ok } } } */
-/* { dg-options "-mdejagnu-cpu=power9 -O2 -ftree-vectorize 
-fno-vect-cost-model -fno-unroll-loops" } */
+/* { dg-options "-mdejagnu-cpu=power9 -O2 -ftree-vectorize 
-fno-vect-cost-model -fno-unroll-loops -fno-trapping-math" } */
 
 /* { dg-additional-options "--param=vect-partial-vector-usage=2" } */
 
diff --git a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-5.c 
b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-5.c
index f9f58ba11f5..4b0b9070c84 100644
--- a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-5.c
+++ b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-5.c
@@ -1,5 +1,5 @@
 /* { dg-do compile { target { lp64 && powerpc_p9vector_ok } } } */
-/* { dg-options "-mdejagnu-cpu=power9 -O2 -ftree-vectorize 
-fno-vect-cost-model -fno-unroll-loops" } */
+/* { dg-options "-mdejagnu-cpu=power9 -O2 -ftree-vectorize 
-fno-vect-cost-model -fno-unroll-loops -fno-trapping-math" } */
 
 /* { dg-additional-options "--param=vect-partial-vector-usage=2" } */
 
diff --git a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-6.c 
b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-6.c
index 5d2357aabfa..65ddf2b098a 100644
--- a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-6.c
+++ b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-6.c
@@ -1,5 +1,5 @@
 /* { dg-do compile { target { lp64 && powerpc_p9vector_ok } } } */
-/* { dg-options "-mdejagnu-cpu=power9 -O2 -ftree-vectorize 
-fno-vect-cost-model -fno-unroll-loops" } */
+/* { dg-options "-mdejagnu-cpu=power9 -O2 -ftree-vectorize 
-fno-vect-cost-model -fno-unroll-loops -fno-trapping-math" } */
 
 /* { dg-additional-options "--param=vect-partial-vector-usage=2" } */
 
diff --git a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-8.c 
b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-8.c
index 1fc2af1e753..7fe0dd00431 100644
--- a/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-8.c
+++ b/gcc/testsuite/gcc.target/powerpc/p9-vec-length-full-8.c
@@ -1,5 +1,5 @@
 /* { dg-do compile { target { lp64 && powerpc_p9vector_ok } } } */
-/* { dg-options "-mdejagnu-cpu=power9 -O2 -ftree-vectorize 
-fno-vect-cost-model -fno-unroll-loops" } */
+/* { dg-options "-mdejagnu-cpu=power9 -O2 -ftree-vectorize 
-fno-vect-cost-model -fno-unroll-loops -fno-trapping-math" } */
 
 /* { dg-additional-options "--param=vect-partial-vector-usage=2" } */
 
diff --git a/gcc/testsuite/gcc.target/powerpc/pr96373.c 
b/gcc/testsuite/gcc.target/powerpc/pr96373.c
new file mode 100644
index 00000000000..f0471b6f68b
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr96373.c
@@ -0,0 +1,31 @@
+/* { dg-do run { target { powerpc*-*-linux* } } } */
+/* { dg-options "-O2 -ftree-vectorize" } */
+
+/* Verify it can run successfully, especially on Power10 and later.   */
+
+#define _GNU_SOURCE
+#include <fenv.h>
+
+__attribute__ ((noipa)) void
+div (double *d, double *s, int n)
+{
+  for (; n; n--, d++, s++)
+    *d = *d / *s;
+}
+
+int main()
+{
+  double d[] = {1,2,3,4,5,6,7,8,9,10,11};
+  double s[] = {11,10,9,8,7,6,5,4,3,2,1};
+
+  feenableexcept(FE_DIVBYZERO|FE_INVALID);
+  div(d, s, 11);
+
+  int i;
+  for (i = 0; i < 11; i++)
+    __builtin_printf(" %f", d[i]);
+
+  __builtin_printf("\n");
+
+  return 0;
+}
-- 
2.39.1

Reply via email to