This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Code generation for condition of C branch statement


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]