From aa87c9c96d9ada1d21090b3c2dd3ec3185eeefbb Mon Sep 17 00:00:00 2001 From: Faith Ekstrand Date: Sat, 27 Jul 2024 00:32:08 -0500 Subject: [PATCH] nak/hw_tests: Use better test values for iadd tests This new helper makes sure we return some particularly interesting numbers which may hit edge cases in the hardware and/or folding code. Part-of: --- src/nouveau/compiler/nak/hw_tests.rs | 30 +++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/src/nouveau/compiler/nak/hw_tests.rs b/src/nouveau/compiler/nak/hw_tests.rs index 433cd5c3198..b9e854e0b4f 100644 --- a/src/nouveau/compiler/nak/hw_tests.rs +++ b/src/nouveau/compiler/nak/hw_tests.rs @@ -550,6 +550,19 @@ fn test_op_iabs() { } } +fn get_iadd_int(a: &mut Acorn) -> u32 { + let x = a.get_uint(36); + match x >> 32 { + 0 => 0, + 1 => 1, + 2 => 1 << 31, + 3 => (1 << 31) - 1, + 4 => u32::MAX, + 5 => u32::MAX - 1, + _ => x as u32, + } +} + #[test] fn test_op_iadd3() { if RunSingleton::get().sm.sm() >= 70 { @@ -567,7 +580,9 @@ fn test_op_iadd3() { if i / 3 == 1 { op.srcs[2].src_mod = SrcMod::INeg; } - test_foldable_op(op); + + let mut a = Acorn::new(); + test_foldable_op_with(op, |_| get_iadd_int(&mut a)); } } } @@ -590,7 +605,9 @@ fn test_op_iadd3x() { if i / 3 == 1 { op.srcs[2].src_mod = SrcMod::BNot; } - test_foldable_op(op); + + let mut a = Acorn::new(); + test_foldable_op_with(op, |_| get_iadd_int(&mut a)); } } } @@ -761,7 +778,14 @@ fn test_iadd64() { let mut a = Acorn::new(); let mut data = Vec::new(); for _ in 0..invocations { - data.push([a.get_u32(), a.get_u32(), a.get_u32(), a.get_u32(), 0, 0]); + data.push([ + get_iadd_int(&mut a), + get_iadd_int(&mut a), + get_iadd_int(&mut a), + get_iadd_int(&mut a), + 0, + 0, + ]); } run.run.run(&bin, &mut data).unwrap();