Code generation for condition of C branch statement

Леонид Круглов 1kruglovleonid1@mail.ru
Tue May 24 15:14:00 GMT 2016


Hello all,

I would like to find some documentation and corresponding sources covering code generation for condition of branch statements.

In particular, I am interested in the patterns that control the usage of "reversed" conditions (with -O0 option specifed).

Example:
-----------------------------------
C source code:

               if (a != 0) { ... } else { ... }

and 2 different approaches to executable code generation:

               cmp   $0x0,-0x3(%rbp)
               jne     THEN
               ; else-branch
               ...
THEN :   ; then-branch
   
versus "reversed" condition:

               cmp   $0x0,-0x3(%rbp)
               je       ELSE
               ; then-branch
               ...
ELSE :   ; else-branch
-----------------------------------

Thanks in advance.
Leonid


More information about the Gcc-help mailing list