Quantcast
Viewing all articles
Browse latest Browse all 22016

gcc differences between -O3 vs -Ofast optimizations

I was just reading through the gcc manual to find out the difference between -O3 and -Ofast.

For -O3

-O3

Optimize yet more. -O3 turns on all optimizations specified by -O2 and also turns on the following optimization flags:-fgcse-after-reload -fipa-cp-clone-floop-interchange -floop-unroll-and-jam -fpeel-loops -fpredictive-commoning -fsplit-paths -ftree-loop-distribute-patterns -ftree-loop-distribution -ftree-loop-vectorize -ftree-partial-pre -ftree-slp-vectorize -funswitch-loops -fvect-cost-model -fversion-loops-for-strides

While of -Ofast

-Ofast

Disregard strict standards compliance. -Ofast enables all -O3 optimizations. It also enables optimizations that are not valid for

all standard-compliant programs. It turns on -ffast-math, -fallow-store-data-races and the Fortran-specific -fstack-arrays, unless -fmax-stack-var-size is specified, and -fno-protect-parens

Therefore I was wondering, if maybe -Ofast is for some reason less safe than -O3, and therefore I should stick to -O3 most of the times then.

Can you clarify the "practical difference" when using them? And if -Ofast is actually safe?


Viewing all articles
Browse latest Browse all 22016

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>