Primary:
[Skip To Body]
[Front Door]
[Current]
[Glance]
[Honesty]
[Instructions]
[Links]
[Search]
[Syllabus]
Sets:
[EBoards]
[Examples]
[Exams]
[Handouts]
[Homework]
[Labs]
[Outlines]
[Project]
[Readings]
[Reference]
ECA:
[About]
[Grades]
[Quizzes]
[Submit Work]
[Change Password]
[Reset Password]
Miscellaneous:
[2001S]
[98F]
[SamR]
[Glimmer Labs]
Back to Additional Improvement Techniques. On to Type Inference.
Held Friday, December 6, 2002
Summary
Today we conclude our exploration of code improvement.
Notes
Overview
for i := 1 to n for j := 1 to n A[i,j] := B[j,i];
START_EVERYTHING: MOV $1 i OUTER_LOOP: MOV $1 j INNER_LOOP: # Compute B[j,i] ISUB j $1 -> %T1 IMUL %T1 $4 -> %T2 IMUL %T2 n -> T3 ISUB i $1 -> %T4 IMUL %T4 $4 -> %T5 IADD %T3 %T5 -> %T6 MOV offset(B,%T6) -> %T7 # Compute A[i,j] ISUB i $1 -> %T8 IMUL %T8 $4 -> %T9 IMUL %T9 n -> %T10 ISUB j $1 -> %T11 IMUL %T11 $4 -> %T12 IADD %T10 %T12 -> %T13 MOV %T6 -> offset(A,%T13) JEQ j n END_INNER_LOOP INC j JUMP INNER_LOOP END_INNER_LOOP: JEQ i n END_OUTER_LOOP INC i JUMP OUTER_LOOP END_OUTER_LOOP:
Block 1 START_EVERYTHING: MOV $1 i Block 2 OUTER_LOOP: MOV $1 j Block 3 INNER_LOOP: # Compute B[j,i] ISUB j $1 -> %T1 IMUL %T1 $4 -> %T2 IMUL %T2 n -> T3 ISUB i $1 -> %T4 IMUL %T4 $4 -> %T5 IADD %T3 %T5 -> %T6 MOV offset(B,%T6) -> %T7 # Compute A[i,j] ISUB i $1 -> %T8 IMUL %T8 $4 -> %T9 IMUL %T9 n -> %T10 ISUB j $1 -> %T11 IMUL %T11 $4 -> %T12 IADD %T10 %T12 -> %T13 MOV %T6 -> offset(A,%T13) JEQ j n END_INNER_LOOP Block 4 INC j JUMP INNER_LOOP Block 5 END_INNER_LOOP: JEQ i n END_OUTER_LOOP Block 6 INC i JUMP OUTER_LOOP Block 7 END_OUTER_LOOP:
Block 3 INNER_LOOP: # Compute B[j,i] ISUB j $1 -> %T1 IMUL %T1 $4 -> %T2 IMUL %T2 n -> T3 ISUB i $1 -> %T4 IMUL %T4 $4 -> %T5 IADD %T3 %T5 -> %T6 MOV offset(B,%T6) -> %T7 # Compute A[i,j] MOV %T4 %T8 # ISUB i $1 -> %T8 IMUL %T8 $4 -> %T9 IMUL %T9 n -> %T10 MOV %T1 %T11 # ISUB j $1 -> %T11 IMUL %T11 $4 -> %T12 IADD %T10 %T12 -> %T13 MOV %T6 -> offset(A,%T13) JEQ j n END_INNER_LOOP
Block 3 INNER_LOOP: # Compute B[j,i] ISUB j $1 -> %T1 IMUL %T1 $4 -> %T2 IMUL %T2 n -> T3 ISUB i $1 -> %T4 IMUL %T4 $4 -> %T5 IADD %T3 %T5 -> %T6 MOV offset(B,%T6) -> %T7 # Compute A[i,j] MOV %T4 %T8 # ISUB i $1 -> %T8 IMUL %T4 $4 -> %T9 # IMUL %T8 $4 -> %T9 IMUL %T9 n -> %T10 MOV %T1 %T11 # ISUB j $1 -> %T11 IMUL %T1 $4 -> %T12 # IMUL %T11 $4 -> %T12 IADD %T10 %T12 -> %T13 MOV %T6 -> offset(A,%T13) JEQ j n END_INNER_LOOP
Block 3 INNER_LOOP: # Compute B[j,i] ISUB j $1 -> %T1 IMUL %T1 $4 -> %T2 IMUL %T2 n -> T3 ISUB i $1 -> %T4 IMUL %T4 $4 -> %T5 IADD %T3 %T5 -> %T6 MOV offset(B,%T6) -> %T7 # Compute A[i,j] IMUL %T4 $4 -> %T9 # IMUL %T8 $4 -> %T9 IMUL %T9 n -> %T10 IMUL %T1 $4 -> %T12 # IMUL %T11 $4 -> %T12 IADD %T10 %T12 -> %T13 MOV %T6 -> offset(A,%T13) JEQ j n END_INNER_LOOP
Block 3 INNER_LOOP: # Compute B[j,i] ISUB j $1 -> %T1 IMUL %T1 $4 -> %T2 IMUL %T2 n -> T3 ISUB i $1 -> %T4 IMUL %T4 $4 -> %T5 IADD %T3 %T5 -> %T6 MOV offset(B,%T6) -> %T7 # Compute A[i,j] MOV %T5 %T9 # IMUL %T4 $4 -> %T9 # IMUL %T8 $4 -> %T9 IMUL %T9 n -> %T10 MOV %T2 %T12 # IMUL %T1 $4 -> %T12 # IMUL %T11 $4 -> %T12 IADD %T10 %T12 -> %T13 MOV %T6 -> offset(A,%T13) JEQ j n END_INNER_LOOP
Back to Additional Improvement Techniques. On to Type Inference.
Primary:
[Skip To Body]
[Front Door]
[Current]
[Glance]
[Honesty]
[Instructions]
[Links]
[Search]
[Syllabus]
Sets:
[EBoards]
[Examples]
[Exams]
[Handouts]
[Homework]
[Labs]
[Outlines]
[Project]
[Readings]
[Reference]
ECA:
[About]
[Grades]
[Quizzes]
[Submit Work]
[Change Password]
[Reset Password]
Miscellaneous:
[2001S]
[98F]
[SamR]
[Glimmer Labs]
Disclaimer:
I usually create these pages on the fly
, which means that I rarely
proofread them and they may contain bad grammar and incorrect details.
It also means that I tend to update them regularly (see the history for
more details). Feel free to contact me with any suggestions for changes.
This document was generated by
Siteweaver on Fri Dec 6 10:38:43 2002.
The source to the document was last modified on Wed Sep 4 10:08:38 2002.
This document may be found at http://www.cs.grinnell.edu/~rebelsky/Courses/CS362/2002F/Outlines/outline.39.html
.
You may wish to
validate this document's HTML
;
;
Check with Bobby