Skip to content

Commit f1a5432

Browse files
Firestar99eddyb
authored andcommitted
const folding: fix libm intrinsics using int add() instead of fadd()
1 parent f3cb7ae commit f1a5432

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

crates/rustc_codegen_spirv/src/builder/libm_intrinsics.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,20 +246,20 @@ impl Builder<'_, '_> {
246246
LibmIntrinsic::Custom(LibmCustomIntrinsic::Log1p) => {
247247
assert_eq!(args.len(), 1);
248248
let one = self.constant_float(args[0].ty, 1.0);
249-
let add = self.add(args[0], one);
249+
let add = self.fadd(args[0], one);
250250
self.gl_op(GLOp::Log, result_type, [add])
251251
}
252252
LibmIntrinsic::Custom(LibmCustomIntrinsic::Exp10) => {
253253
assert_eq!(args.len(), 1);
254254
// exp10(x) == exp(x * log(10));
255255
let log10 = self.constant_float(args[0].ty, 10.0f64.ln());
256-
let mul = self.mul(args[0], log10);
256+
let mul = self.fmul(args[0], log10);
257257
self.gl_op(GLOp::Exp, result_type, [mul])
258258
}
259259
LibmIntrinsic::Custom(LibmCustomIntrinsic::Expm1) => {
260260
let exp = self.gl_op(GLOp::Exp, args[0].ty, [args[0]]);
261261
let one = self.constant_float(exp.ty, 1.0);
262-
self.sub(exp, one)
262+
self.fsub(exp, one)
263263
}
264264
LibmIntrinsic::Custom(LibmCustomIntrinsic::Erf) => {
265265
self.undef_zombie(result_type, "Erf not supported yet")

0 commit comments

Comments
 (0)