-
-
Save seunghyukcho/79ef2efdf7124f635d4bf4208922a743 to your computer and use it in GitHub Desktop.
Optimization techniques
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Original code | |
for(i = 0; i < 10; i++) { | |
arr[i] += 5 * i + x * x; | |
} | |
// After code motion optimization | |
int temp = x * x; | |
for(i = 0; i < 10; i++) { | |
arr[i] += 5 * i + temp; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Original code | |
c = 7; | |
for (i = 0; i < N; i++) { | |
y[i] = c * i; | |
} | |
// After strength reduction optimization | |
c = 7; | |
k = 0; | |
for (i = 0; i < N; i++) { | |
y[i] = k; | |
k = k + c; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment