[PATCH] D103617: [InstCombine] eliminate sext and/or trunc if value has enough signbits

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 3 07:35:16 PDT 2021


spatel created this revision.
spatel added reviewers: lebedev.ri, RKSimon, nikic.
Herald added subscribers: hiraditya, mcrosier.
spatel requested review of this revision.
Herald added a project: LLVM.

If we have enough signbits in a source value, we can skip an intermediate cast for a trunc+sext pair:
https://alive2.llvm.org/ce/z/A_mQt-

This is the original problem shown in:
https://llvm.org/PR49543

There's a test that shows we transformed what used to be a pair of shifts, so that suggests we could add another ComputeNumSignBits fold starting from a shift.

There does not appear to be any change in compile-time from the extra analysis:
https://llvm-compile-time-tracker.com/compare.php?from=3d2c9069dcafd0cbb641841aa3dd6e851fb7d760&to=b9513cdf2419704c7bb0c3a02a9ca06aae13d902&stat=instructions


https://reviews.llvm.org/D103617

Files:
  llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
  llvm/test/Transforms/InstCombine/sext-of-trunc-nsw.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D103617.349543.patch
Type: text/x-patch
Size: 5431 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210603/03e5cf3b/attachment.bin>


More information about the llvm-commits mailing list