Skip to content

Commit 097eacd

Browse files
committed
allow libm_intrinsics fallback
1 parent ebc143b commit 097eacd

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

crates/rustc_codegen_spirv/src/builder/builder_methods.rs

+12-10
Original file line numberDiff line numberDiff line change
@@ -2325,17 +2325,19 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
23252325
.get(&callee_val)
23262326
.copied();
23272327
if let Some(libm_intrinsic) = libm_intrinsic {
2328-
let result = self.call_libm_intrinsic(libm_intrinsic, result_type, args);
2329-
if result_type != result.ty {
2330-
bug!(
2331-
"Mismatched libm result type for {:?}: expected {}, got {}",
2332-
libm_intrinsic,
2333-
self.debug_type(result_type),
2334-
self.debug_type(result.ty),
2335-
);
2328+
if let Some(result) = self.call_libm_intrinsic(libm_intrinsic, result_type, args) {
2329+
if result_type != result.ty {
2330+
bug!(
2331+
"Mismatched libm result type for {:?}: expected {}, got {}",
2332+
libm_intrinsic,
2333+
self.debug_type(result_type),
2334+
self.debug_type(result.ty),
2335+
);
2336+
}
2337+
return result;
23362338
}
2337-
result
2338-
} else if [self.panic_fn_id.get(), self.panic_bounds_check_fn_id.get()]
2339+
}
2340+
if [self.panic_fn_id.get(), self.panic_bounds_check_fn_id.get()]
23392341
.contains(&Some(callee_val))
23402342
{
23412343
// HACK(eddyb) redirect builtin panic calls to an abort, to avoid

crates/rustc_codegen_spirv/src/builder/libm_intrinsics.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,8 @@ impl Builder<'_, '_> {
201201
intrinsic: LibmIntrinsic,
202202
result_type: Word,
203203
args: &[SpirvValue],
204-
) -> SpirvValue {
205-
match intrinsic {
204+
) -> Option<SpirvValue> {
205+
Some(match intrinsic {
206206
LibmIntrinsic::GLOp(op) => self.gl_op(op, result_type, args),
207207
LibmIntrinsic::Custom(LibmCustomIntrinsic::SinCos) => {
208208
assert_eq!(args.len(), 1);
@@ -258,6 +258,7 @@ impl Builder<'_, '_> {
258258
let one = self.constant_float(exp.ty, 1.0);
259259
self.sub(exp, one)
260260
}
261+
/*
261262
LibmIntrinsic::Custom(LibmCustomIntrinsic::Erf) => {
262263
let undef = self.undef(result_type);
263264
self.zombie(undef.def(self), "Erf not supported yet");
@@ -348,6 +349,8 @@ impl Builder<'_, '_> {
348349
self.zombie(undef.def(self), "Scalbn not supported yet");
349350
undef
350351
}
351-
}
352+
*/
353+
_ => return None
354+
})
352355
}
353356
}

0 commit comments

Comments
 (0)