gh-131798: Optimize _UNARY_INVERT (GH-135222)

This commit is contained in:
Noam Cohen 2025-06-09 13:33:18 +03:00 committed by GitHub
parent c19e36cc4e
commit b150b6aca7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 33 additions and 1 deletions

View file

@ -467,6 +467,15 @@ dummy_func(void) {
res = sym_new_truthiness(ctx, value, false);
}
op(_UNARY_INVERT, (value -- res)) {
if (sym_matches_type(value, &PyLong_Type)) {
res = sym_new_type(ctx, &PyLong_Type);
}
else {
res = sym_new_not_null(ctx);
}
}
op(_COMPARE_OP, (left, right -- res)) {
if (oparg & 16) {
res = sym_new_type(ctx, &PyBool_Type);

View file

@ -285,8 +285,15 @@
}
case _UNARY_INVERT: {
JitOptSymbol *value;
JitOptSymbol *res;
res = sym_new_not_null(ctx);
value = stack_pointer[-1];
if (sym_matches_type(value, &PyLong_Type)) {
res = sym_new_type(ctx, &PyLong_Type);
}
else {
res = sym_new_not_null(ctx);
}
stack_pointer[-1] = res;
break;
}