On Tue, 18 Nov 2025, Robin Dapp wrote:

> > Hi, yeah that's right.  That's a good indication I need to add that to the 
> > docs.
> > Now however I only try a vector of all zeros in expand atm, mainly because 
> > I don't
> > know where to get the other possible else values for non-Len based targets.
> > There's a target hook preferred_else_value which different targets seem to
> > have interpreted slightly different I think.. AArch64 seems to have 
> > interpreted
> > it as "given a conditional operation which value is the else value" whereas
> > RISC-V seems to have done the same, but defaults to zero if the operation is
> > unconditional.
> >
> > And the default implementation is default_preferred_else_value returns 0.
> 
> Just to add a little: I think the implementations of preferred_else_value 
> (not 
> mask_load_else) are aligned.  aarch64 and x86 use "zeros" because that's what 
> the hardware does and riscv uses "undefined" for vector types, again because 
> that's what the hardware/SPEC allows.
> Using zero causes slightly less efficient riscv code because we then need to 
> explicitly zero out the inactive elements.  As long as we're not relying on 
> those in any way (like we do in the mask load case), preferred_else_value 
> should work I'd say. 

Usually the 'else' value applies to masked operations.  For a
cond_vec_cbranch_any that would mean if any mask element is zero
then an else value of 1 makes the branch taken.  For cond_vec_cbranch_all
an else value of 0 makes the branch not taken.  So we cannot really
use what the target prefers here but instead in practice we are always
looking for a "neutral" element here which means having the else
value represented is pointless at this point?  Otherwise we have to
check target predicates whether the actual else value we require
is supported.

That said, to what part of cond_vec_cbranch_any do you think the 'else'
value applies?

Richard.

-- 
Richard Biener <[email protected]>
SUSE Software Solutions Germany GmbH,
Frankenstrasse 146, 90461 Nuernberg, Germany;
GF: Jochen Jaser, Andrew McDonald, Werner Knoblich; (HRB 36809, AG Nuernberg)

Reply via email to