[PATCH] D142786: [InstCombine] Improve transforms for (icmp uPred X * Z, Y * Z) -> (icmp uPred X, Y)
Noah Goldstein via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 27 15:25:23 PST 2023
goldstein.w.n created this revision.
Herald added a subscriber: hiraditya.
Herald added a project: All.
goldstein.w.n requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Several cases where missing.
1. `(icmp eq/ne X*Z, Y*Z) [if Z % 2 != 0] -> (icmp eq/ne X, Y)` EQ: https://alive2.llvm.org/ce/z/6_HPZ5 NE: https://alive2.llvm.org/ce/z/c34qSU
There was previously an implementation of this that work of `Y` was non-constant, but it was missing if `Y*Z` evaluated to a constant and/or `nsw`/`nuw` where both false. As well it only worked if `Z` was a constant but we can check 1s bit of `KnownBits` to cover more cases.
2. `(icmp eq/ne X*Z, Y*Z) [if Z != 0 and nsw(X*Y) and nsw(Y*Z)] -> (icmp eq/ne X, Y)` EQ: https://alive2.llvm.org/ce/z/6SdAG6 NE: https://alive2.llvm.org/ce/z/fjsq_b
This was previously implemented only to work if `Z` was constant, but we can use `isKnownNonZero` to cover more cases.
3. `(icmp uPred X*Y, Y*Z) [if Z != 0 and nuw(X*Y) and nuw(X*Y)] -> (icmp uPred X, Y)` EQ: https://alive2.llvm.org/ce/z/FqWQLX NE: https://alive2.llvm.org/ce/z/2gHrd2 ULT: https://alive2.llvm.org/ce/z/MUAWgZ ULE: https://alive2.llvm.org/ce/z/szQQ2L UGT: https://alive2.llvm.org/ce/z/McVUdu UGE: https://alive2.llvm.org/ce/z/95uyC8
This was previously implemented only for `eq/ne` cases. As well only if `Z` was constant, but again we can use `isKnownNonZero` to cover more cases.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D142786
Files:
llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
llvm/test/Transforms/InstCombine/icmp-mul.ll
llvm/test/Transforms/InstCombine/pr38677.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D142786.492925.patch
Type: text/x-patch
Size: 9246 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230127/90e7357b/attachment.bin>
More information about the llvm-commits
mailing list