https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109011
--- Comment #12 from Jakub Jelinek <jakub at gcc dot gnu.org> --- (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.