[PATCH] D103788: [InstCombine] Eliminate casts to optimize ctlz operation

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 10 04:40:49 PDT 2021


lebedev.ri added a comment.

In D103788#2810074 <https://reviews.llvm.org/D103788#2810074>, @datta.nagraj wrote:

> @lebedev.ri Sir, but if we don't take trunc into consideration, then how are we optimizing this?
> Earlier it was 2 insts (zext - ctlz), and now its 3 insts(ctlz - add - zext). I agree that the ctlz , add are done on a lower datatype.
> If we consider trunc as well, then we can convert 3 insts (zext - ctlz - trunc) to 2 insts (ctlz - add).
> Shouldn't we do this opt only when the trunc is present?

In general - yes, in instcombine we should not increase the instruction count,
however as it was already hinted by @spatel, this seems like a rare edge case
where we should be okay with that. (unless @spatel disagrees?)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D103788/new/

https://reviews.llvm.org/D103788



More information about the llvm-commits mailing list