qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Torbjorn Granlund <tg@gmplib.org>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] Possible ppc comparision optimisation
Date: Wed, 08 May 2013 00:56:54 +0200	[thread overview]
Message-ID: <86bo8mcsax.fsf@shell.gmplib.org> (raw)

The current ppc gen_op_cmp generates a long sequence of instructions,
using a plain series of three disjoint compares.

It is possible to compute the 3 result bits more cleverly.  Below is a
possible replacement gen_op_cmp.  (It is tested by booting GNU/Linux
ppx64, but not much more than that.)

Surely this should be faster than the old code?  OK, it is less
readable, but cmp is pretty critical and should be made fast.

Should one truncate things using tcg_gen_trunc_tl_i32 and do the add,
xori, addi as i32 variants?  (Why?)

There could be a disadvantage of this compared to the old code, since
this has a chained algebraic dependency, while the old code's many
instructions might have been more independent.

static inline void gen_op_cmp(TCGv arg0, TCGv arg1, int s, int crf)
{
    TCGv t0 = tcg_temp_new();
    TCGv t1 = tcg_temp_new();
    TCGv_i32 s0 = tcg_temp_new_i32();

    tcg_gen_trunc_tl_i32(cpu_crf[crf], cpu_so);

    tcg_gen_setcond_tl((s ? TCG_COND_LE: TCG_COND_LEU), t0, arg0, arg1);
    tcg_gen_setcond_tl((s ? TCG_COND_LT: TCG_COND_LTU), t1, arg0, arg1);
    tcg_gen_add_tl(t0, t0, t1);
    tcg_gen_xori_tl(t0, t0, 1);
    tcg_gen_addi_tl(t0, t0, 1);
    tcg_gen_trunc_tl_i32(s0, t0);
    tcg_gen_shli_i32(s0, s0, 1);
    tcg_gen_or_i32(cpu_crf[crf], cpu_crf[crf], s0);

    tcg_temp_free(t0);
    tcg_temp_free(t1);
    tcg_temp_free_i32(s0);
}

-- 
Torbjörn

             reply	other threads:[~2013-05-07 22:57 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-07 22:56 Torbjorn Granlund [this message]
2013-05-08  8:05 ` [Qemu-devel] Possible ppc comparision optimisation Paolo Bonzini
2013-05-08 15:44   ` Torbjorn Granlund
2013-05-08 16:16     ` Paolo Bonzini

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=86bo8mcsax.fsf@shell.gmplib.org \
    --to=tg@gmplib.org \
    --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).