You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When the result of a umul.with.overflow by a constant is only needed when it didn't overflow and the result passes a comparison check, that comparison can be moved before the checked multiplication so that it can be replaced with a normal multiplication.
This is highly advantageous as actually emitting the overflow check needs a full x86 mul, whereas without it a lea can be used, and since it collapsed the two conditions into the one check it saves the second conditional move too:
Motivation: after rust-lang/rust#95295, we're hitting this a bunch in Rust. rust-lang/rust#99174 does it manually for some cases, but it would be much nicer for LLVM to do it everywhere.
When the result of a
umul.with.overflow
by a constant is only needed when it didn't overflow and the result passes a comparison check, that comparison can be moved before the checked multiplication so that it can be replaced with a normal multiplication.Alive2 proof for an example case: https://alive2.llvm.org/ce/z/XdagRK
This is highly advantageous as actually emitting the overflow check needs a full x86
mul
, whereas without it alea
can be used, and since it collapsed the two conditions into the one check it saves the second conditional move too:Motivation: after rust-lang/rust#95295, we're hitting this a bunch in Rust. rust-lang/rust#99174 does it manually for some cases, but it would be much nicer for LLVM to do it everywhere.
Minimized demonstration of the code pattern: https://rust.godbolt.org/z/7KWh5j5Mz
The text was updated successfully, but these errors were encountered: