'SSA variables elimination
There is a program which is in SSA form. Is there an algorithm to simplify the program?
For example,
for(int vlc1 = 0; vlc1 < N; vlc1++) {
int v1 = a[vlc1];
int v2 = 100;
int v3 = v1 + v2;
a[vlc1+1] = v3;
}
This example can be simplified to:
for(int vlc1 = 0; vlc1 < N; vlc1++) {
a[vlc1+1] = a[vlc1] + 100;
}
And there is an another example,
int v0 = a[0];
for(int vlc1 = 0; vlc1 < N; vlc1++) {
int v1 = a[vlc1];
int v2 = 100;
int v3 = v1 + v2;
a[vlc1+1] = v3;
}
int v4 = a[0] / v0;
This example can be simplified to:
int v0 = a[0];
for(int vlc1 = 0; vlc1 < N; vlc1++) {
a[vlc1] = a[vlc1+1] + 100;
}
int v4 = a[0] / v0;
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
