diff mbox series

testsuite: Fix vect-mod-var.c for division by 0 [PR116461]

Message ID 20240823041921.669233-1-quic_apinski@quicinc.com
State New
Headers show
Series testsuite: Fix vect-mod-var.c for division by 0 [PR116461] | expand

Commit Message

Andrew Pinski Aug. 23, 2024, 4:19 a.m. UTC
The testcase cc.dg/vect/vect-mod-var.c has an division by 0
which is undefined. On some targets (aarch64), the scalar and
the vectorized version, the result of division by 0 is the same.
While on other targets (x86), we get a SIGFAULT. On other targets (powerpc),
the results are different.

The fix is to make sure the testcase does not test division by 0 (or really mod by 0).

Pushed as obvious after testing on x86_64-linux-gnu to make sure the testcase passes
now.

	PR testsuite/116461

gcc/testsuite/ChangeLog:

	* gcc.dg/vect/vect-mod-var.c: Change the initialization loop so that
	`b[i]` is never 0. Use 1 in those places.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
---
 gcc/testsuite/gcc.dg/vect/vect-mod-var.c | 3 +++
 1 file changed, 3 insertions(+)
diff mbox series

Patch

diff --git a/gcc/testsuite/gcc.dg/vect/vect-mod-var.c b/gcc/testsuite/gcc.dg/vect/vect-mod-var.c
index eeed318c62b..c552941faef 100644
--- a/gcc/testsuite/gcc.dg/vect/vect-mod-var.c
+++ b/gcc/testsuite/gcc.dg/vect/vect-mod-var.c
@@ -23,6 +23,9 @@  main (void)
     {
       a[i] = BASE1 + i * 5;
       b[i] = BASE2 - i * 4;
+      /* b[i] cannot be 0 as that would cause undefined
+	 behavior with respect to `% b[i]`. */
+      b[i] = b[i] ? b[i] : 1;
       __asm__ volatile ("");
     }