File: 208-Fix-near-and-far-jump-target-ordering.patch

package info (click to toggle)
numba 0.56.4%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 23,672 kB
  • sloc: python: 183,651; ansic: 15,370; cpp: 2,259; javascript: 424; sh: 308; makefile: 174
file content (39 lines) | stat: -rw-r--r-- 1,402 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
From b6b0ecf61e69ce8a0b255c2adef002dcacff0215 Mon Sep 17 00:00:00 2001
From: Stuart Archibald <stuartarchibald@users.noreply.github.com>
Origin: https://github.com/numba/numba/pull/8639
Date: Fri, 25 Nov 2022 15:12:12 +0000
Subject: [PATCH 08/20] Fix near and far jump target ordering.

This fixes the true branch to be fall through and the false branch
to be a jump. It seems to fix branch pruning but there's something
strange about it.
---
 numba/core/interpreter.py | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

--- a/numba/core/interpreter.py
+++ b/numba/core/interpreter.py
@@ -2896,14 +2896,16 @@
         self._op_JUMP_IF(inst, pred=pred, iftrue=True)
 
     def _jump_if_none(self, inst, pred, iftrue):
-        brs = {
-            True: inst.get_jump_target(),
-            False: inst.next,
-        }
-        truebr = brs[iftrue]
-        falsebr = brs[not iftrue]
+        # branch pruning assumes true falls through and false is jump
+        truebr = inst.next
+        falsebr = inst.get_jump_target()
+
+        # this seems strange
+        if not iftrue:
+            op = BINOPS_TO_OPERATORS["is"]
+        else:
+            op = BINOPS_TO_OPERATORS["is not"]
 
-        op = BINOPS_TO_OPERATORS["is"]
         rhs = self.store(value=ir.Const(None, loc=self.loc),
                          name=f"$constNone{inst.offset}")
         lhs = self.get(pred)