We can do this if Y*C doesn't overflow. This is trivial if C is
0/1. Otherwise we actually generate a mul instruction iff the div
has one use.
Alive2 Links:
udiv: https://alive2.llvm.org/ce/z/GWPW67 sdiv: https://alive2.llvm.org/ce/z/bUoX9h
Paths
| Differential D150091
[InstCombine] Transform `icmp eq/ne ({su}div exact X,Y),C` -> `icmp eq/ne X, Y*C` ClosedPublic Authored by goldstein.w.n on May 7 2023, 11:53 PM.
Details Summary We can do this if Y*C doesn't overflow. This is trivial if C is Alive2 Links: udiv: https://alive2.llvm.org/ce/z/GWPW67 sdiv: https://alive2.llvm.org/ce/z/bUoX9h
Diff Detail
Event TimelineThis revision is now accepted and ready to land.Jun 28 2023, 12:37 AM Comment Actions I'd also suggest to update the proofs to match what you are actually implementing. The current ones are rather roundabout. This revision was landed with ongoing or failed builds.Jul 13 2023, 5:37 PM Closed by commit rGddd18d02c71b: [InstCombine] Transform `icmp eq/ne ({su}div exact X,Y),C` -> `icmp eq/ne X… (authored by goldstein.w.n). · Explain Why This revision was automatically updated to reflect the committed changes.
Revision Contents
Diff 540239 llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
llvm/test/Transforms/InstCombine/sdiv-icmp.ll
|
Drop this part of the comment, it does not reflect the implementation.