Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiplication loop motion, extractor fails to find solution #659

Draft
wants to merge 27 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix context bug in ivt
yihozhang authored and oflatt committed Nov 19, 2024
commit b0ce36ea825480951074dc68a764af18de457d0c
33 changes: 14 additions & 19 deletions dag_in_context/src/optimizations/ivt.egg
Original file line number Diff line number Diff line change
@@ -88,45 +88,40 @@

(ContextOf inpW outer-ctx)
(ContextOf inpI if-ctx)
(HasType inpW argW)
(HasType inpI argI)
) (
;; first peeled condition
(let new-if-cond (Subst outer-ctx inpW condI))
;; if contexts
(let new-if-true-ctx (InIf true new-if-cond inpW))
(let new-if-false-ctx (InIf false new-if-cond inpW))
(let new-if-inp (Subst outer-ctx inpW inpI))
(let new-if-true-ctx (InIf true new-if-cond new-if-inp))
(let new-if-false-ctx (InIf false new-if-cond new-if-inp))

(let new-loop-context (TmpCtx))

;; body
(let new-loop-outputs_
(TupleRemoveAt
(ApplyPerm perm (Subst new-loop-context inpI thn))
0))
;; the first element of body was true but should be the condition.
(let new-loop-outputs
(Concat
; (Single (Subst new-loop-context (Arg argW new-loop-context) condI))
(Single (Subst new-loop-context new-loop-outputs_ condI))
new-loop-outputs_))

(let new-loop (DoWhile (Arg argW new-if-true-ctx) new-loop-outputs))
(TupleRemoveAt (ApplyPerm perm thn) 0))
(let new-loop-outputs
(Subst new-loop-context new-loop-outputs_
(Concat (Single condI) inpI)))

(let new-loop (DoWhile (Arg argI new-if-true-ctx) new-loop-outputs))
(let new-if
(If new-if-cond inpW
(If new-if-cond new-if-inp
new-loop
(Arg argW new-if-false-ctx)))
(Arg argI new-if-false-ctx)))

;; Apply the body of the false branch as an afterprocessing wrapper
(let new-expr_
(Subst outer-ctx new-if
(Subst if-ctx inpI els)))
(Subst outer-ctx new-if els))
(let new-expr
(TupleRemoveAt
(ApplyPerm perm new-expr_)
0))

(union new-expr loop)
(union new-loop-context (InLoop (Arg argW new-if-true-ctx) new-loop-outputs))
(union new-loop-context (InLoop (Arg argI new-if-true-ctx) new-loop-outputs))

(delete (DoWhile inpW outW))
(delete (TmpCtx))