summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorIgnacio Encinas <ignacio@iencinas.com>2025-03-06 20:49:27 +0100
committerAlexandre Ghiti <alexghiti@rivosinc.com>2025-04-01 07:03:04 +0000
commit79ba5c1c7767a539f42c6f6db46961b0bec2bc03 (patch)
tree978ff76dc90bdd902900740bffa8edc421d5bd05 /tools
parent83d78ac677b9fdd8ea763507c6fe02d6bf415f3a (diff)
downloadlinux-79ba5c1c7767a539f42c6f6db46961b0bec2bc03.tar.gz
linux-79ba5c1c7767a539f42c6f6db46961b0bec2bc03.tar.bz2
linux-79ba5c1c7767a539f42c6f6db46961b0bec2bc03.zip
selftests: riscv: fix v_exec_initval_nolibc.c
Vector registers are zero initialized by the kernel. Stop accepting "all ones" as a clean value. Note that this was not working as expected given that value == 0xff can be assumed to be always false by the compiler as value's range is [-128, 127]. Both GCC (-Wtype-limits) and clang (-Wtautological-constant-out-of-range-compare) warn about this. Reviewed-by: Charlie Jenkins <charlie@rivosinc.com> Tested-by: Charlie Jenkins <charlie@rivosinc.com> Signed-off-by: Ignacio Encinas <ignacio@iencinas.com> Link: https://lore.kernel.org/r/20250306-fix-v_exec_initval_nolibc-v2-1-97f9dc8a7faf@iencinas.com Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/testing/selftests/riscv/vector/v_exec_initval_nolibc.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/tools/testing/selftests/riscv/vector/v_exec_initval_nolibc.c b/tools/testing/selftests/riscv/vector/v_exec_initval_nolibc.c
index 35c0812e32de..4dde05e45a04 100644
--- a/tools/testing/selftests/riscv/vector/v_exec_initval_nolibc.c
+++ b/tools/testing/selftests/riscv/vector/v_exec_initval_nolibc.c
@@ -6,7 +6,7 @@
* the values. To further ensure consistency, this file is compiled without
* libc and without auto-vectorization.
*
- * To be "clean" all values must be either all ones or all zeroes.
+ * To be "clean" all values must be all zeroes.
*/
#define __stringify_1(x...) #x
@@ -14,9 +14,8 @@
int main(int argc, char **argv)
{
- char prev_value = 0, value;
+ char value = 0;
unsigned long vl;
- int first = 1;
if (argc > 2 && strcmp(argv[2], "x"))
asm volatile (
@@ -44,14 +43,11 @@ int main(int argc, char **argv)
"vsrl.vi " __stringify(register) ", " __stringify(register) ", 8\n\t" \
".option pop\n\t" \
: "=r" (value)); \
- if (first) { \
- first = 0; \
- } else if (value != prev_value || !(value == 0x00 || value == 0xff)) { \
+ if (value != 0x00) { \
printf("Register " __stringify(register) \
" values not clean! value: %u\n", value); \
exit(-1); \
} \
- prev_value = value; \
} \
})