8000 Perf: Improved typeprop by switching overwrite -> set (#6) · oraluben/cpython@511c5f0 · GitHub
[go: up one dir, main page]

Skip to content

Commit 511c5f0

authored
Perf: Improved typeprop by switching overwrite -> set (#6)
We can perform type_set if we can guarantee dst is the same type as src.
1 parent a3f3225 commit 511c5f0

File tree

2 files changed

+26
-19
lines changed

2 files changed

+26
-19
lines changed

Python/bytecodes.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ dummy_func(
210210
U_INST(BINARY_OP_MULTIPLY_INT_REST);
211211
}
212212

213-
u_inst(BINARY_OP_MULTIPLY_INT_REST, (left, right -- prod : PyLong_Type)) {
213+
u_inst(BINARY_OP_MULTIPLY_INT_REST, (left, right -- prod : <<= *left)) {
214214
STAT_INC(BINARY_OP, hit);
215215
prod = _PyLong_Multiply((PyLongObject *)left, (PyLongObject *)right);
216216
_Py_DECREF_SPECIALIZED(right, (destructor)PyObject_Free);
@@ -235,7 +235,7 @@ dummy_func(
235235
U_INST(BINARY_OP_SUBTRACT_INT_REST);
236236
}
237237

238-
u_inst(BINARY_OP_SUBTRACT_INT_REST, (left, right -- sub : PyLong_Type)) {
238+
u_inst(BINARY_OP_SUBTRACT_INT_REST, (left, right -- sub : <<= *left)) {
239239
STAT_INC(BINARY_OP, hit);
240240
sub = _PyLong_Subtract((PyLongObject *)left, (PyLongObject *)right);
241241
_Py_DECREF_SPECIALIZED(right, (destructor)PyObject_Free);
@@ -323,19 +323,19 @@ dummy_func(
323323
}
324324
}
325325

326-
inst(BINARY_OP_ADD_FLOAT_UNBOXED, (left, right -- sum : PyRawFloat_Type)) {
326+
inst(BINARY_OP_ADD_FLOAT_UNBOXED, (left, right -- sum : <<= *left)) {
327327
STAT_INC(BINARY_OP, hit);
328328
double temp = *(double *)(&(left)) + *(double *)(&(right));
329329
sum = *(PyObject **)(&temp);
330330
}
331331

332-
inst(BINARY_OP_SUBTRACT_FLOAT_UNBOXED, (left, right -- sum : PyRawFloat_Type)) {
332+
inst(BINARY_OP_SUBTRACT_FLOAT_UNBOXED, (left, right -- sum : <<= *left)) {
333333
STAT_INC(BINARY_OP, hit);
334334
double temp = *(double *)(&(left)) - *(double *)(&(right));
335335
sum = *(PyObject **)(&temp);
336336
}
337337

338-
inst(BINARY_OP_MULTIPLY_FLOAT_UNBOXED, (left, right -- prod : PyRawFloat_Type)) {
338+
inst(BINARY_OP_MULTIPLY_FLOAT_UNBOXED, (left, right -- prod : <<= *left)) {
339339
STAT_INC(BINARY_OP, hit);
340340
double temp = *(double *)(&(left)) * *(double *)(&(right));
341341
prod = *(PyObject **)(&temp);
@@ -364,7 +364,7 @@ dummy_func(
364364
bb_test = BB_TEST(is_successor, 0);
365365
}
366366

367-
u_inst(BINARY_OP_ADD_INT_REST, (left, right -- sum : PyLong_Type)) {
367+
u_inst(BINARY_OP_ADD_INT_REST, (left, right -- sum : <<= *left)) {
368368
STAT_INC(BINARY_OP, hit);
369369
sum = _PyLong_Add((PyLongObject *)left, (PyLongObject *)right);
370370
_Py_DECREF_SPECIALIZED(right, (destructor)PyObject_Free);
@@ -507,12 +507,12 @@ dummy_func(
507507
DISPATCH_INLINED(new_frame);
508508
}
509509

510-
inst(LIST_APPEND, (list, unused[oparg-1], v -- list : PyList_Type, unused[oparg-1])) {
510+
inst(LIST_APPEND, (list, unused[oparg-1], v -- list : <<= PyList_Type, unused[oparg-1])) {
511511
ERROR_IF(_PyList_AppendTakeRef((PyListObject *)list, v) < 0, error);
512512
PREDICT(JUMP_BACKWARD);
513513
}
514514

515-
inst(SET_ADD, (set, unused[oparg-1], v -- set, unused[oparg-1])) {
515+
inst(SET_ADD, (set, unused[oparg-1], v -- set : <<= PySet_Type, unused[oparg-1])) {
516516
int err = PySet_Add(set, v);
517517
DECREF_INPUTS();
518518
ERROR_IF(err, error);
@@ -3232,12 +3232,12 @@ dummy_func(
32323232
ERROR_IF(result == NULL, error);
32333233
}
32343234

3235-
inst(COPY, (bottom, unused[oparg-1] -- bottom, unused[oparg-1], top: *bottom)) {
3235+
inst(COPY, (bottom, unused[oparg-1] -- bottom, unused[oparg-1], top: <<= *bottom)) {
32363236
assert(oparg > 0);
32373237
top = Py_NewRef(bottom);
32383238
}
32393239

3240-
inst(COPY_NO_INCREF, (bottom, unused[oparg - 1] -- bottom, unused[oparg - 1], top: *bottom)) {
3240+
inst(COPY_NO_INCREF, (bottom, unused[oparg - 1] -- bottom, unused[oparg - 1], top: <<= *bottom)) {
32413241
assert(oparg > 0);
32423242
top = bottom;
32433243
}

Python/tier2_typepropagator.c.h

Lines changed: 16 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
0