Create a gist now

Instantly share code, notes, and snippets.

@rhysd /sqrt2.s Secret
Created Mar 24, 2016

.text
.macosx_version_min 10, 11
.file "sqrt2.ll"
.globl abs
.type abs,@function
abs: # @abs
.param f64
.result f64
# BB#0: # %entry
block
f64.const $push0=, 0x0p0
f64.gt $push1=, $0, $pop0
f64.ne $push2=, $0, $0
i32.or $push3=, $pop1, $pop2
br_if 0, $pop3 # 0: down to label0
# BB#1: # %if.expr.else
f64.neg $0=, $0
.LBB0_2: # %if.expr.end
end_block # label0:
return $0
.endfunc
.Lfunc_end0:
.size abs, .Lfunc_end0-abs
.globl sqrt2
.type sqrt2,@function
sqrt2: # @sqrt2
.param f64, f64, f64
.result f64
# BB#0: # %entry
block
f64.sub $push0=, $0, $1
f64.call $push1=, abs@FUNCTION, $pop0
f64.const $push2=, 0x1.4f8b588e368f1p-17
f64.ge $push3=, $pop1, $pop2
br_if 0, $pop3 # 0: down to label1
# BB#1: # %postfixif.then
return $1
.LBB1_2: # %postfixif.end
end_block # label1:
f64.mul $push4=, $1, $1
f64.sub $push5=, $pop4, $2
f64.const $push6=, -0x1p1
f64.mul $push7=, $1, $pop6
f64.div $push8=, $pop5, $pop7
f64.add $push9=, $1, $pop8
f64.call $push10=, sqrt2@FUNCTION, $1, $pop9, $2
return $pop10
.endfunc
.Lfunc_end1:
.size sqrt2, .Lfunc_end1-sqrt2
.globl sqrt
.type sqrt,@function
sqrt: # @sqrt
.param f64
.result f64
# BB#0: # %entry
f64.const $push0=, 0x0p0
f64.call $push1=, sqrt2@FUNCTION, $pop0, $0, $0
return $pop1
.endfunc
.Lfunc_end2:
.size sqrt, .Lfunc_end2-sqrt
.type .Lconst.unit,@object # @const.unit
.section .rodata,"a",@progbits
.p2align 3
.Lconst.unit:
.size .Lconst.unit, 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment