Quantcast
Channel: Kevin Paiva
Viewing all articles
Browse latest Browse all 5

Compiler Options (Lab 3)

$
0
0

I did some research on 2 compiler optimization options provided in GCC. My 2 options were -fassociative-math an -fcompare-elim. The following is what i found:

Regarding -fassociative-math, I found that this option allows the compiler to re-order operands of floating point operations. Now the problem with re-ordering operands is that the compiler can re-order an operand that causes the calculation to report a different result. This violates the ISO C and C++ language standard and makes the feature less likely to be used by most developers. To use fassociative-math you also need to have -fno-signed-zeros and fno-trapping-math in your compilation line. This is very helpful when optimizing arithmetic that does not need to be 100% accurate.

-fcompare-elim uses flags set by the processor on compilation in order to decide whether or not the processor needs to do a comarison. If it does not need to do a comparison it doesn’t bother trying. By default this is enabled at optimization levels: -O -O2 -O3 -Os.

It was very interesting looking through these compiler options and I feel like I understand a little more, exactly what these 2 options do during compilation.


Viewing all articles
Browse latest Browse all 5

Latest Images

Trending Articles



Latest Images