Skip to content

Commit 23db9c6

Browse files
authored
GH-115685: Split _TO_BOOL_ALWAYS_TRUE into micro-ops (GH-116352)
1 parent 0c81ce1 commit 23db9c6

8 files changed

+50
-44
lines changed

Include/internal/pycore_opcode_metadata.h

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_uop_ids.h

+20-20
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_uop_metadata.h

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/bytecodes.c

+7-6
Original file line numberDiff line numberDiff line change
@@ -382,15 +382,16 @@ dummy_func(
382382
}
383383
}
384384

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

390+
macro(TO_BOOL_ALWAYS_TRUE) =
391+
unused/1 +
392+
_GUARD_TYPE_VERSION +
393+
_REPLACE_WITH_TRUE;
394+
394395
inst(UNARY_INVERT, (value -- res)) {
395396
res = PyNumber_Invert(value);
396397
DECREF_INPUTS();

Python/executor_cases.c.h

+1-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/generated_cases.c.h

+15-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/optimizer_analysis.c

+3
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,9 @@ remove_unneeded_uops(_PyUOpInstruction *buffer, int buffer_size)
456456
last->opcode = _NOP;
457457
buffer[pc].opcode = NOP;
458458
}
459+
if (last->opcode == _REPLACE_WITH_TRUE) {
460+
last->opcode = _NOP;
461+
}
459462
break;
460463
}
461464
case _JUMP_TO_TOP:

Python/optimizer_cases.c.h

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)