py/emitnative: Explicitly compare comparison ops in binary_op emitter.

Without this it's possible to get a compiler error about the comparison
always being true, because MP_BINARY_OP_LESS is 0.  And it seems that gcc
optimises these 6 equality comparisons into the same size machine code as
before.
This commit is contained in:
Pepijn de Vos 2023-02-25 17:01:28 +01:00 committed by Damien George
parent 2e4dda3c20
commit 72e9318325

View File

@ -2365,14 +2365,13 @@ STATIC void emit_native_binary_op(emit_t *emit, mp_binary_op_t op) {
} else if (op == MP_BINARY_OP_MULTIPLY) {
ASM_MUL_REG_REG(emit->as, REG_ARG_2, reg_rhs);
emit_post_push_reg(emit, vtype_lhs, REG_ARG_2);
} else if (MP_BINARY_OP_LESS <= op && op <= MP_BINARY_OP_NOT_EQUAL) {
// comparison ops are (in enum order):
// MP_BINARY_OP_LESS
// MP_BINARY_OP_MORE
// MP_BINARY_OP_EQUAL
// MP_BINARY_OP_LESS_EQUAL
// MP_BINARY_OP_MORE_EQUAL
// MP_BINARY_OP_NOT_EQUAL
} else if (op == MP_BINARY_OP_LESS
|| op == MP_BINARY_OP_MORE
|| op == MP_BINARY_OP_EQUAL
|| op == MP_BINARY_OP_LESS_EQUAL
|| op == MP_BINARY_OP_MORE_EQUAL
|| op == MP_BINARY_OP_NOT_EQUAL) {
// comparison ops
if (vtype_lhs != vtype_rhs) {
EMIT_NATIVE_VIPER_TYPE_ERROR(emit, MP_ERROR_TEXT("comparison of int and uint"));