qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Dan Hecht <dan.hecht@gmail.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] conditional branch implementation using dyngen labels
Date: Wed, 5 Jan 2005 17:58:13 -0800	[thread overview]
Message-ID: <2e5a35a6050105175820db00e5@mail.gmail.com> (raw)

Hi,

I am wondering why you changed the code generation for conditional
branches (i386) in gen_jcc() to use dyngen labels?  It seems the new
code will be lower performing than the old, since there is an extra
jump instruction along one of the paths.

For example, prior to the recent CVS commit, the code generated for a
conditional jump would be something like:

0x087666ce:  mov    0x2c(%ebp),%eax
0x087666d1:  test   %eax,%eax
0x087666d3:  jne    0x87666ea
0x087666d5:  jmp    0x95e3502
0x087666da:  mov    $0x82e98ac,%ebx
0x087666df:  movl   $0x6ca,0x20(%ebp)
0x087666e6:  jmp    0x87666fb
0x087666e8:  mov    %esi,%esi
0x087666ea:  jmp    0x95e3f26
0x087666ef:  movl   $0x6b3,0x20(%ebp)
0x087666f6:  mov    $0x82e98ad,%ebx
0x087666fb:  ret 

with jmp at 0x087666d5 and 0x087666ea being chained.

Now, the code is something like:

0x08bd2085:  mov    0x2c(%ebp),%eax
0x08bd2088:  test   %eax,%eax
0x08bd208a:  jne    0x8bd2091
0x08bd208c:  jmp    0x8bd20a3
0x08bd2091:  jmp    0x9a4f35d
0x08bd2096:  movl   $0x80555c30,0x20(%ebp)
0x08bd209d:  mov    $0x8406390,%ebx
0x08bd20a2:  ret
0x08bd20a3:  jmp    0x9a4fd8f
0x08bd20a8:  movl   $0x80555c8c,0x20(%ebp)
0x08bd20af:  mov    $0x8406391,%ebx
0x08bd20b4:  ret

with the jmp at 0x08bd2091 and 0x08bd20a3 being chained.  Notice the
extra jmp in the path to the later part of the block.

Locally, I have optimized the i386 to generate something like:

0x087686dd:  cmpl   $0x0,0x2c(%ebp)
0x087686e1:  jne    0x95e7981
0x087686e7:  jmp    0x95e6f5d
0x087686ec:  movl   $0x6ca,0x20(%ebp)
0x087686f3:  mov    $0x82eba54,%ebx
0x087686f8:  ret
0x087686f9:  movl   $0x6b3,0x20(%ebp)
0x08768700:  mov    $0x82eba55,%ebx
0x08768705:  ret 

with the jne at 0x087686e1 and the jmp at 0x087686e7 getting chained,
as an optimization (but haven't had time to clean it up enough to send
in for a patch).  However, this target specific code is harder to
implement with the new broken down micro operations.

So, I'm wondering the reasoning behind this change and if there's
another way I should have gone about implementing this optimization. 
Previously, I just rewrite op_jz_subx, etc all in assembly.

Thanks in advance,
Dan

             reply	other threads:[~2005-01-06  2:10 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-01-06  1:58 Dan Hecht [this message]
2005-01-06 20:05 ` [Qemu-devel] conditional branch implementation using dyngen labels Fabrice Bellard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2e5a35a6050105175820db00e5@mail.gmail.com \
    --to=dan.hecht@gmail.com \
    --cc=dmh23@cornell.edu \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).