Skip to content

Commit

Permalink
GH-115685: Split _TO_BOOL_ALWAYS_TRUE into micro-ops (GH-116352)
Browse files Browse the repository at this point in the history
  • Loading branch information
markshannon authored Mar 5, 2024
1 parent 0c81ce1 commit 23db9c6
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 44 deletions.
2 changes: 1 addition & 1 deletion Include/internal/pycore_opcode_metadata.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 20 additions & 20 deletions Include/internal/pycore_uop_ids.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Include/internal/pycore_uop_metadata.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 7 additions & 6 deletions Python/bytecodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -382,15 +382,16 @@ dummy_func(
}
}

inst(TO_BOOL_ALWAYS_TRUE, (unused/1, version/2, value -- res)) {
// This one is a bit weird, because we expect *some* failures:
assert(version);
EXIT_IF(Py_TYPE(value)->tp_version_tag != version);
STAT_INC(TO_BOOL, hit);
DECREF_INPUTS();
op(_REPLACE_WITH_TRUE, (value -- res)) {
Py_DECREF(value);
res = Py_True;
}

macro(TO_BOOL_ALWAYS_TRUE) =
unused/1 +
_GUARD_TYPE_VERSION +
_REPLACE_WITH_TRUE;

inst(UNARY_INVERT, (value -- res)) {
res = PyNumber_Invert(value);
DECREF_INPUTS();
Expand Down
7 changes: 1 addition & 6 deletions Python/executor_cases.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 15 additions & 8 deletions Python/generated_cases.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Python/optimizer_analysis.c
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,9 @@ remove_unneeded_uops(_PyUOpInstruction *buffer, int buffer_size)
last->opcode = _NOP;
buffer[pc].opcode = NOP;
}
if (last->opcode == _REPLACE_WITH_TRUE) {
last->opcode = _NOP;
}
break;
}
case _JUMP_TO_TOP:
Expand Down
2 changes: 1 addition & 1 deletion Python/optimizer_cases.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 23db9c6

Please sign in to comment.