Crossware

Table of Contents        Previous topic       Next topic       

C/C++ COMPILER->Compiler command line options->Conditional Branch Elimination (/Ob)

The /Ob option tells the compiler to consider the use of conditionally executable instructions instead of branches.

Branching around a few instructions can have an impact on the instruction pipeline and so can be slower than processing the same instructions but not executing them.

Consider the code generated for the C library abs() function.

With only stack frame pointer elimination enabled, the following code is generated:

    LDR    R0,[R13,#0]
    CMP    R0,#0
    BGE    .@1
    RSB    R0,R0,#0
.@1
    MOV    R15,R14

With stack frame pointer elimination enabled and conditional branch elimination enabled, the following code is generated:

    LDR    R0,[R13,#0]
    CMP    R0,#0
    RSBLT    R0,R0,#0
    MOV    R15,R14

The branch has been removed and the RSB instruction has been replaced with the RSBLT instruction.