From 26a87d56bbf48fc4d9f418a394a5f8303dd73936 Mon Sep 17 00:00:00 2001 From: Gordon Tisher Date: Fri, 26 Jan 2024 14:24:15 -0800 Subject: [PATCH] Use the correct LLVM intrinsics for `powi` on *nix. (#4481) --- .release-notes/4481.md | 3 +++ packages/builtin/float.pony | 8 ++++---- test/full-program-tests/regression-4480/main.pony | 9 +++++++++ 3 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 .release-notes/4481.md create mode 100644 test/full-program-tests/regression-4480/main.pony diff --git a/.release-notes/4481.md b/.release-notes/4481.md new file mode 100644 index 0000000000..3b12a6dc0f --- /dev/null +++ b/.release-notes/4481.md @@ -0,0 +1,3 @@ +## Use the correct LLVM intrinsics for `powi` on *nix. + +We were using outdated LLVM intrinsics `llvm.powi.f32`j and `llvm.powi.f64`; updated to use `llvm.powi.f32.i32` and `llvm.powi.f64.i32`. diff --git a/packages/builtin/float.pony b/packages/builtin/float.pony index 1ff1012312..19c1f82783 100644 --- a/packages/builtin/float.pony +++ b/packages/builtin/float.pony @@ -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) @@ -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 => @@ -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 => diff --git a/test/full-program-tests/regression-4480/main.pony b/test/full-program-tests/regression-4480/main.pony new file mode 100644 index 0000000000..b279efd2d3 --- /dev/null +++ b/test/full-program-tests/regression-4480/main.pony @@ -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())