Home > Software engineering >  Does C/C program performance depend on compiler?
Does C/C program performance depend on compiler?

Time:10-15

I read an article in which different compilers were compared to infer which is the best in different circumstances. It gave me a thought. Even though I tried to google, I didn't manage to find a clear and lucid answer: will the program run faster or slower if I use different compilers to compile it? Suppose, it's some uncommon complicated algorithm that is used along with templating.

CodePudding user response:

Yes. The compiler is what writes a program that implements the behavior you've described with your C or C code. Different compilers (or even the same compiler, given different options) can come up with vastly different programs that implement the same behavior.

Remember, your CPU does not execute C or C code. It only executes machine code. There is no defined standard for how the former gets transformed into the latter.

CodePudding user response:

It may depend on the compiler, compiler version, compiler optimization settings, C language version used when compiling, the linker used, linker optimization options and much more. So in short, the answer to your question is Yes.

  • Related