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

--- Comment #16 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to Wilco from comment #15)
> It would make more sense to move x86 backends to CTZ_DEFINED_VALUE_AT_ZERO
> == 2 so that you always get the same result even when you don't have tzcnt.
> A conditional move would be possible, so it adds an extra 2 instructions at
> worst (ie. still significantly faster than doing the table lookup, multiply
> etc). And it could be optimized when you know CLZ/CTZ input is non-zero.

Conditional moves are a lottery on x86, in many cases very bad idea.  And when
people actually use __builtin_clz*, they state that they don't care about the 0
value, so emitting terribly performing code for it just in case would be wrong.
If forwprop emits the conditional in separate blocks for the CTZ_DVAZ!=2 case,
on targets where conditional moves are beneficial for it it can also emit them,
or emit the jump which say on x86 will be most likely faster than cmov.

Reply via email to