[PATCH] D32605: Recognize CTLZ builtin

Evgeny Stupachenko via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 9 15:23:07 PDT 2017


evstupac added a comment.

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

>   if the CPU has no direct lowering for the intrinsic, this transform is beneficial only if the resulting intrinsic can be constant folded


Why?
What about converting loop to countable?
What about InstCombine optimizations (not sure how useful they are, but still)?

  // fold (srl (ctlz x), "5") -> x  iff x has one bit set (the low bit).
  // select_cc seteq X, 0, sizeof(X), ctlz(X) -> ctlz(X) 
  // select_cc seteq X, 0, sizeof(X), ctlz_zero_undef(X) -> ctlz(X)
  // select_cc seteq X, 0, sizeof(X), cttz(X) -> cttz(X)
  // select_cc seteq X, 0, sizeof(X), cttz_zero_undef(X) -> cttz(X)

.....
What about clear range of CTLZ(X):  0 <= CTLZ(X) <= bitwidth(X)?


Repository:
  rL LLVM

https://reviews.llvm.org/D32605





More information about the llvm-commits mailing list