diff --git a/src/Sema.zig b/src/Sema.zig index a3dccf1d7d..7666b2c9ec 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -15816,6 +15816,13 @@ fn cmpNumeric( if (lhs_val.isUndef() or rhs_val.isUndef()) { return sema.addConstUndef(Type.bool); } + if (lhs_val.isNan() or rhs_val.isNan()) { + if (op == std.math.CompareOperator.neq) { + return Air.Inst.Ref.bool_true; + } else { + return Air.Inst.Ref.bool_false; + } + } if (Value.compareHetero(lhs_val, op, rhs_val)) { return Air.Inst.Ref.bool_true; } else { diff --git a/test/behavior/math.zig b/test/behavior/math.zig index 77820ac0fb..8f947e2829 100644 --- a/test/behavior/math.zig +++ b/test/behavior/math.zig @@ -979,18 +979,16 @@ test "vector integer addition" { } test "NaN comparison" { - if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO - try testNanEqNan(f16); try testNanEqNan(f32); try testNanEqNan(f64); try testNanEqNan(f128); - if (has_f80_rt) try testNanEqNan(f80); + if (has_f80_rt and (builtin.zig_backend == .stage1)) try testNanEqNan(f80); // TODO comptime try testNanEqNan(f16); comptime try testNanEqNan(f32); comptime try testNanEqNan(f64); comptime try testNanEqNan(f128); - // comptime try testNanEqNan(f80); + // comptime try testNanEqNan(f80); // TODO } fn testNanEqNan(comptime F: type) !void {