All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@domain.hid>
To: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
Cc: Xenomai core <Xenomai-core@domain.hid>
Subject: Re: [Xenomai-core] llimd.
Date: Tue, 28 Oct 2008 22:00:06 +0100	[thread overview]
Message-ID: <49077D56.8040908@domain.hid> (raw)
In-Reply-To: <49076E08.5060708@domain.hid>

Gilles Chanteperdrix wrote:
> Hi Jan,
> 
> I see that the implementation of rthal_llmulshft seems to account for
> the first argument sign. Does it work ? Namely, in the generic
> implementation will __rthal_u96shift propagate the sign bit ?

Yes, this works (given there is no overflow, of course). If you consider
a high word of 0xfffffff0 and a (right) shift of 8, we effectively cut
off all the leading 1s: high << (32-8) = 0xf0000000. But this only works
because we replace a right shift with a left shift (plus some OR'ing
later on). If we had to do a real right shift, we would also have to
take signed vs. unsigned into account (ie. shift in zeros or the sign
bit from the left?).

> 
> If yes, do you see a way llimd could be made to work the same way ? This
> way we would avoid inline ullimd twice in llimd code.

As the basic building block here is a multiplication, we cannot get
around telling apart signed from unsigned (or converting signed into
unsigned): the underlying multiplication logic is different.

But what about this approach:

static inline __attribute__((__const__)) long long
__rthal_generic_llimd (long long op, unsigned m, unsigned d)
{
	int signed = 0;
	long long ret;

	if (op < 0LL) {
		op = -op;
		signed = 1;
	}
	ret = __rthal_generic_ullimd(op, m, d);
	return signed ? -ret : ret;
}

However, I guess writing this in assembly for archs that suffer should
be more efficient.

Jan


  reply	other threads:[~2008-10-28 21:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-28 19:54 [Xenomai-core] llimd Gilles Chanteperdrix
2008-10-28 21:00 ` Jan Kiszka [this message]
2008-10-30 10:02   ` Gilles Chanteperdrix
2008-10-31  8:18     ` Jan Kiszka
2008-10-31 10:05       ` Gilles Chanteperdrix
2008-10-31 10:29         ` Gilles Chanteperdrix
2008-10-31 10:45           ` Gilles Chanteperdrix
2008-10-31 11:26             ` Jan Kiszka

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=49077D56.8040908@domain.hid \
    --to=jan.kiszka@domain.hid \
    --cc=Xenomai-core@domain.hid \
    --cc=gilles.chanteperdrix@xenomai.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.