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
It's SROA who inserts the truncs and shifts, and later when we discover the condition is always true we cannot get rid of them.
Please note that the important fact is not the order of passes: I deliberately made it so SROA will have a chance before we notice the condition is true. In the real case, the condition does not always hold, but SROA still pessimizes the output.
In my real case SROA doesn't really matter since the value is anyway going to be written into the return pointer (like here), but even if SROA cannot see that it seems it should not pessimize the code.
Given the following LLVM IR (minimized from real Rust code):
LLVM transforms it into:
Instead of the clearly more efficient:
It's SROA who inserts the truncs and shifts, and later when we discover the condition is always true we cannot get rid of them.
Please note that the important fact is not the order of passes: I deliberately made it so SROA will have a chance before we notice the condition is true. In the real case, the condition does not always hold, but SROA still pessimizes the output.
In my real case SROA doesn't really matter since the value is anyway going to be written into the return pointer (like here), but even if SROA cannot see that it seems it should not pessimize the code.
Godbolt: https://godbolt.org/z/rr15o7Keb
The text was updated successfully, but these errors were encountered: