Skip to content

Commit f8b35d1

Browse files
authoredJan 4, 2018
Workaround llvm.powi.* intrinsics not available on win32 (#5538)
1 parent 482b1cf commit f8b35d1

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed
 

‎src/float.cr

+10-2
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,11 @@ struct Float32
132132
end
133133

134134
def **(other : Int32)
135-
LibM.powi_f32(self, other)
135+
{% if flag?(:win32) %}
136+
self ** other.to_f32
137+
{% else %}
138+
LibM.powi_f32(self, other)
139+
{% end %}
136140
end
137141

138142
def **(other : Float32)
@@ -191,7 +195,11 @@ struct Float64
191195
end
192196

193197
def **(other : Int32)
194-
LibM.powi_f64(self, other)
198+
{% if flag?(:win32) %}
199+
self ** other.to_f64
200+
{% else %}
201+
LibM.powi_f64(self, other)
202+
{% end %}
195203
end
196204

197205
def **(other : Float64)

‎src/math/libm.cr

+4-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,10 @@ lib LibM
3737
fun max_f64 = "llvm.maxnum.f64"(value1 : Float64, value2 : Float64) : Float64
3838
fun pow_f32 = "llvm.pow.f32"(value : Float32, power : Float32) : Float32
3939
fun pow_f64 = "llvm.pow.f64"(value : Float64, power : Float64) : Float64
40-
fun powi_f32 = "llvm.powi.f32"(value : Float32, power : Int32) : Float32
41-
fun powi_f64 = "llvm.powi.f64"(value : Float64, power : Int32) : Float64
40+
{% unless flag?(:win32) %}
41+
fun powi_f32 = "llvm.powi.f32"(value : Float32, power : Int32) : Float32
42+
fun powi_f64 = "llvm.powi.f64"(value : Float64, power : Int32) : Float64
43+
{% end %}
4244
fun round_f32 = "llvm.round.f32"(value : Float32) : Float32
4345
fun round_f64 = "llvm.round.f64"(value : Float64) : Float64
4446
fun sin_f32 = "llvm.sin.f32"(value : Float32) : Float32

0 commit comments

Comments
 (0)
Please sign in to comment.