Skip to content
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

Remove some spurious where T from SA constructors #665

Merged
merged 1 commit into from
Sep 27, 2019
Merged

Conversation

c42f
Copy link
Member

@c42f c42f commented Sep 27, 2019

Surprisingly enough these result in methods which can be called but which don't inline, leading to performance problems.

julia> g(x) = SA[1 2; 3 x]

Before:

julia> @code_llvm g(1)

;  @ REPL[2]:1 within `g'
define void @julia_g_16110({ [4 x i64] }* noalias nocapture sret, i64) {
top:
  %2 = alloca %jl_value_t addrspace(10)*, i32 7
  %gcframe = alloca %jl_value_t addrspace(10)*, i32 3
  %3 = bitcast %jl_value_t addrspace(10)** %gcframe to i8*
  call void @llvm.memset.p0i8.i32(i8* %3, i8 0, i32 24, i32 0, i1 false)
  %thread_ptr = call i8* asm "movq %fs:0, $0", "=r"()
  %ptls_i8 = getelementptr i8, i8* %thread_ptr, i64 -15560
  %ptls = bitcast i8* %ptls_i8 to %jl_value_t***
  %4 = getelementptr %jl_value_t addrspace(10)*, %jl_value_t addrspace(10)** %gcframe, i32 0
  %5 = bitcast %jl_value_t addrspace(10)** %4 to i64*
  store i64 2, i64* %5
  %6 = getelementptr %jl_value_t**, %jl_value_t*** %ptls, i32 0
  %7 = getelementptr %jl_value_t addrspace(10)*, %jl_value_t addrspace(10)** %gcframe, i32 1
  %8 = bitcast %jl_value_t addrspace(10)** %7 to %jl_value_t***
  %9 = load %jl_value_t**, %jl_value_t*** %6
  store %jl_value_t** %9, %jl_value_t*** %8
  %10 = bitcast %jl_value_t*** %6 to %jl_value_t addrspace(10)***
  store %jl_value_t addrspace(10)** %gcframe, %jl_value_t addrspace(10)*** %10
  %11 = call %jl_value_t addrspace(10)* @jl_box_int64(i64 signext %1)
  %12 = getelementptr %jl_value_t addrspace(10)*, %jl_value_t addrspace(10)** %gcframe, i32 2
  store %jl_value_t addrspace(10)* %11, %jl_value_t addrspace(10)** %12
  %13 = getelementptr %jl_value_t addrspace(10)*, %jl_value_t addrspace(10)** %2, i32 0
  store %jl_value_t addrspace(10)* addrspacecast (%jl_value_t* inttoptr (i64 140508241764800 to %jl_value_t*) to %jl_value_t addrspace(10)*), %jl_value_t addrspace(10)** %13
  %14 = getelementptr %jl_value_t addrspace(10)*, %jl_value_t addrspace(10)** %2, i32 1
  store %jl_value_t addrspace(10)* addrspacecast (%jl_value_t* inttoptr (i64 140508121018480 to %jl_value_t*) to %jl_value_t addrspace(10)*), %jl_value_t addrspace(10)** %14

blah blah blah

After:

julia> @code_llvm g(1)

;  @ REPL[2]:1 within `g'
define void @julia_g_16075({ [4 x i64] }* noalias nocapture sret, i64) {
top:
  %2 = bitcast { [4 x i64] }* %0 to <2 x i64>*
  store <2 x i64> <i64 1, i64 3>, <2 x i64>* %2, align 8
  %.sroa.0.sroa.3.0..sroa.0.0..sroa_cast1.sroa_idx8 = getelementptr inbounds { [4 x i64] }, { [4 x i64] }* %0, i64 0, i32 0, i64 2
  store i64 2, i64* %.sroa.0.sroa.3.0..sroa.0.0..sroa_cast1.sroa_idx8, align 8
  %.sroa.0.sroa.4.0..sroa.0.0..sroa_cast1.sroa_idx9 = getelementptr inbounds { [4 x i64] }, { [4 x i64] }* %0, i64 0, i32 0, i64 3
  store i64 %1, i64* %.sroa.0.sroa.4.0..sroa.0.0..sroa_cast1.sroa_idx9, align 8
  ret void
}

@coveralls
Copy link

Coverage Status

Coverage remained the same at 81.561% when pulling ed5444e on cjf/SA-fix into 5005108 on master.

@c42f c42f changed the title Remove some spurious where T from SA constructors Remove some spurious where T from SA constructors Sep 27, 2019
@c42f c42f merged commit 1a54a0b into master Sep 27, 2019
@c42f c42f deleted the cjf/SA-fix branch September 28, 2019 01:20
@c42f c42f mentioned this pull request Nov 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants