[PATCH] D32605: Recognize CTLZ builtin

Evgeny Stupachenko via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 9 19:12:46 PDT 2017


evstupac added a comment.

In https://reviews.llvm.org/D32605#750321, @joerg wrote:

> In https://reviews.llvm.org/D32605#750309, @evstupac wrote:
>
> > If loop is just converted to countable other optimizations are applicable like unroll, LSR, vectorization... with potential great impact.
>
>
> That is something SCEV should be able to discover on its own.


Could you briefly describe how? The only way to get BECount is to calculate CTLZ. What SCEV should discover?
The only optimization that could avoid CTLZ calculation is full unroll

> Replacing the full loop with the intrinsic is ok. The current default lowering is broken, but improving that is orthogonal. I.e. from a code size perspective, trading the loop for a libcall is still an improvement when using an optimized library version.

Loop idiom recognition is not the best place to check if we'll be able to delete a loop or not. If we decided to insert TTI guard I'll do this in the beginning.
If you know that default lowering is broken please file a bug report. Someone could use __builtin_ctlz and get a wrong code.


Repository:
  rL LLVM

https://reviews.llvm.org/D32605





More information about the llvm-commits mailing list