Skip to content

Commit

Permalink
work
Browse files Browse the repository at this point in the history
  • Loading branch information
harkal committed Sep 27, 2024
1 parent 918cd5f commit 3d26886
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions vyper/venom/passes/dft.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@ class Group:
group_id: int
dependents: list["Group"]
root: IRInstruction
instruction_count: int
volatile: bool

def __init__(self, group_id: int, root: IRInstruction, volatile: bool):
self.group_id = group_id
self.dependents = []
self.root = root
self.volatile = volatile

self.instruction_count = 1
def __hash__(self) -> int:
return hash(self.group_id)

Expand Down Expand Up @@ -109,11 +110,16 @@ def _walk_group_r(group: Group):
for dep in self.gda.get(g, []):
dep.dependents.append(g)

sorted_groups = sorted(self.groups, key=lambda g: (len(g.dependents), -g.instruction_count))
# print("sorted:")
# for g in sorted_groups:
# print(f"{g.group_id}: {len(g.dependents)} {g.instruction_count}")

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.

groups_visited.add(exit_group)
for g in self.groups:
for g in sorted_groups:
if len(g.dependents) == 0:
_walk_group_r(g)
for g in self.groups:
for g in sorted_groups:
_walk_group_r(g)
groups_visited.remove(exit_group)

Expand Down Expand Up @@ -159,6 +165,7 @@ def mark_group_r(g: Group, instruction: IRInstruction):
if self.inst_groups.get(inst) is not None:
continue
self.inst_groups[inst] = g
g.instruction_count += 1
mark_group_r(g, inst)

for g in self.groups:
Expand Down

0 comments on commit 3d26886

Please sign in to comment.