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

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 26 06:54:01 PST 2017


spatel added a comment.

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

> Basically, I can see how triggering that instcombine too prematurely might lead to poor codegen for your non-lzcnt target.
>
> Ideally, we would want that canonicalization to be performed directly before (or during) codegen to help instruction selection on targets that have a fast ctz/clz defined on zero.
>
> What if instead we move that transform into `CodeGenPrepare::optimizeSelectInst()`? I think that would fix the issue in a cleaner way, since we would not need to introduce new target hooks to conditionalize its execution.


Thanks for posting the example. That made it clear, and the proposal to move the functionality of foldSelectCttzCtlz() later sounds good to me.


https://reviews.llvm.org/D29088





More information about the llvm-commits mailing list