@@ -393,7 +393,7 @@ impl Builder<'_, '_> {
393393 let lower = self . emit ( ) . s_convert ( u32, None , arg) . unwrap ( ) ;
394394 let higher = self
395395 . emit ( )
396- . shift_left_logical ( ty, None , arg, u32_32)
396+ . shift_right_logical ( ty, None , arg, u32_32)
397397 . unwrap ( ) ;
398398 let higher = self . emit ( ) . s_convert ( u32, None , higher) . unwrap ( ) ;
399399
@@ -414,6 +414,7 @@ impl Builder<'_, '_> {
414414 _ => self . fatal ( "count_ones on a non-integer type" ) ,
415415 }
416416 }
417+
417418 pub fn bit_reverse ( & self , arg : SpirvValue ) -> SpirvValue {
418419 let ty = arg. ty ;
419420 match self . cx . lookup_type ( ty) {
@@ -453,7 +454,7 @@ impl Builder<'_, '_> {
453454 let lower = self . emit ( ) . s_convert ( u32, None , arg) . unwrap ( ) ;
454455 let higher = self
455456 . emit ( )
456- . shift_left_logical ( ty, None , arg, u32_32)
457+ . shift_right_logical ( ty, None , arg, u32_32)
457458 . unwrap ( ) ;
458459 let higher = self . emit ( ) . s_convert ( u32, None , higher) . unwrap ( ) ;
459460
@@ -463,7 +464,7 @@ impl Builder<'_, '_> {
463464
464465 let higher_bits = self . emit ( ) . u_convert ( uint, None , higher_bits) . unwrap ( ) ;
465466 let shift = self . constant_u32 ( self . span ( ) , 32 ) . def ( self ) ;
466- let higher_bits = self . emit ( ) . shift_right_logical ( uint, None , higher_bits, shift) . unwrap ( ) ;
467+ let higher_bits = self . emit ( ) . shift_left_logical ( uint, None , higher_bits, shift) . unwrap ( ) ;
467468 let lower_bits = self . emit ( ) . u_convert ( uint, None , lower_bits) . unwrap ( ) ;
468469
469470 let result = self . emit ( ) . bitwise_or ( ty, None , lower_bits, higher_bits) . unwrap ( ) ;
@@ -542,7 +543,7 @@ impl Builder<'_, '_> {
542543 let lower = self . emit ( ) . s_convert ( u32, None , arg) . unwrap ( ) ;
543544 let higher = self
544545 . emit ( )
545- . shift_left_logical ( ty, None , arg, u32_32)
546+ . shift_right_logical ( ty, None , arg, u32_32)
546547 . unwrap ( ) ;
547548 let higher = self . emit ( ) . s_convert ( u32, None , higher) . unwrap ( ) ;
548549
0 commit comments