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

Expression expansion doesn't reuse local registers after completed #49

Open
kobbled opened this issue Dec 30, 2022 · 0 comments
Open

Expression expansion doesn't reuse local registers after completed #49

kobbled opened this issue Dec 30, 2022 · 0 comments
Assignees
Labels
optimization Optimize for efficiency

Comments

@kobbled
Copy link
Owner

kobbled commented Dec 30, 2022

e.g.:

local := R[50..90]
a = x1 * (y2 - y3) - y1 * (x2 - x3) + x2 * y3 - x3 * y2
b = (Mth::pow(x1, 2) + Mth::pow(y1, 2)) * (y3 - y2)
c = (Mth::pow(x1, 2) + Mth::pow(y1, 2)) * (x2 - x3)
d = (Mth::pow(x3, 2) + Mth::pow(y3, 2)) * (x2 * y1 - x1 * y2)

expands to this in LS:

 : R[50:a]=(AR[1]*(AR[5]-AR[8])-AR[2]*(AR[4]-AR[7])+AR[4]*AR[8]-AR[7]*AR[5]) ;
 : CALL MTH_POW(AR[1],2,57) ;
 : CALL MTH_POW(AR[2],2,58) ;
 : R[51:b]=((R[57:dvar1]+R[58:dvar2])*(AR[8]-AR[5])) ;
 : CALL MTH_POW(AR[1],2,59) ;
 : CALL MTH_POW(AR[2],2,60) ;
 : R[52:c]=((R[59:dvar3]+R[60:dvar4])*(AR[4]-AR[7])) ;
 : CALL MTH_POW(AR[7],2,61) ;
 : CALL MTH_POW(AR[8],2,62) ;
 : R[53:d]=((R[61:dvar5]+R[62:dvar6])*(AR[4]*AR[2]-AR[1]*AR[5])) ;

After the evaluation of b, the stack counter should be reset to 57. This can be achieved by doing $stack.push/$stack.pop before/after each expression expansion.

@kobbled kobbled added the optimization Optimize for efficiency label Dec 30, 2022
@kobbled kobbled self-assigned this Dec 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
optimization Optimize for efficiency
Projects
None yet
Development

No branches or pull requests

1 participant