r/Compilers • u/Repulsive_Egg_5786 • Aug 14 '26
Optimization Question
How do compilers optimize constructs of this form ?
for(i=o; i<inputs; i++) {
A[i] = B[i];
B[i] = A[i];
}
7
Upvotes
r/Compilers • u/Repulsive_Egg_5786 • Aug 14 '26
How do compilers optimize constructs of this form ?
for(i=o; i<inputs; i++) {
A[i] = B[i];
B[i] = A[i];
}
View all comments
Show parent comment
1
u/namalleh Aug 16 '26
It's not even a swap, because there's no temp var
just wasted cycles