探索gcc编译优化细节 编译器优化gcc -o3

int n = count / 2;
for (int i = 0; i < n; ++i) {
    *to = *from++;
}
int n = (count + 7) / 8;
switch (count % 8) {
    case 0: do { *to = *from++; } while (--n > 0);
    case 7: *to = *from++;
    case 6: *to = *from++;
    case 5: *to = *from++;
    case 4: *to = *from++;
    case 3: *to = *from++;
    case 2: *to = *from++;
    case 1: *to = *from++;
} while (--n > 0);

 

 

优化算法

posted @ 2024-07-10 08:56  dafengchui  阅读(4)  评论(0编辑  收藏  举报