Are there any options (other than /O2) to improve the Visual C++ code output? The MSDN documentation is quite bad in this regard. Note that I'm not asking about project-wide settings (link-time optimization, etc...). I'm only interested in this particular example.
The fairly simple C++11 code looks like this:
#include <vector>
int main() {
std::vector<int> v = {1, 2, 3, 4};
int sum = 0;
for(int i = 0; i < v.size(); i++) {
sum += v[i];
}
return sum;
}
Clang's output with libc++ is quite compact:
main: # @main
mov eax, 10
ret
Visual C++ output, on the other hand, is a multi-page mess. Am I missing something here or is VS really this bad?
Compiler explorer link: https://godbolt.org/g/GJYHjE
Aucun commentaire:
Enregistrer un commentaire