-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Closed
Closed
Copy link
Labels
compiler:codegenGeneration of LLVM IR and native codeGeneration of LLVM IR and native codeperformanceMust go fasterMust go faster
Description
There might be a better MWE for this, I'm not sure why it happens (codegen perf bug, I'm guessing?):
julia> using BenchmarkTools
julia> struct FooA{X}
x::X
end
julia> F, f = FooA{Int}, FooA{Int}(1)
(FooA{Int64}, FooA{Int64}(1))
julia> @btime convert($F, $f)
0.035 ns (0 allocations: 0 bytes)
FooA{Int64}(1)
julia> @code_lowered convert(F, f)
CodeInfo(
123 1 ─ return %%x │
)
julia> @code_llvm convert(F, f)
; Function convert
; Location: essentials.jl:123
define { i64 } @julia_convert_32884(%jl_value_t addrspace(10)*, { i64 } addrspace(11)* nocapture nonnull readonly dereferenceable(8)) {
top:
%2 = getelementptr inbounds { i64 }, { i64 } addrspace(11)* %1, i64 0, i32 0
%.unpack = load i64, i64 addrspace(11)* %2, align 8
%3 = insertvalue { i64 } undef, i64 %.unpack, 0
ret { i64 } %3
}
julia> struct FooB{X}
x::Union{X,Nothing}
end
julia> F, f = FooB{Int}, FooB{Int}(1)
(FooB{Int64}, FooB{Int64}(1))
julia> @btime convert($F, $f)
56.547 ns (2 allocations: 64 bytes)
FooB{Int64}(1)
julia> @code_lowered convert(F, f)
CodeInfo(
123 1 ─ return %%x │
)
julia> @code_llvm convert(F, f)
; Function convert
; Location: essentials.jl:123
define void @julia_convert_33024({ i64, i8 }* noalias nocapture sret, %jl_value_t addrspace(10)*, { i64, i8 } addrspace(11)* nocapture nonnull readonly dereferenceable(16)) {
top:
%3 = bitcast { i64, i8 }* %0 to i8*
%4 = bitcast { i64, i8 } addrspace(11)* %2 to i8 addrspace(11)*
call void @llvm.memcpy.p0i8.p11i8.i64(i8* %3, i8 addrspace(11)* %4, i64 16, i32 8, i1 false)
ret void
}Metadata
Metadata
Assignees
Labels
compiler:codegenGeneration of LLVM IR and native codeGeneration of LLVM IR and native codeperformanceMust go fasterMust go faster