Skip to content

Commit

Permalink
Workaround llvm.powi.* intrinsics not available on win32 (#5538)
Browse files Browse the repository at this point in the history
  • Loading branch information
RX14 committed Jan 4, 2018
1 parent 482b1cf commit f8b35d1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
12 changes: 10 additions & 2 deletions src/float.cr
Expand Up @@ -132,7 +132,11 @@ struct Float32
end

def **(other : Int32)
LibM.powi_f32(self, other)
{% if flag?(:win32) %}
self ** other.to_f32
{% else %}
LibM.powi_f32(self, other)
{% end %}
end

def **(other : Float32)
Expand Down Expand Up @@ -191,7 +195,11 @@ struct Float64
end

def **(other : Int32)
LibM.powi_f64(self, other)
{% if flag?(:win32) %}
self ** other.to_f64
{% else %}
LibM.powi_f64(self, other)
{% end %}
end

def **(other : Float64)
Expand Down
6 changes: 4 additions & 2 deletions src/math/libm.cr
Expand Up @@ -37,8 +37,10 @@ lib LibM
fun max_f64 = "llvm.maxnum.f64"(value1 : Float64, value2 : Float64) : Float64
fun pow_f32 = "llvm.pow.f32"(value : Float32, power : Float32) : Float32
fun pow_f64 = "llvm.pow.f64"(value : Float64, power : Float64) : Float64
fun powi_f32 = "llvm.powi.f32"(value : Float32, power : Int32) : Float32
fun powi_f64 = "llvm.powi.f64"(value : Float64, power : Int32) : Float64
{% unless flag?(:win32) %}
fun powi_f32 = "llvm.powi.f32"(value : Float32, power : Int32) : Float32
fun powi_f64 = "llvm.powi.f64"(value : Float64, power : Int32) : Float64
{% end %}
fun round_f32 = "llvm.round.f32"(value : Float32) : Float32
fun round_f64 = "llvm.round.f64"(value : Float64) : Float64
fun sin_f32 = "llvm.sin.f32"(value : Float32) : Float32
Expand Down

0 comments on commit f8b35d1

Please sign in to comment.