do loads early (#13131)

* do loads early

* local and reg
This commit is contained in:
George Hotz 2025-11-06 09:57:09 -08:00 committed by GitHub
commit 290441dd44
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -22,9 +22,12 @@ def linearize(u:UOp) -> list[UOp]:
# simple priority override
match u.op:
# the order and placement of these is important
case Ops.DEFINE_GLOBAL | Ops.DEFINE_LOCAL | Ops.DEFINE_REG | Ops.DEFINE_VAR: priority = -20
# early consts
case Ops.CONST: priority = -10
# place loads early
#case Ops.LOAD: priority = -1
case Ops.LOAD: priority = -1
# control flow resets priority
case Ops.RANGE|Ops.END|Ops.IF|Ops.ENDIF: priority = 0
# prevent priority inversion