This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Code generation for condition of C branch statement
- From: ÐÐÐÐÐÐ ÐÑÑÐÐÐÐ <1kruglovleonid1 at mail dot ru>
- To: gcc-help at gcc dot gnu dot org
- Date: Tue, 24 May 2016 18:14:33 +0300
- Subject: Code generation for condition of C branch statement
- Authentication-results: sourceware.org; auth=none
- Reply-to: ÐÐÐÐÐÐ ÐÑÑÐÐÐÐ <1kruglovleonid1 at mail dot ru>
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