Different bitcode generated by 'save-temps' and '-S -emit-llvm'

I try to generate bitcode from the following two commands.

clang -O3 mic/nbody-align.c -S -emit-llvm
clang -O3 mic/nbody-align.c --save-temps

And the generated bitcodes are different: The first one contains vectorization, but not the second one.
I wonder why this happens, and which passes have been applied to these generated bitcodes?
Thanks in advance.

-save-temps emits the code at different times in the pipeline. The IR (.bc) file is the output of clang before any middle-end optimizations run.
-emit-llvm runs all the middle-end optimizations but not the backend.

-O3 -emit-llvm -Xclang -disable-llvm-optzns is similar to the save-temps results but I would usually recommend the former (for some weird reasons I don’t recall).

Hope this helps.

1 Like