Shaders: v_cmp_lg is ordered on AMD hosts too (olt | ogt, not fcmp one)
v_cmp_lg_{f32,f16} ("less or greater") is ordered and not equal: false
when either operand is a NaN, on RDNA2 hardware as in the ISA. It was
lowered to `fcmp one`, which says the same, but the AMD D3D12 driver runs
`fcmp one` as unordered and returns true for a NaN. NVIDIA and WARP get it
right. It now lowers as `olt | ogt`, which all three run alike.
New GPU test v_cmp_lg_is_false_for_nan covers both widths: NaN on either
side, both NaN, a signalling NaN, +0 against -0, inf against inf and
against -inf, and junk in the unread high halves for f16.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
35e8407c9c
commit
64a2ec1b95
3 files changed
+84
-20
No files matched your search
@@ -4989,26 +4989,35 @@ impl<'a> Lower<'a> {
|
||||
} else {
|
||||
(self.fsrc(inst, 0)?, self.fsrc(inst, 1)?)
|
||||
};
|
||||
let p = match op {
|
||||
"f" => pred::FALSE,
|
||||
"lt" => pred::OLT,
|
||||
"eq" => pred::OEQ,
|
||||
"le" => pred::OLE,
|
||||
"gt" => pred::OGT,
|
||||
"lg" => pred::ONE,
|
||||
"ge" => pred::OGE,
|
||||
"o" => pred::ORD,
|
||||
"u" => pred::UNO,
|
||||
"nge" => pred::ULT,
|
||||
"nlg" => pred::UEQ,
|
||||
"ngt" => pred::ULE,
|
||||
"nle" => pred::UGT,
|
||||
"neq" => pred::UNE,
|
||||
"nlt" => pred::UGE,
|
||||
"tru" => pred::TRUE,
|
||||
_ => return Err(inst.name()),
|
||||
};
|
||||
self.s.m.cmp(c, p, a, b)
|
||||
if op == "lg" {
|
||||
// Ordered and not equal, false for a NaN, as `olt | ogt`.
|
||||
// `fcmp one` means the same, but the AMD D3D12 driver
|
||||
// runs it as unordered (true for a NaN) where NVIDIA
|
||||
// and WARP do not; olt and ogt agree on all three.
|
||||
let lt = self.s.m.cmp(c, pred::OLT, a, b);
|
||||
let gt = self.s.m.cmp(c, pred::OGT, a, b);
|
||||
self.s.m.bin(c, Bin::Or, lt, gt)
|
||||
} else {
|
||||
let p = match op {
|
||||
"f" => pred::FALSE,
|
||||
"lt" => pred::OLT,
|
||||
"eq" => pred::OEQ,
|
||||
"le" => pred::OLE,
|
||||
"gt" => pred::OGT,
|
||||
"ge" => pred::OGE,
|
||||
"o" => pred::ORD,
|
||||
"u" => pred::UNO,
|
||||
"nge" => pred::ULT,
|
||||
"nlg" => pred::UEQ,
|
||||
"ngt" => pred::ULE,
|
||||
"nle" => pred::UGT,
|
||||
"neq" => pred::UNE,
|
||||
"nlt" => pred::UGE,
|
||||
"tru" => pred::TRUE,
|
||||
_ => return Err(inst.name()),
|
||||
};
|
||||
self.s.m.cmp(c, p, a, b)
|
||||
}
|
||||
}
|
||||
"u64" | "i64" => {
|
||||
let (a, b) = (self.src64(inst, 0)?, self.src64(inst, 1)?);
|
||||
|
||||
Reference in new issue
Block a user