Skip to content

Commit

Permalink
Use the correct LLVM intrinsics for powi on *nix.
Browse files Browse the repository at this point in the history
  • Loading branch information
chalcolith committed Jan 26, 2024
1 parent 8451fd0 commit c1fb729
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/builtin/float.pony
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ use @logbf[F32](x: F32)
use @logb[F64](x: F64)
use @"llvm.pow.f32"[F32](x: F32, y: F32)
use @"llvm.pow.f64"[F64](x: F64, y: F64)
use @"llvm.powi.f32"[F32](x: F32, y: I32) if not windows
use @"llvm.powi.f64"[F64](x: F64, y: I32) if not windows
use @"llvm.powi.f32.i32"[F32](x: F32, y: I32) if not windows
use @"llvm.powi.f64.i32"[F64](x: F64, y: I32) if not windows
use @"llvm.sqrt.f32"[F32](x: F32)
use @"llvm.sqrt.f64"[F64](x: F64)
use @cbrtf[F32](x: F32)
Expand Down Expand Up @@ -217,7 +217,7 @@ primitive F32 is FloatingPoint[F32]
ifdef windows then
pow(y.f32())
else
@"llvm.powi.f32"(this, y)
@"llvm.powi.f32.i32"(this, y)
end

fun sqrt(): F32 =>
Expand Down Expand Up @@ -434,7 +434,7 @@ primitive F64 is FloatingPoint[F64]
ifdef windows then
pow(y.f64())
else
@"llvm.powi.f64"(this, y)
@"llvm.powi.f64.i32"(this, y)
end

fun sqrt(): F64 =>
Expand Down
9 changes: 9 additions & 0 deletions test/full-program-tests/regression-4480/main.pony
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
actor Main
new create(env: Env) =>
let a: F64 = 3.14
let b: F64 = a.powi(-2)
env.out.print("B is now " + b.string())

let c: F32 = 3.14
let d: F32 = c.powi(-3)
env.out.print("D is now " + d.string())

0 comments on commit c1fb729

Please sign in to comment.