@@ -393,7 +393,7 @@ impl Builder<'_, '_> {
393
393
let lower = self . emit ( ) . s_convert ( u32, None , arg) . unwrap ( ) ;
394
394
let higher = self
395
395
. emit ( )
396
- . shift_left_logical ( ty, None , arg, u32_32)
396
+ . shift_right_logical ( ty, None , arg, u32_32)
397
397
. unwrap ( ) ;
398
398
let higher = self . emit ( ) . s_convert ( u32, None , higher) . unwrap ( ) ;
399
399
@@ -414,6 +414,7 @@ impl Builder<'_, '_> {
414
414
_ => self . fatal ( "count_ones on a non-integer type" ) ,
415
415
}
416
416
}
417
+
417
418
pub fn bit_reverse ( & self , arg : SpirvValue ) -> SpirvValue {
418
419
let ty = arg. ty ;
419
420
match self . cx . lookup_type ( ty) {
@@ -453,7 +454,7 @@ impl Builder<'_, '_> {
453
454
let lower = self . emit ( ) . s_convert ( u32, None , arg) . unwrap ( ) ;
454
455
let higher = self
455
456
. emit ( )
456
- . shift_left_logical ( ty, None , arg, u32_32)
457
+ . shift_right_logical ( ty, None , arg, u32_32)
457
458
. unwrap ( ) ;
458
459
let higher = self . emit ( ) . s_convert ( u32, None , higher) . unwrap ( ) ;
459
460
@@ -463,7 +464,7 @@ impl Builder<'_, '_> {
463
464
464
465
let higher_bits = self . emit ( ) . u_convert ( uint, None , higher_bits) . unwrap ( ) ;
465
466
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 ( ) ;
467
468
let lower_bits = self . emit ( ) . u_convert ( uint, None , lower_bits) . unwrap ( ) ;
468
469
469
470
let result = self . emit ( ) . bitwise_or ( ty, None , lower_bits, higher_bits) . unwrap ( ) ;
@@ -542,7 +543,7 @@ impl Builder<'_, '_> {
542
543
let lower = self . emit ( ) . s_convert ( u32, None , arg) . unwrap ( ) ;
543
544
let higher = self
544
545
. emit ( )
545
- . shift_left_logical ( ty, None , arg, u32_32)
546
+ . shift_right_logical ( ty, None , arg, u32_32)
546
547
. unwrap ( ) ;
547
548
let higher = self . emit ( ) . s_convert ( u32, None , higher) . unwrap ( ) ;
548
549
0 commit comments