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

Datta Nagraj via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Jun 6 23:53:15 PDT 2021


datta.nagraj created this revision.
datta.nagraj added reviewers: simon, david.
Herald added a subscriber: hiraditya.
datta.nagraj requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

If a ctlz operation is performed on higher datatype and then
downcasted, then this can be optimized by doing a ctlz operation
on a lower datatype and adding the difference bitsize to the result
of ctlz to provide the same output:

https://alive2.llvm.org/ce/z/8uup9M

The original problem is shown in
https://llvm.org/PR50173


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D103788

Files:
  llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
  llvm/test/Transforms/InstCombine/zext-ctlz-trunc-to-ctlz-add.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D103788.350181.patch
Type: text/x-patch
Size: 3698 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210607/da2a520c/attachment.bin>


More information about the llvm-commits mailing list