-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Regression: Missed fold for x * 0 #50630
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
assigned to @nerh |
Aforementioned code snipped is no longer folded into single multiplication instruction after changes in "simplifyWithOpReplaced". If there are no objections I'd like to take this issue fix the optimization. |
SGTM Current IR: define i32 @mul(i32 %0, i32 %1) {
%3 = icmp eq i32 %0, 0
%4 = mul i32 %1, %0
%5 = select i1 %3, i32 0, i32 %4
ret i32 %5
} To get rid of that select we will need freeze: https://alive2.llvm.org/ce/z/maX0k- |
Candidate patch: https://reviews.llvm.org/D108408 |
We have the expected codegen again (just a multiply, no cmov) after: |
Extended Description
Clang trunk is not generating optimal code for a (very poor) multiplication routine https://godbolt.org/z/GrjMhsTcv.
Should compile to:
And it does in clang 12 but not in clang trunk.
If I'm not mistaken it appears a select i1 (icmp eq i32 %x, 0), i32 0, i32 (mul i32 %x, %y) -> mul i32 %x, %y fold is not firing.
The text was updated successfully, but these errors were encountered: