[PATCH] D110170: [InstCombine] fold cast of right-shift if high bits are not demanded

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 5 16:17:22 PDT 2021


spatel added a comment.

In D110170#3044059 <https://reviews.llvm.org/D110170#3044059>, @bjope wrote:

> Although. the original IR looked a bit more like in this example https://godbolt.org/z/s8Krzrq36 , which show that the number of instructions in the loop increase from 16 to 19, for x86, when using opt from trunc instead of the 13.0.0 version. And afaict this patch is the main difference.

Ah - the larger example is very interesting if I'm seeing it correctly. We're xor'ing 4 bits from some value?

That could be made significantly shorter in IR or codegen:
https://alive2.llvm.org/ce/z/bWgS_h
https://godbolt.org/z/sP6n13xd3
(Note that the x86 codegen is likely better for a target **without** popcount! I'll file some bugs tomorrow.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110170



More information about the llvm-commits mailing list