Skip to content

Instantly share code, notes, and snippets.

@vtjnash
Forked from ihnorton/ex.md
Last active August 29, 2015 14:19
Show Gist options
  • Save vtjnash/80a2aa73f04e33ec13b2 to your computer and use it in GitHub Desktop.
Save vtjnash/80a2aa73f04e33ec13b2 to your computer and use it in GitHub Desktop.
%jl_value_t = type { %jl_value_t* }
declare void @jl_throw_with_superfluous_argument(%jl_value_t*, i32)
@jl_domain_exception = external global %jl_value_t*

define double @julia_gv_67043(i64) {
top:
  %1 = call double inttoptr (i64 339752784 to double (double, double)*)(double 1.000000e+00, double 0.000000e+00)
  %2 = sitofp i64 %0 to double
  %3 = call double inttoptr (i64 339772768 to double (double, double)*)(double %1, double %2)
  %4 = fadd double %2, %1
  %5 = fcmp uno double %4, 0.000000e+00
  %6 = fcmp ord double %3, 0.000000e+00
  %7 = or i1 %6, %5
  br i1 %7, label %pass, label %fail

fail:                                             ; preds = %top
  %8 = load %jl_value_t*, %jl_value_t** @jl_domain_exception, align 8
  call void @jl_throw_with_superfluous_argument(%jl_value_t* %8, i32 6)
  unreachable

pass:                                             ; preds = %top
  ret double %3
}
$ ./llc --version
LLVM (http://llvm.org/):
  LLVM version 3.7.0svn
  Optimized build with assertions.
  Built Apr 15 2015 (00:24:42).
  Default target: x86_64-pc-linux-gnu
  Host CPU: westmere

  Registered Targets:
    x86    - 32-bit X86: Pentium-Pro and above
    x86-64 - 64-bit X86: EM64T and AMD64
; llvm git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234975 91177308-0d34-0410-b5e6-96231b3b80d8
$ ./llc -filetype=asm -mtriple=x86_64-w64-windows-gnu-elf -mcpu=corei7-avx -o - gv-svn.ll
	.text
	.file	"/home/jameson/gv-svn.ll"
	.section	.rodata.cst8,"aM",@progbits,8
	.align	8
.LCPI0_0:
	.quad	4607182418800017408     # double 1
	.text
	.globl	julia_gv_67043
	.align	16, 0x90
	.type	julia_gv_67043,@function
julia_gv_67043:                         # @julia_gv_67043
	.cfi_startproc
# BB#0:                                 # %top
	pushq	%rsi
.Ltmp0:
	.cfi_def_cfa_offset 16
	subq	$64, %rsp
	vmovaps	%xmm7, 48(%rsp)         # 16-byte Spill
	vmovaps	%xmm6, 32(%rsp)         # 16-byte Spill
.Ltmp1:
	.cfi_def_cfa_offset 80
.Ltmp2:
	.cfi_offset %rsi, -16
.Ltmp3:
	.cfi_offset %xmm6, -48
.Ltmp4:
	.cfi_offset %xmm7, -32
	movq	%rcx, %rsi
	movl	$339752784, %eax        # imm = 0x14403750
	vmovsd	.LCPI0_0(%rip), %xmm0   # xmm0 = mem[0],zero
	vxorps	%xmm1, %xmm1, %xmm1
	callq	*%rax
	vmovapd	%xmm0, %xmm6
	vxorps	%xmm0, %xmm0, %xmm0
	vcvtsi2sdq	%rsi, %xmm0, %xmm7
	movl	$339772768, %eax        # imm = 0x14408560
                                        # kill: XMM0<def> XMM6<kill>
	vmovaps	%xmm7, %xmm1
	callq	*%rax
	vucomisd	%xmm0, %xmm0
	jnp	.LBB0_3
# BB#1:                                 # %top
	vaddsd	%xmm6, %xmm7, %xmm1
	vucomisd	%xmm1, %xmm1
	jnp	.LBB0_2
.LBB0_3:                                # %pass
	vmovaps	32(%rsp), %xmm6         # 16-byte Reload
	vmovaps	48(%rsp), %xmm7         # 16-byte Reload
	addq	$64, %rsp
	popq	%rsi
	retq
.LBB0_2:                                # %fail
	movq	jl_domain_exception(%rip), %rcx
	movl	$6, %edx
	callq	jl_throw_with_superfluous_argument@PLT
	ud2
.Lfunc_end0:
	.size	julia_gv_67043, .Lfunc_end0-julia_gv_67043
	.cfi_endproc


	.section	".note.GNU-stack","",@progbits
$ diff -u <(./llc -filetype=asm -mtriple=x86_64-w64-windows-gnu-elf -mcpu=corei7-avx -o - ~/gv-svn.ll) <(./llc -filetype=asm -mtriple=x86_64-w64-windows-gnu-elf -mcpu=corei7-avx -o - ~/gv-svn.ll -disable-copyprop)
--- /dev/fd/63	2015-04-15 00:56:22.426457498 -0400
+++ /dev/fd/62	2015-04-15 00:56:22.426457498 -0400
@@ -34,7 +34,7 @@
 	vxorps	%xmm0, %xmm0, %xmm0
 	vcvtsi2sdq	%rsi, %xmm0, %xmm7
 	movl	$339772768, %eax        # imm = 0x14408560
-                                        # kill: XMM0<def> XMM6<kill>
+	vmovapd	%xmm6, %xmm0
 	vmovaps	%xmm7, %xmm1
 	callq	*%rax
 	vucomisd	%xmm0, %xmm0
@vtjnash
Copy link
Author

vtjnash commented Apr 15, 2015

cross-link: JuliaLang/julia#10394

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment