@@ -535,87 +535,11 @@ impl<T: SpirvTarget> SpirvCompiler<T> {
535535 b. select ( ty, Some ( out) , is_zero, even, sel1) . unwrap ( ) ;
536536 } )
537537 }
538- Arithmetic :: Hypot ( op) => {
539- self . compile_binary_op ( op, out, uniform, |b, out_ty, ty, lhs, rhs, out| {
540- let relaxed = matches ! ( out_ty. elem( ) , Elem :: Relaxed ) ;
541- let zero = b. static_cast ( ConstVal :: Bit32 ( 0 ) , & Elem :: Int ( 32 , false ) , & out_ty) ;
542- let one = b. static_cast ( ConstVal :: Bit32 ( 1 ) , & Elem :: Int ( 32 , false ) , & out_ty) ;
543- let abs_a = b. id ( ) ;
544- T :: f_abs ( b, ty, lhs, abs_a) ;
545- let abs_b = b. id ( ) ;
546- T :: f_abs ( b, ty, rhs, abs_b) ;
547- let max = b. id ( ) ;
548- T :: f_max ( b, ty, abs_a, abs_b, max) ;
549- let min = b. id ( ) ;
550- T :: f_min ( b, ty, abs_a, abs_b, min) ;
551- let bool = Elem :: Bool . id ( b) ;
552- let is_max_zero = b. f_ord_equal ( bool, None , max, zero) . unwrap ( ) ;
553- let max_safe = b. id ( ) ;
554- b. select ( ty, Some ( max_safe) , is_max_zero, one, max) . unwrap ( ) ;
555- let t = b. id ( ) ;
556- b. f_div ( ty, Some ( t) , min, max_safe) . unwrap ( ) ;
557- let t_fma = b. gl_fma ( ty, t, t, one) . unwrap ( ) ;
558- let square_root = b. id ( ) ;
559- T :: sqrt ( b, ty, t_fma, square_root) ;
560- let ids = [
561- abs_a,
562- abs_b,
563- max,
564- is_max_zero,
565- max_safe,
566- t_fma,
567- square_root,
568- out,
569- ] ;
570- for id in ids {
571- b. mark_uniformity ( id, uniform) ;
572- if relaxed {
573- b. decorate ( id, Decoration :: RelaxedPrecision , [ ] ) ;
574- }
575- }
576- b. f_mul ( ty, Some ( out) , square_root, max) . unwrap ( ) ;
577- } )
538+ Arithmetic :: Hypot ( _op) => {
539+ unreachable ! ( "Replaced by transformer" ) ;
578540 }
579- Arithmetic :: Rhypot ( op) => {
580- self . compile_binary_op ( op, out, uniform, |b, out_ty, ty, lhs, rhs, out| {
581- let relaxed = matches ! ( out_ty. elem( ) , Elem :: Relaxed ) ;
582- let zero = b. static_cast ( ConstVal :: Bit32 ( 0 ) , & Elem :: Int ( 32 , false ) , & out_ty) ;
583- let one = b. static_cast ( ConstVal :: Bit32 ( 1 ) , & Elem :: Int ( 32 , false ) , & out_ty) ;
584- let abs_a = b. id ( ) ;
585- T :: f_abs ( b, ty, lhs, abs_a) ;
586- let abs_b = b. id ( ) ;
587- T :: f_abs ( b, ty, rhs, abs_b) ;
588- let max = b. id ( ) ;
589- T :: f_max ( b, ty, abs_a, abs_b, max) ;
590- let min = b. id ( ) ;
591- T :: f_min ( b, ty, abs_a, abs_b, min) ;
592- let bool = Elem :: Bool . id ( b) ;
593- let is_max_zero = b. f_ord_equal ( bool, None , max, zero) . unwrap ( ) ;
594- let max_safe = b. id ( ) ;
595- b. select ( ty, Some ( max_safe) , is_max_zero, one, max) . unwrap ( ) ;
596- let t = b. id ( ) ;
597- b. f_div ( ty, Some ( t) , min, max_safe) . unwrap ( ) ;
598- let t_fma = b. gl_fma ( ty, t, t, one) . unwrap ( ) ;
599- let inverse_square_root = b. id ( ) ;
600- T :: inverse_sqrt ( b, ty, t_fma, inverse_square_root) ;
601- let ids = [
602- abs_a,
603- abs_b,
604- max,
605- is_max_zero,
606- max_safe,
607- t_fma,
608- inverse_square_root,
609- out,
610- ] ;
611- for id in ids {
612- b. mark_uniformity ( id, uniform) ;
613- if relaxed {
614- b. decorate ( id, Decoration :: RelaxedPrecision , [ ] ) ;
615- }
616- }
617- b. f_div ( ty, Some ( out) , inverse_square_root, max) . unwrap ( ) ;
618- } )
541+ Arithmetic :: Rhypot ( _op) => {
542+ unreachable ! ( "Replaced by transformer" ) ;
619543 }
620544 Arithmetic :: Sqrt ( op) => {
621545 self . compile_unary_op_cast ( op, out, uniform, |b, out_ty, ty, input, out| {
0 commit comments