RISC-V: NO_WARNING preferred else value for RVV

PR target/115840.

In riscv_preferred_else_value, we create an uninitialized tmp var
for else value, instead of the 0 (as default_preferred_else_value)
or the pre-exists VAR (as aarch64 does), so that we can use agnostic
policy.

The problem is that `warn_uninit` will emit a warning:
  '({anonymous})' may be used uninitialized

Let's mark this tmp var as NO_WARNING.

This problem is found when I try to build glibc with V extension.

gcc

	PR target/115840
	* config/riscv/riscv.cc(riscv_preferred_else_value): Mark
	tmp_var as NO_WARNING.

gcc/testsuite
	* gcc.dg/vect/pr115840.c: New testcase.
This commit is contained in:
YunQiang Su 2024-07-11 20:43:54 +08:00 committed by YunQiang Su
parent a55d24b3cf
commit c6f38e5e6d
2 changed files with 16 additions and 1 deletions

View file

@ -11432,7 +11432,11 @@ riscv_preferred_else_value (unsigned ifn, tree vectype, unsigned int nops,
tree *ops)
{
if (riscv_v_ext_mode_p (TYPE_MODE (vectype)))
return get_or_create_ssa_default_def (cfun, create_tmp_var (vectype));
{
tree tmp_var = create_tmp_var (vectype);
TREE_NO_WARNING (tmp_var) = 1;
return get_or_create_ssa_default_def (cfun, tmp_var);
}
return default_preferred_else_value (ifn, vectype, nops, ops);
}

View file

@ -0,0 +1,11 @@
/* { dg-do compile } */
/* { dg-additional-options "-Wall -Werror" } */
double loads[16];
void
foo (double loadavg[], int count)
{
for (int i = 0; i < count; i++)
loadavg[i] = loads[i] / 1.5;
}