diff --git a/src/nouveau/compiler/nak/builder.rs b/src/nouveau/compiler/nak/builder.rs index 0aa868ce7d7..94b2909745a 100644 --- a/src/nouveau/compiler/nak/builder.rs +++ b/src/nouveau/compiler/nak/builder.rs @@ -540,6 +540,9 @@ pub trait SSABuilder: Builder { let dst = self.alloc_ssa(RegFile::Pred, 1); match cmp_op { + IntCmpOp::False | IntCmpOp::True => { + panic!("These don't make sense for the builder helper"); + } IntCmpOp::Eq | IntCmpOp::Ne => { self.push_op(OpISetP { dst: dst.into(), diff --git a/src/nouveau/compiler/nak/hw_tests.rs b/src/nouveau/compiler/nak/hw_tests.rs index 1b8cb6348a4..7f0a61826b4 100644 --- a/src/nouveau/compiler/nak/hw_tests.rs +++ b/src/nouveau/compiler/nak/hw_tests.rs @@ -680,6 +680,8 @@ fn test_op_iadd3x() { fn test_op_isetp() { let set_ops = [PredSetOp::And, PredSetOp::Or, PredSetOp::Xor]; let cmp_ops = [ + IntCmpOp::False, + IntCmpOp::True, IntCmpOp::Eq, IntCmpOp::Ne, IntCmpOp::Lt, @@ -1211,6 +1213,8 @@ fn test_isetp64() { let x = x as i64; let y = y as i64; match cmp_op { + IntCmpOp::False => false, + IntCmpOp::True => true, IntCmpOp::Eq => x == y, IntCmpOp::Ne => x != y, IntCmpOp::Lt => x < y, @@ -1220,6 +1224,8 @@ fn test_isetp64() { } } else { match cmp_op { + IntCmpOp::False => false, + IntCmpOp::True => true, IntCmpOp::Eq => x == y, IntCmpOp::Ne => x != y, IntCmpOp::Lt => x < y, diff --git a/src/nouveau/compiler/nak/ir.rs b/src/nouveau/compiler/nak/ir.rs index 01a32f0c315..4d06f58ad9a 100644 --- a/src/nouveau/compiler/nak/ir.rs +++ b/src/nouveau/compiler/nak/ir.rs @@ -1813,8 +1813,11 @@ impl fmt::Display for FloatCmpOp { } } +#[allow(dead_code)] #[derive(Clone, Copy, Eq, Hash, PartialEq)] pub enum IntCmpOp { + False, + True, Eq, Ne, Lt, @@ -1826,6 +1829,7 @@ pub enum IntCmpOp { impl IntCmpOp { pub fn flip(self) -> IntCmpOp { match self { + IntCmpOp::False | IntCmpOp::True => self, IntCmpOp::Eq | IntCmpOp::Ne => self, IntCmpOp::Lt => IntCmpOp::Gt, IntCmpOp::Le => IntCmpOp::Ge, @@ -1838,6 +1842,8 @@ impl IntCmpOp { impl fmt::Display for IntCmpOp { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { + IntCmpOp::False => write!(f, ".f"), + IntCmpOp::True => write!(f, ".t"), IntCmpOp::Eq => write!(f, ".eq"), IntCmpOp::Ne => write!(f, ".ne"), IntCmpOp::Lt => write!(f, ".lt"), @@ -3769,6 +3775,8 @@ impl Foldable for OpISetP { let x = x as i32; let y = y as i32; match &self.cmp_op { + IntCmpOp::False => false, + IntCmpOp::True => true, IntCmpOp::Eq => x == y, IntCmpOp::Ne => x != y, IntCmpOp::Lt => x < y, @@ -3778,6 +3786,8 @@ impl Foldable for OpISetP { } } else { match &self.cmp_op { + IntCmpOp::False => false, + IntCmpOp::True => true, IntCmpOp::Eq => x == y, IntCmpOp::Ne => x != y, IntCmpOp::Lt => x < y, @@ -3787,7 +3797,9 @@ impl Foldable for OpISetP { } }; - let cmp = if self.ex && x == y { + let cmp_op_is_const = + matches!(self.cmp_op, IntCmpOp::False | IntCmpOp::True); + let cmp = if self.ex && x == y && !cmp_op_is_const { // Pre-Volta, isetp.x takes the accumulator into account. If we // want to support this, we need to take an an accumulator into // account. Disallow it for now. diff --git a/src/nouveau/compiler/nak/sm50.rs b/src/nouveau/compiler/nak/sm50.rs index 24fd41e0faf..fcd23993316 100644 --- a/src/nouveau/compiler/nak/sm50.rs +++ b/src/nouveau/compiler/nak/sm50.rs @@ -844,6 +844,8 @@ impl SM50Encoder<'_> { self.set_field( range, match op { + IntCmpOp::False => 0_u8, + IntCmpOp::True => 7_u8, IntCmpOp::Eq => 2_u8, IntCmpOp::Ne => 5_u8, IntCmpOp::Lt => 1_u8, diff --git a/src/nouveau/compiler/nak/sm70_encode.rs b/src/nouveau/compiler/nak/sm70_encode.rs index abcdef2152f..904bd00f857 100644 --- a/src/nouveau/compiler/nak/sm70_encode.rs +++ b/src/nouveau/compiler/nak/sm70_encode.rs @@ -827,6 +827,8 @@ impl SM70Encoder<'_> { self.set_field( range, match op { + IntCmpOp::False => 0_u8, + IntCmpOp::True => 7_u8, IntCmpOp::Eq => 2_u8, IntCmpOp::Ne => 5_u8, IntCmpOp::Lt => 1_u8,