Skip to content

Commit c9e93fe

Browse files
Remove broken constant propagation code (for now)
1 parent 32b2d07 commit c9e93fe

File tree

2 files changed

+15
-117
lines changed

2 files changed

+15
-117
lines changed

Python/optimizer_bytecodes.c

Lines changed: 3 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -222,60 +222,15 @@ dummy_func(void) {
222222
}
223223

224224
op(_BINARY_OP_ADD_INT, (left, right -- res)) {
225-
if (sym_is_const(ctx, left) && sym_is_const(ctx, right)) {
226-
assert(PyLong_CheckExact(sym_get_const(ctx, left)));
227-
assert(PyLong_CheckExact(sym_get_const(ctx, right)));
228-
PyObject *temp = _PyCompactLong_Add((PyLongObject *)sym_get_const(ctx, left),
229-
(PyLongObject *)sym_get_const(ctx, right));
230-
if (temp == NULL) {
231-
goto error;
232-
}
233-
res = sym_new_const(ctx, temp);
234-
Py_DECREF(temp);
235-
// TODO gh-115506:
236-
// replace opcode with constant propagated one and add tests!
237-
}
238-
else {
239-
res = sym_new_type(ctx, &PyLong_Type);
240-
}
225+
res = sym_new_type(ctx, &PyLong_Type);
241226
}
242227

243228
op(_BINARY_OP_SUBTRACT_INT, (left, right -- res)) {
244-
if (sym_is_const(ctx, left) && sym_is_const(ctx, right)) {
245-
assert(PyLong_CheckExact(sym_get_const(ctx, left)));
246-
assert(PyLong_CheckExact(sym_get_const(ctx, right)));
247-
PyObject *temp = _PyCompactLong_Subtract((PyLongObject *)sym_get_const(ctx, left),
248-
(PyLongObject *)sym_get_const(ctx, right));
249-
if (temp == NULL) {
250-
goto error;
251-
}
252-
res = sym_new_const(ctx, temp);
253-
Py_DECREF(temp);
254-
// TODO gh-115506:
255-
// replace opcode with constant propagated one and add tests!
256-
}
257-
else {
258-
res = sym_new_type(ctx, &PyLong_Type);
259-
}
229+
res = sym_new_type(ctx, &PyLong_Type);
260230
}
261231

262232
op(_BINARY_OP_MULTIPLY_INT, (left, right -- res)) {
263-
if (sym_is_const(ctx, left) && sym_is_const(ctx, right)) {
264-
assert(PyLong_CheckExact(sym_get_const(ctx, left)));
265-
assert(PyLong_CheckExact(sym_get_const(ctx, right)));
266-
PyObject *temp = _PyCompactLong_Multiply((PyLongObject *)sym_get_const(ctx, left),
267-
(PyLongObject *)sym_get_const(ctx, right));
268-
if (temp == NULL) {
269-
goto error;
270-
}
271-
res = sym_new_const(ctx, temp);
272-
Py_DECREF(temp);
273-
// TODO gh-115506:
274-
// replace opcode with constant propagated one and add tests!
275-
}
276-
else {
277-
res = sym_new_type(ctx, &PyLong_Type);
278-
}
233+
res = sym_new_type(ctx, &PyLong_Type);
279234
}
280235

281236
op(_BINARY_OP_ADD_FLOAT, (left, right -- res)) {

Python/optimizer_cases.c.h

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

0 commit comments

Comments
 (0)