Daniel Dunbar | 19 Jul 01:34 2008

patch: more builtin support

This patch adds support for __builtin_{ffs[l][l], parity[l][l], popcount[l][l], huge_valf, huge_vall}.
 + test case

nans, powi[fl], prefetch still missing (among others, no doubt).

 - Daniel
// RUN: ccc %s && ./a.out > A
// RUN: gcc %s && ./a.out > B
// RUN: diff A B

#include <stdio.h>

void test(int M, long long N) {
  printf("%d %lld: %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d\n",
         M, N,
         __builtin_ffs(M), __builtin_ffsl(M), __builtin_ffsll(M),
         __builtin_parity(M), __builtin_parityl(M), __builtin_parityll(M),
         __builtin_popcount(M), __builtin_popcountl(M), __builtin_popcountll(M),
         __builtin_ffs(N), __builtin_ffsl(N), __builtin_ffsll(N),
         __builtin_parity(N), __builtin_parityl(N), __builtin_parityll(N),
         __builtin_popcount(N), __builtin_popcountl(N), __builtin_popcountll(N));
}

int main() {
  int i;

  test(-1,-1LL);
  test(0,0);
  test(1,1);
(Continue reading)

Chris Lattner | 20 Jul 02:23 2008
Picon

Re: patch: more builtin support


On Jul 18, 2008, at 4:34 PM, Daniel Dunbar wrote:

> This patch adds support for __builtin_{ffs[l][l], parity[l][l],  
> popcount[l][l], huge_valf, huge_vall}.
> + test case

Looks great to me with one minor change: we don't want the clang  
testsuite to actually execute code.  Please make the test just be  
something like this:

void test(int M, long long N) {
   printf("%d %lld: %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d  
%d\n",
          M, N,
          __builtin_ffs(M), __builtin_ffsl(M), __builtin_ffsll(M),
          __builtin_parity(M), __builtin_parityl(M),  
__builtin_parityll(M),
          __builtin_popcount(M), __builtin_popcountl(M),  
__builtin_popcountll(M),
          __builtin_ffs(N), __builtin_ffsl(N), __builtin_ffsll(N),
          __builtin_parity(N), __builtin_parityl(N),  
__builtin_parityll(N),
          __builtin_popcount(N), __builtin_popcountl(N),  
__builtin_popcountll(N));
}

with: clang -emit-llvm %s | not grep __builtin

or something like that.  The llvm-test suite can be used to verify  
(Continue reading)

Daniel Dunbar | 21 Jul 19:28 2008

Re: patch: more builtin support

> Looks great to me with one minor change: we don't want the clang  
> testsuite to actually execute code.  Please make the test just be  
> something like this: ...

Done. The grep works in this case but this policy is going to be harder
to deal with for other codegen tests -- either the test is going to be very
fragile or just not written.

To take a current example, how do you check that the accesses to the
following bit-field are being compiled correctly without running code:
--
struct {
  _Bool x : 2;
} x;

int foo () {
   return x.x += 1;
}
--

Is running code with lli verboten?

 - Daniel

----- Original Message ----
From: Chris Lattner <clattner@...>
To: Daniel Dunbar <daniel@...>
Cc: cfe-dev@...
Sent: Saturday, July 19, 2008 5:23:26 PM
Subject: Re: [cfe-dev] patch: more builtin support
(Continue reading)

Chris Lattner | 22 Jul 00:27 2008
Picon

Re: patch: more builtin support


On Jul 21, 2008, at 10:28 AM, Daniel Dunbar wrote:

>> Looks great to me with one minor change: we don't want the clang
>> testsuite to actually execute code.  Please make the test just be
>> something like this: ...
>
>
> Done. The grep works in this case but this policy is going to be  
> harder
> to deal with for other codegen tests -- either the test is going to  
> be very
> fragile or just not written.
>
> To take a current example, how do you check that the accesses to the
> following bit-field are being compiled correctly without running code:
> --
> struct {
>  _Bool x : 2;
> } x;
>
> int foo () {
>   return x.x += 1;
> }
> --
>
> Is running code with lli verboten?

I agree that this doesn't make sense to grep for, I just think  
execution tests should go in the llvm-test suite (where llvm-gcc will  
(Continue reading)


Gmane