-
Notifications
You must be signed in to change notification settings - Fork 10.8k
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
[InstCombine] Missed optimization: Fold usub_sat((sub nuw C1, A), C2)
to usub_sat(C1 - C2, A)
or 0
#82177
Comments
usub_sat((sub nuw C1, A), C2)
to usub_sat(C1 - C2, A)
or 0
usub_sat((sub nuw C1, A), C2)
to usub_sat(C1 - C2, A)
or 0
I will work on this. |
If I need to confirm the transformation for vectors. |
It seems we must keep the equality between two expression, in your example, it is C1 - A u< C2 with C1 - C2 u< A。And can you give the example such as how can I get this IR from C or C++ Code. |
Since this pattern doesn't involve vector operation, the correctness for scalars implies the correctness for vectors. However, If you do want to verify this pattern in Alive2, you can transform |
@cyk2018, tools like https://github.com/travitch/whole-program-llvm and https://github.com/SRI-CSL/gllvm can extract IRs when compiling the whole project. For a single C/C++ file, just |
Thanks for your links. I am confused in how to generate nuw flag. I have found this method that SCCPSolver can generate this after analysis. The question is not very relevant with this issue. Still sincerely thanks. |
… A) or 0 (#82280) - Fixes: #82177 - Alive2: https://alive2.llvm.org/ce/z/Q7mMC3
Alive2 proof: https://alive2.llvm.org/ce/z/Bre2we
Motivating example
can be folded to:
When
C2 u< C1
, we getusub_sat(C1 - C2, A)
, otherwise we get0
. See also the examples in alive2 proof.Real-world motivation
This snippet of IR is derived from jemalloc/src/psset.c@psset_maybe_remove_purge_list (after O3 pipeline).
The example above is a reduced version. If you're interested in the original suboptimal IR and optimal IR, contact me to get it, please. Actually such pattern is found frequently in the IRs in jemalloc project.
Let me know if you can confirm that it's an optimization opportunity, thanks.
The text was updated successfully, but these errors were encountered: