https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118342
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |uros at gcc dot gnu.org --- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Yes, so we can use it for a == 0 ? prec : __builtin_ctzll (a); but not say (with small middle-end enhancements) for a == 0 ? -1 : __builtin_ctzll (a); because on some CPUs that would yield -1LL and on others 0xffffffffULL. Anyway, implementation-wise, this could be done either with no middle-end changes and then CTZ_DEFINED_VALUE_AT_ZERO always yielding 2 and prec and a dumb ctz<mode>2 define_expand which for !TARGET_BMI would emit the prec setter and then an if_then_else pattern with bsf which uses match_dup and use just bsf instead of rep; bsf there, or doing something smarter, e.g. let the expander use 2 optabs, either ctz<mode>2 or ctzubat0<mode>2, the latter if it is the builtin or ifn with 1 argument and the optab is defined, and perhaps add another value of CTZ_DEFINED_VALUE_AT_ZERO, say 3, which would mean use this value in GIMPLE but not RTL.