-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Cannot select fmaximum
/fminimum
#64022
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
@llvm/issue-subscribers-backend-risc-v |
@llvm/issue-subscribers-bug |
It looks like the RISC-V backend supports I want to make changes to add support for P.S. Isn't there supposed to be some kind of fallback code generation for intrinsics that are not supported by a backend? |
@unterumarmung using an assertions build triggers an llvm_unreachable. https://godbolt.org/z/5nY98v53Y I'm going to commit a patch to turn that llvm_unreachable into a fatal error. |
Unlike fmaxnum and fminnum, these operations propagate nan and consider -0.0 to be less than +0.0. Without Zfa, we don't have a single instruction for this. The lowering I've used forces the other input to nan if one input is a nan. If both inputs are nan, they get swapped. Then use the fmax or fmin instruction. New ISD nodes are needed because fmaxnum/fminnum to not define the order of -0.0 and +0.0. This lowering ensures the snans are quieted though that is probably not required in default environment). Also ensures non-canonical nans are canonicalized, though I'm also not sure that's needed. Another option could be to use fmax/fmin and then overwrite the result based on the inputs being nan, but I'm not sure we can do that with any less code. Future work will handle nonans FMF, and handling the case where we can prove the input isn't nan. This does fix the crash in #64022, but we need to do more work to avoid scalarization. Reviewed By: fakepaper56 Differential Revision: https://reviews.llvm.org/D156069
I'm actually getting and error for
If |
I fixed llvm.fmaximum for scalar f32 when the F extension is enabled earlier today. |
Thanks a lot, Craig! What is the state or planning for the reduction ones? |
Need to figure out a good lowering for reductions. We don't have a hardware reduction instruction that does this. So we need to do something like vredmax, and vfclass to find all the nans, and vcpop to count if there are any nans. If there are any nans replace the vredmax result with nan. This is not going to be efficient. |
That should be fine. We would like to remove some hacks and fix some issues related to this in MLIR and for that we need at least the basic functionality to be implemented on x86, ARM and RISC-V. It looks like RISC-V is the only one missing. |
After my scalar fix, the reductions no longer crash. They just generate terrible code https://godbolt.org/z/YfzYv4o8G |
Awesome! Let me integrate and run more extensive benchmarks. |
Any plans to add support for
fmaximum
/fminimum
and their respective reductions to the RISC-V backend? We would like to target them from MLIR since the main fmax/fmin semantics in MLIR matches these instructions. This is currently blocking: https://reviews.llvm.org/D155877The text was updated successfully, but these errors were encountered: