diff --git a/src/nouveau/compiler/nak/hw_tests.rs b/src/nouveau/compiler/nak/hw_tests.rs index 27290cde016..ac71816329e 100644 --- a/src/nouveau/compiler/nak/hw_tests.rs +++ b/src/nouveau/compiler/nak/hw_tests.rs @@ -950,7 +950,7 @@ fn test_op_shf() { let mut a = Acorn::new(); test_foldable_op_with(op, &mut |i| { if i == shift_idx { - a.get_uint(6) as u32 + a.get_uint(7) as u32 } else { a.get_u32() } diff --git a/src/nouveau/compiler/nak/ir.rs b/src/nouveau/compiler/nak/ir.rs index c1c59fac37f..a90303440fc 100644 --- a/src/nouveau/compiler/nak/ir.rs +++ b/src/nouveau/compiler/nak/ir.rs @@ -4007,21 +4007,22 @@ impl Foldable for OpShf { && self.data_type != IntType::I64 { if self.right { - x.checked_shr(shift).unwrap_or(0) as u64 + x.checked_shr(shift).unwrap_or(0) } else { - x.checked_shl(shift).unwrap_or(0) as u64 + x.checked_shl(shift).unwrap_or(0) } } else if self.data_type.is_signed() { if self.right { - (x as i64).checked_shr(shift).unwrap_or(0) as u64 + let x = x as i64; + x.checked_shr(shift).unwrap_or(x >> 63) as u64 } else { - (x as i64).checked_shl(shift).unwrap_or(0) as u64 + x.checked_shl(shift).unwrap_or(0) } } else { if self.right { - x.checked_shr(shift).unwrap_or(0) as u64 + x.checked_shr(shift).unwrap_or(0) } else { - x.checked_shl(shift).unwrap_or(0) as u64 + x.checked_shl(shift).unwrap_or(0) } };