diff --git a/src/compiler/nir/nir_algebraic.py b/src/compiler/nir/nir_algebraic.py index be26b60d32e..b7efcf93c91 100644 --- a/src/compiler/nir/nir_algebraic.py +++ b/src/compiler/nir/nir_algebraic.py @@ -255,7 +255,12 @@ class Constant(Value): if isinstance(self.value, (bool)): return 'NIR_TRUE' if self.value else 'NIR_FALSE' if isinstance(self.value, int): - return hex(self.value) + # Explicitly sign-extend negative integers to 64-bit, ensuring correct + # handling of -INT32_MIN which is not representable in 32-bit. + if self.value < 0: + return hex(struct.unpack('Q', struct.pack('q', self.value))[0]) + else: + return hex(self.value) elif isinstance(self.value, float): return hex(struct.unpack('Q', struct.pack('d', self.value))[0]) else: