public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: FX <fxcoudert@gmail.com>
To: gcc@gcc.gnu.org, marc.glisse@inria.fr
Subject: Re: __builtin_clzll and uintmax_t
Date: Sat, 05 Mar 2011 22:05:00 -0000	[thread overview]
Message-ID: <AC5CE0DC-41F9-4DD2-86C4-91C92C5FE222@gmail.com> (raw)

Salut Marc !

> We have a variable of type uintmax_t and want to count the leading zeros. Can we just call __builtin_clzll on it?

Yes.

> In particular, can uintmax_t be larger than unsigned long long in gcc?

uintmax_t is the largest of the standard unsigned C types, so it cannot be larger than unsigned long long. On x86_64, for example:

> #include <stdio.h>
> #include <stdint.h>
> 
> int main (void)
> {
>   printf ("%lu ", sizeof (uintmax_t));
>   printf ("%lu ", sizeof (int));
>   printf ("%lu ", sizeof (long int));
>   printf ("%lu ", sizeof (long long int));
>   printf ("%lu\n", sizeof (__int128));
> }

gives : 8 4 8 8 16


> Is __builtin_clzll available on all platforms?

Yes, we emit calls to this built-in unconditionally in the Fortran front-end, and it has caused no trouble.


FX

             reply	other threads:[~2011-03-05 22:05 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-05 22:05 FX [this message]
2011-03-06  8:57 ` Marc Glisse
2011-03-06 14:52   ` Jakub Jelinek
2011-03-08 12:04     ` Joern Rennecke
  -- strict thread matches above, loose matches on Subject: below --
2011-03-05 21:05 Marc Glisse

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=AC5CE0DC-41F9-4DD2-86C4-91C92C5FE222@gmail.com \
    --to=fxcoudert@gmail.com \
    --cc=gcc@gcc.gnu.org \
    --cc=marc.glisse@inria.fr \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).