diff --git a/crates/rustc_codegen_spirv/src/builder/builder_methods.rs b/crates/rustc_codegen_spirv/src/builder/builder_methods.rs index 8cc2f67abd..acebcfb776 100644 --- a/crates/rustc_codegen_spirv/src/builder/builder_methods.rs +++ b/crates/rustc_codegen_spirv/src/builder/builder_methods.rs @@ -2325,17 +2325,19 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { .get(&callee_val) .copied(); if let Some(libm_intrinsic) = libm_intrinsic { - let result = self.call_libm_intrinsic(libm_intrinsic, result_type, args); - if result_type != result.ty { - bug!( - "Mismatched libm result type for {:?}: expected {}, got {}", - libm_intrinsic, - self.debug_type(result_type), - self.debug_type(result.ty), - ); + if let Some(result) = self.call_libm_intrinsic(libm_intrinsic, result_type, args) { + if result_type != result.ty { + bug!( + "Mismatched libm result type for {:?}: expected {}, got {}", + libm_intrinsic, + self.debug_type(result_type), + self.debug_type(result.ty), + ); + } + return result; } - result - } else if [self.panic_fn_id.get(), self.panic_bounds_check_fn_id.get()] + } + if [self.panic_fn_id.get(), self.panic_bounds_check_fn_id.get()] .contains(&Some(callee_val)) { // HACK(eddyb) redirect builtin panic calls to an abort, to avoid diff --git a/crates/rustc_codegen_spirv/src/builder/libm_intrinsics.rs b/crates/rustc_codegen_spirv/src/builder/libm_intrinsics.rs index 3604ce5e5d..71cb3e1e38 100644 --- a/crates/rustc_codegen_spirv/src/builder/libm_intrinsics.rs +++ b/crates/rustc_codegen_spirv/src/builder/libm_intrinsics.rs @@ -201,8 +201,8 @@ impl Builder<'_, '_> { intrinsic: LibmIntrinsic, result_type: Word, args: &[SpirvValue], - ) -> SpirvValue { - match intrinsic { + ) -> Option { + Some(match intrinsic { LibmIntrinsic::GLOp(op) => self.gl_op(op, result_type, args), LibmIntrinsic::Custom(LibmCustomIntrinsic::SinCos) => { assert_eq!(args.len(), 1); @@ -258,6 +258,7 @@ impl Builder<'_, '_> { let one = self.constant_float(exp.ty, 1.0); self.sub(exp, one) } + /* LibmIntrinsic::Custom(LibmCustomIntrinsic::Erf) => { let undef = self.undef(result_type); self.zombie(undef.def(self), "Erf not supported yet"); @@ -348,6 +349,8 @@ impl Builder<'_, '_> { self.zombie(undef.def(self), "Scalbn not supported yet"); undef } - } + */ + _ => return None + }) } }