@@ -6234,14 +6234,14 @@ class spu_llvm_recompiler : public spu_recompiler_base, public cpu_translator
6234
6234
const value_t <f32[4 ]> ab[2 ]{a, b};
6235
6235
6236
6236
std::bitset<2 > safe_int_compare (0 );
6237
- std::bitset<2 > safe_nonzero_compare (0 );
6237
+ std::bitset<2 > safe_finite_compare (0 );
6238
6238
6239
6239
for (u32 i = 0 ; i < 2 ; i++)
6240
6240
{
6241
6241
if (auto [ok, data] = get_const_vector (ab[i].value , m_pos, __LINE__ + i); ok)
6242
6242
{
6243
6243
safe_int_compare.set (i);
6244
- safe_nonzero_compare .set (i);
6244
+ safe_finite_compare .set (i);
6245
6245
6246
6246
for (u32 j = 0 ; j < 4 ; j++)
6247
6247
{
@@ -6256,7 +6256,7 @@ class spu_llvm_recompiler : public spu_recompiler_base, public cpu_translator
6256
6256
// we don't produce "extended range" values the same way as real hardware, it's not safe to apply
6257
6257
// this optimization for values outside of the range of x86 floating point hardware.
6258
6258
safe_int_compare.reset (i);
6259
- if (!exponent) safe_nonzero_compare .reset (i);
6259
+ if ((value & 0x7fffffffu ) >= 0x7f7ffffeu ) safe_finite_compare .reset (i);
6260
6260
}
6261
6261
}
6262
6262
}
@@ -6267,17 +6267,20 @@ class spu_llvm_recompiler : public spu_recompiler_base, public cpu_translator
6267
6267
return eval (sext<s32[4 ]>(bitcast<s32[4 ]>(a) > bitcast<s32[4 ]>(b)));
6268
6268
}
6269
6269
6270
- const auto ai = eval (bitcast<s32[4 ]>(a));
6271
- const auto bi = eval (bitcast<s32[4 ]>(b));
6272
-
6273
- if (!safe_nonzero_compare.any ())
6270
+ if (safe_finite_compare.test (1 ))
6274
6271
{
6275
- return eval (sext<s32[4 ]>(fcmp_uno (a != b) & select ((ai & bi) >= 0 , ai > bi, ai < bi )));
6272
+ return eval (sext<s32[4 ]>(fcmp_uno (clamp_negative_smax (a) > b )));
6276
6273
}
6277
- else
6274
+
6275
+ if (safe_finite_compare.test (0 ))
6278
6276
{
6279
- return eval (sext<s32[4 ]>(select ((ai & bi) >= 0 , ai > bi, ai < bi )));
6277
+ return eval (sext<s32[4 ]>(fcmp_ord (a > clamp_smax (b) )));
6280
6278
}
6279
+
6280
+ const auto ai = eval (bitcast<s32[4 ]>(a));
6281
+ const auto bi = eval (bitcast<s32[4 ]>(b));
6282
+
6283
+ return eval (sext<s32[4 ]>(fcmp_uno (a != b) & select ((ai & bi) >= 0 , ai > bi, ai < bi)));
6281
6284
});
6282
6285
6283
6286
set_vr (op.rt , fcgt (get_vr<f32[4 ]>(op.ra ), get_vr<f32[4 ]>(op.rb )));
0 commit comments