On Sat, 2026-02-07 at 11:54 -0700, Jeffrey Law wrote:
> Robin's patch to fix nonzero bits for the result of a popcount triggered 
> a minor testsuite scan failure for loongarch.  Essentially it was 
> expecting to see an ANDI for a zero-extend, but after the change we get 
> a slli with a count 0, which is used for sign extension on loongarch.
> 
> Both are likely equally performant.  So this just adjusts the test to 
> accept both forms.  Now one could argue that the result of the popcount 

This case is ctz instead of popcount.  On LoongArch popcount also has a
redundant ANDI but due to a different mechanism:  LoongArch has no
scalar popcount so popcount is implemented by moving the value into a
vector register and invoking vector popcount (if vector extension is
available).  Finally when the SI is moved back from vector reg to
general reg, we hit https://gcc.gnu.org/PR119013.

This ctz case can be fixed with the SUBREG_PROMOTED_SET trick in
define_expand, I guess.

> is already sign extended and you'd be right -- that's a separate missed 
> optimization issue and unrelated to this testsuite regression.
> 
> Anyway, pushing this to the trunk.
> 
> jeff

-- 
Xi Ruoyao <[email protected]>

Reply via email to