Skip to content

Instantly share code, notes, and snippets.

@kraiskil
Created November 12, 2013 14:32
Show Gist options
  • Save kraiskil/7431748 to your computer and use it in GitHub Desktop.
Save kraiskil/7431748 to your computer and use it in GitHub Desktop.
#!/bin/bash
clang -emit-llvm -S -march=$1 select.cl -o select.ll
clang -march=$1 select.c select.ll -o select
./select
#include <stdio.h>
typedef short short16 __attribute__((__ext_vector_type__(16)));
short16 __attribute__ ((overloadable))
myselect(short16 a, short16 b, short16 c);
/*{
return (c < (short16)0 ? b : a);
}*/
volatile short a=0xa;
volatile short b=0xb;
volatile short c=0xc;
volatile short zero=0x0;
int main(void)
{
short16 av; av.x=a;
short16 bv; bv.x=b;
short16 cv; cv.x=c;
short16 zv; zv.x=zero;
short16 res1 = myselect( av, bv, cv );
short16 res2 = myselect( av, bv, zv );
printf("res1.x=%x, res2.x=%x\n", res1.x, res2.x);
return 0;
}
typedef short short16 __attribute__((__ext_vector_type__(16)));
short16 __attribute__ ((overloadable))
myselect(short16 a, short16 b, short16 c)
{
return (c < (short16)0 ? b : a);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment