diff options
author | Brandt Bucher <brandtbucher@microsoft.com> | 2023-03-23 22:25:09 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-23 22:25:09 (GMT) |
commit | 0444ae24875489dc290d8efdb9ee6440ee60dac8 (patch) | |
tree | aaea58348a957d6612899965f7e78256ec1cdc64 /Python/compile.c | |
parent | bd063756b34003c1bc7cacf5b1bd90a409180fb6 (diff) | |
download | cpython-0444ae24875489dc290d8efdb9ee6440ee60dac8.zip cpython-0444ae24875489dc290d8efdb9ee6440ee60dac8.tar.gz cpython-0444ae24875489dc290d8efdb9ee6440ee60dac8.tar.bz2 |
GH-100982: Break up COMPARE_AND_BRANCH (GH-102801)
Diffstat (limited to 'Python/compile.c')
-rw-r--r-- | Python/compile.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/Python/compile.c b/Python/compile.c index 33cd6ca..192deaa 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -2800,6 +2800,15 @@ check_compare(struct compiler *c, expr_ty e) return SUCCESS; } +static const int compare_masks[] = { + [Py_LT] = COMPARISON_LESS_THAN, + [Py_LE] = COMPARISON_LESS_THAN | COMPARISON_EQUALS, + [Py_EQ] = COMPARISON_EQUALS, + [Py_NE] = COMPARISON_NOT_EQUALS, + [Py_GT] = COMPARISON_GREATER_THAN, + [Py_GE] = COMPARISON_GREATER_THAN | COMPARISON_EQUALS, +}; + static int compiler_addcompare(struct compiler *c, location loc, cmpop_ty op) { @@ -2840,7 +2849,7 @@ static int compiler_addcompare(struct compiler *c, location loc, } /* cmp goes in top bits of the oparg, while the low bits are used by quickened * versions of this opcode to store the comparison mask. */ - ADDOP_I(c, loc, COMPARE_OP, cmp << 4); + ADDOP_I(c, loc, COMPARE_OP, (cmp << 4) | compare_masks[cmp]); return SUCCESS; } |