Skip to content

Commit

Permalink
Fix @fastmath with integer additions (#110)
Browse files Browse the repository at this point in the history
  • Loading branch information
Zentrik committed Nov 7, 2023
1 parent f43725a commit ecf1f4a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/LLVM_intrinsics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ for f in BINARY_OPS_FLOAT
end

for f in BINARY_OPS_INT
@eval @generated function $f(x::T, y::T) where T<:LT{<:IntegerTypes}
@eval @generated function $f(x::T, y::T, ::F=nothing) where {T<:LT{<:IntegerTypes}, F<:FPFlags}
ff = $(QuoteNode(f))
s = """
%3 = $ff $(llvm_type(T)) %0, %1
Expand Down
3 changes: 3 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,9 @@ llvm_ir(f, args) = sprint(code_llvm, f, Base.typesof(args...))
f = v -> @fastmath v + v
# Test that v+v is rewritten as v * 2.0 (change test if optimization changes)
@test occursin(r"fmul fast <4 x double> %[0-9]*, <double 2\.000000e\+00", llvm_ir(f, (v,)))

a = Vec{8, Int32}(0)
@test all((@fastmath a + a) == a)
end

@testset "Gather and scatter function" begin
Expand Down

0 comments on commit ecf1f4a

Please sign in to comment.