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
Reduce bswap to smaller type #53867
Comments
https://alive2.llvm.org/ce/z/Qif2dE Should we limit this to just being fed from a trunc or should this be a SimplifyDemandedBits driven fold?
|
As a rule-of-thumb, relying on a trunc is always fragile, i think demandedbits may be better here. |
Optimized codegen is handled in DAG by 370ebc9 but we should be trying to simplify IR in InstCombine as well |
Narrowing bswap in IR: See also canonicalizing bswap+shift in IR: |
This is the IR counterpart to 370ebc9 which provided a bswap narrowing fix for issue #53867. Here we can be more general (although I'm not sure yet what would happen for illegal types in codegen - too rare to worry about?): https://alive2.llvm.org/ce/z/3-CPfo This will be more effective if we have moved the shift after the bswap as proposed in D122010, but it is independent of that patch. Differential Revision: https://reviews.llvm.org/D122166
We get the motivating C source tests in IR now (and codegen), so we can close this report. |
The first attempt at this missed a validity check. This version includes a test of the narrow source type for modulo-16-bits. Original commit message: This is the IR counterpart to 370ebc9 which provided a bswap narrowing fix for issue #53867. Here we can be more general (although I'm not sure yet what would happen for illegal types in codegen - too rare to worry about?): https://alive2.llvm.org/ce/z/3-CPfo This will be more effective if we have moved the shift after the bswap as proposed in D122010, but it is independent of that patch. Differential Revision: https://reviews.llvm.org/D122166
In some cases where shift is followed by bswap the bswap type may be reduced.
E.g.
should just be
https://godbolt.org/z/fq9e591EM
https://alive2.llvm.org/ce/z/rskDKL
The text was updated successfully, but these errors were encountered: