https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109011

--- Comment #13 from Hongtao.liu <crazylht at gmail dot com> ---
(In reply to Jakub Jelinek from comment #12)
> (In reply to Hongtao.liu from comment #11)
> > (In reply to Jakub Jelinek from comment #3)
> > > Seems they are vectorizing __builtin_ctz (x) as bitsize - .CLZ ((x - 1) &
> > > ~x) for CLZ_DEFINED_VALUE_AT_ZERO 2 with value bitsize.
> > > Perhaps we should pattern match it in tree-vect-patterns.cc that way if 
> > > clz
> > > is vectorizable (it is with -mavx512cd) and ctz is not.
> > 
> > Yes, I'm going to add a pattern match named vect_recog_ctz_as_clz_or_popcnt.
> > 
> > BTW, It looks like only x86 have vector clz but not ctz, for other targets,
> > they either have both or neither.
> 
> I have already the patch half written.  Yes, for clz, but various other
> targets don't have ffs and do have clz etc.

It looks like ffs is *just* ctz with defined behavior for zero, so we can
handle it exactly the same as ctz in the same pattern match((bitsize - .CLZ ((x
- 1) & ~x)) or .POPCOUNT ((x - 1) & ~x)) when CLZ_DEFINED_VALUE_AT_ZERO 2.

Reply via email to