[gcc(refs/users/aoliva/heads/testme)] testsuite: vect: slp-mask-store-1 accesses past the end of flags
Alexandre Oliva
aoliva@gcc.gnu.org
Wed Mar 18 10:45:35 GMT 2026
https://gcc.gnu.org/g:572ce0d32c6860386dd5600097f6ae7dc97b7065
commit 572ce0d32c6860386dd5600097f6ae7dc97b7065
Author: Alexandre Oliva <oliva@adacore.com>
Date: Wed Mar 18 07:16:42 2026 -0300
testsuite: vect: slp-mask-store-1 accesses past the end of flags
The loop invokes undefined behavior: the flags array runs 0..31, but
so does the iterator i, thus the accesses to pairs therein run 0..63.
If we're lucky we find all zeros and don't mess with anything else,
but if we find any nonzero out-of-range flags, we'll end up scribbling
out of range onto x, that runs 0..15.
Surely the iterator wasn't meant to go up to 32. If it goes up to 16,
as proposed herein, we only access flags in range, and since its
second half is all zeros, we only access x in range as well.
for gcc/testsuite/ChangeLog
* gcc.dg/vect/slp-mask-store-1.c (foo): Fix iteration range.
Diff:
---
gcc/testsuite/gcc.dg/vect/slp-mask-store-1.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gcc/testsuite/gcc.dg/vect/slp-mask-store-1.c b/gcc/testsuite/gcc.dg/vect/slp-mask-store-1.c
index 2f80bf89e5e6..9cfb45e63e97 100644
--- a/gcc/testsuite/gcc.dg/vect/slp-mask-store-1.c
+++ b/gcc/testsuite/gcc.dg/vect/slp-mask-store-1.c
@@ -5,7 +5,7 @@
void __attribute__((noipa))
foo (unsigned * __restrict x, int * __restrict flag)
{
- for (int i = 0; i < 32; ++i)
+ for (int i = 0; i < 16; ++i)
{
if (flag[2*i+0])
x[2*i+0] = x[2*i+0] + 3;
More information about the Gcc-cvs
mailing list