-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Use native fmin/fmax in aarch64 #47814
Merged
Merged
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
0eaf876
Use native fmin in aarch64
gbaraldi 93f8273
Small cleanup + effects
gbaraldi 9e61d9f
Cleanup
gbaraldi 5603cbf
Update base/math.jl
gbaraldi 1b2a92e
Some more cleanup
gbaraldi 9e3471a
Merge branch 'master' into fmin-aarch64
gbaraldi a8f0002
Merge branch 'JuliaLang:master' into fmin-aarch64
gbaraldi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -851,26 +851,44 @@ minmax(x::T, y::T) where {T<:AbstractFloat} = min(x, y), max(x, y) | |
|
||
_isless(x::Float16, y::Float16) = signbit(widen(x) - widen(y)) | ||
|
||
Base.@assume_effects :total @inline llvm_min(x::Float64, y::Float64) = ccall("llvm.minimum.f64", llvmcall, Float64, (Float64, Float64), x, y) | ||
Base.@assume_effects :total @inline llvm_min(x::Float32, y::Float32) = ccall("llvm.minimum.f32", llvmcall, Float32, (Float32, Float32), x, y) | ||
Base.@assume_effects :total @inline llvm_max(x::Float64, y::Float64) = ccall("llvm.maximum.f64", llvmcall, Float64, (Float64, Float64), x, y) | ||
Base.@assume_effects :total @inline llvm_max(x::Float32, y::Float32) = ccall("llvm.maximum.f32", llvmcall, Float32, (Float32, Float32), x, y) | ||
|
||
const has_native_fminmax = Sys.ARCH === :aarch64 | ||
function min(x::T, y::T) where {T<:Union{Float32,Float64}} | ||
if has_native_fminmax | ||
gbaraldi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return llvm_min(x,y) | ||
else | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indentation below is off now. Maybe just |
||
diff = x - y | ||
argmin = ifelse(signbit(diff), x, y) | ||
anynan = isnan(x)|isnan(y) | ||
ifelse(anynan, diff, argmin) | ||
return ifelse(anynan, diff, argmin) | ||
end | ||
end | ||
|
||
function max(x::T, y::T) where {T<:Union{Float32,Float64}} | ||
if has_native_fminmax | ||
return llvm_max(x,y) | ||
else | ||
diff = x - y | ||
argmax = ifelse(signbit(diff), y, x) | ||
anynan = isnan(x)|isnan(y) | ||
ifelse(anynan, diff, argmax) | ||
return ifelse(anynan, diff, argmax) | ||
end | ||
end | ||
|
||
function minmax(x::T, y::T) where {T<:Union{Float32,Float64}} | ||
if has_native_fminmax | ||
return llvm_min(x, y), llvm_max(x, y) | ||
else | ||
diff = x - y | ||
sdiff = signbit(diff) | ||
min, max = ifelse(sdiff, x, y), ifelse(sdiff, y, x) | ||
anynan = isnan(x)|isnan(y) | ||
ifelse(anynan, diff, min), ifelse(anynan, diff, max) | ||
return ifelse(anynan, diff, min), ifelse(anynan, diff, max) | ||
end | ||
end | ||
|
||
""" | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can define these functions only
if has_native_fminmax
?