[PATCH] D126410: [InstCombine] fold icmp equality with udiv and large constant
Sanjay Patel via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed May 25 12:44:01 PDT 2022
spatel created this revision.
spatel added reviewers: nikic, Kmeakin, lebedev.ri.
Herald added subscribers: hiraditya, mcrosier.
Herald added a project: All.
spatel requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
With large compare constant:
(X u/ Y) == C --> (X == C) && (Y == 1)
(X u/ Y) != C --> (X != C) || (Y != 1)
https://alive2.llvm.org/ce/z/EhKwh6
There are various potential missing icmp (div) transforms shown here:
https://github.com/llvm/llvm-project/issues/55695
This is a generalization for part of the udiv + equality. I didn't check in detail, but some of those may only make sense as codegen transforms.
This results in one extra instruction in IR, but it is better for analysis, and looks much better in codegen on all targets that I tried.
https://reviews.llvm.org/D126410
Files:
llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
llvm/test/Transforms/InstCombine/icmp-div-constant.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D126410.432080.patch
Type: text/x-patch
Size: 5091 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220525/c96e23ee/attachment.bin>
More information about the llvm-commits
mailing list