[PATCH] D29088: Do not create ctlz/cttz(X, false) when the target do not support zero defined ctlz/cttz.

Amaury SECHET via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 27 03:56:27 PST 2017


deadalnix added a comment.

In https://reviews.llvm.org/D29088#657697, @andreadb wrote:

> I agree that we are currently missing an optimization.
>  That said, (if I remember correctly) the only place where we form cttz/ctlz with `is_zero_undef=false` is in `foldSelectCttzCtlz()` and the only goal of that transform is to canonicalize cttz/ctlz in preparation for codegen. That's why I suggested considering the possibility of moving that transform into CGP. If we do this, then we no longer need to add extra optimization rules to "fix" the fact that we prematurely canonicalized.


We also are doing it in InstCombine ( see foldCttzCtlz ) using isKnownNonZero, but that guy is unable to figure that one out. Looking at the implementation, it looks pretty ad hoc.


https://reviews.llvm.org/D29088





More information about the llvm-commits mailing list