Skip to content

Conversation

blegat
Copy link
Member

@blegat blegat commented May 5, 2021

Noticed when investigating the benchmark of #1287
Should also help with #1313

On the benchmark of #1287:
Before this PR:

  0.043870 seconds (123.85 k allocations: 17.192 MiB, 20.42% gc time)
  0.000315 seconds (178 allocations: 257.875 KiB)

After this PR:

  0.011613 seconds (3.72 k allocations: 1.152 MiB)
  0.000312 seconds (178 allocations: 257.875 KiB)

@odow
Copy link
Member

odow commented May 5, 2021

TIL:

julia> foo(x) where {T} = x^2
foo (generic function with 1 method)

julia> bar(x) = x^2
bar (generic function with 1 method)

julia> @code_native foo(1)
	.section	__TEXT,__text,regular,pure_instructions
; ┌ @ REPL[1]:1 within `foo'
	pushq	%rax
	movq	%rsi, (%rsp)
	movq	(%rsi), %rax
; │┌ @ intfuncs.jl:312 within `literal_pow'
; ││┌ @ int.jl:88 within `*'
	movq	(%rax), %rdi
	imulq	%rdi, %rdi
; │└└
	movabsq	$jl_box_int64, %rax
	callq	*%rax
	popq	%rcx
	retq
; └

julia> @code_native bar(1)
	.section	__TEXT,__text,regular,pure_instructions
; ┌ @ REPL[2]:1 within `bar'
	movq	%rdi, %rax
; │┌ @ intfuncs.jl:312 within `literal_pow'
; ││┌ @ int.jl:88 within `*'
	imulq	%rdi, %rax
; │└└
	retq
	nopl	(%rax,%rax)
; └

@odow odow merged commit 56e319c into master May 6, 2021
@odow odow deleted the bl/useless_S branch May 6, 2021 00:55
@blegat blegat added this to the v0.10 milestone May 22, 2021
blegat added a commit that referenced this pull request May 22, 2021
blegat added a commit that referenced this pull request May 22, 2021
@blegat blegat modified the milestones: v0.10, v0.9.22 May 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants