Skip to content

Commit

Permalink
improve float_allocas
Browse files Browse the repository at this point in the history
Co-authored-by: Harry Kalogirou <[email protected]>
  • Loading branch information
charles-cooper and harkal authored Nov 26, 2024
1 parent f6cf277 commit 2e47b73
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions vyper/venom/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,13 +188,16 @@ def float_allocas(self):
if bb is entry_bb:
continue

# "fast" way to strip allocas from each basic block
def is_alloca(inst):
return inst.opcode in ("alloca", "palloca")
# Extract alloca instructions
non_alloca_instructions = []
for inst in bb.instructions:
if inst.opcode in ("alloca", "palloca"):
entry_bb.insert_instruction(inst)
else:
non_alloca_instructions.append(inst)

bb.instructions.sort(key=is_alloca)
while len(bb.instructions) > 0 and is_alloca(bb.instructions[-1]):
entry_bb.insert_instruction(bb.instructions.pop())
# Replace original instructions with filtered list
bb.instructions = non_alloca_instructions

entry_bb.instructions.append(tmp)

Expand Down

0 comments on commit 2e47b73

Please sign in to comment.