Performance: replace conditional jump by some shift/and/or?

They are generating different code, and the shift is definitely slower on my i7. I’m using julia 1.2, and I altered some of the commented quotes in the generated code to help the syntax highlighter.

julia> c = 1
1

julia> @code_native f1(c)
	.text
; ┌ @ timing.jl:1 within 'f1'
; │┌ @ operators.jl:341 within '>='
; ││┌ @ timing.jl:1 within '<='
	testq	%rdi, %rdi
; │└└
	js	L12
; │┌ @ int.jl:293 within '&'
	andl	$7, %edi
; │└
	movq	%rdi, %rax
	retq
; │┌ @ int.jl:293 within '&'
L12:
	movzbl	%dil, %eax
; │└
	retq
	nopw	%cs:(%rax,%rax)
; └

julia> @code_native f2(c)
	.text
; ┌ @ timing.jl:3 within 'f2'
; │┌ @ int.jl:444 within '>>' @ timing.jl:3
	movq	%rdi, %rax
	sarq	$63, %rax
; │└
; │┌ @ int.jl:293 within '&'
	andl	$248, %eax
; │└
; │┌ @ int.jl:316 within '|'
	leaq	7(%rax), %rax
; │└
; │┌ @ int.jl:293 within '&'
	andq	%rdi, %rax
; │└
	retq
	nopw	%cs:(%rax,%rax)
; └