-
Notifications
You must be signed in to change notification settings - Fork 11.9k
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 of is.fpclass pessimizes codegen for comparison with fast math flags #104597
Comments
Can we use |
I'm not sure it's useful to turn icmp into class. The only plus I see is it would get you some FP value tracking, maybe? But if we look through bitcasts for that, it's the same? |
It is used to improve fp-related context-sensitive analysis. And we lower |
But can't we just recognize the same FP context analysis in terms of icmp? Isn't that what #97762 is doing? Plus we are definitely missing codegen handling to swap between the two forms |
I choose to turn icmp into fpclass because Clang codegen emits fpclass for
As we have already canonicalized most of icmp patterns into fpclass, this patch is not beneficial for real-world cases.
I suggest using For the original issue, InstCombine should canonicalize |
Clang is not emitting the canonical form. Instcombine turns the isinf/isnan cases into fcmp
Disagree, these patterns appear in math library code and I don't think most of them have been handled.
If this case was a comparison to 0, we would use fcmp. Here it's sensitive to the sign of 0 and it only checks +0. I think the chain of preference should be fcmp -> icmp -> is.fpclass. This case is tricky because of -0 though |
glibc uses macros for these libcalls. And clang codegen emits is.fpclass.
llvm-project/clang/lib/CodeGen/CGBuiltin.cpp Lines 3687 to 3753 in 89c556c
|
Yes, but instcombine will immediately turn it back into fcmp ord/uno or fcmp+fabs with inf. Clang could save instcombine some work by emitting that directly (as it used to) |
Test case:
AMD64 codegen:
AMD64 codegen after InstCombine:
Here's what happens:
llvm-project/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
Line 1036 in 14d57e2
The text was updated successfully, but these errors were encountered: