[PATCH] D119369: [InstCombine] reduce mul operands based on undemanded high bits

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 9 12:50:30 PST 2022


spatel created this revision.
spatel added reviewers: lebedev.ri, fwolff, RKSimon, xbolva00, craig.topper.
Herald added subscribers: hiraditya, mcrosier.
spatel requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

We already do this in SDAG, but mul was left out of the fold for unused high bits in IR.
The high bits of a mul's operands do not change the low bits of the result:
https://alive2.llvm.org/ce/z/XRj5Ek

Verify some test diffs to confirm that they are correct:
https://alive2.llvm.org/ce/z/y_W8DW
https://alive2.llvm.org/ce/z/7DM5uf
https://alive2.llvm.org/ce/z/GDiHCK

This gets a fold that was presumed not possible in D114272 <https://reviews.llvm.org/D114272>:
https://alive2.llvm.org/ce/z/tAN-WY

Removing nsw/nuw is needed for general correctness (and is also done in the codegen version), but we might be able to recover more of those with better analysis.


https://reviews.llvm.org/D119369

Files:
  llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
  llvm/test/Transforms/InstCombine/and-or.ll
  llvm/test/Transforms/InstCombine/icmp-mul-and.ll
  llvm/test/Transforms/InstCombine/mul-inseltpoison.ll
  llvm/test/Transforms/InstCombine/mul.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D119369.407244.patch
Type: text/x-patch
Size: 9645 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220209/a3f1d44b/attachment.bin>


More information about the llvm-commits mailing list