Choose type for integer literals to match the target mask size (if possible).

On a target with a 16-bit mask (for example), we would choose the type
of an integer literal "1024" to be an int16.  Previously, we used an int32,
which is a worse fit and leads to less efficient code than an int16
on a 16-bit mask target.  (However, we'd still give an integer literal
1000000 the type int32, even in a 16-bit target.)

Updated the tests to still pass with 8 and 16-bit targets, given this
change.
This commit is contained in:
Matt Pharr
2013-07-23 17:01:03 -07:00
parent 9ba49eabb2
commit f7f281a256
61 changed files with 166 additions and 120 deletions

27
lex.ll
View File

@@ -77,6 +77,8 @@ static int allTokens[] = {
TOKEN_UNSIGNED, TOKEN_VARYING, TOKEN_VOID, TOKEN_WHILE,
TOKEN_STRING_C_LITERAL, TOKEN_DOTDOTDOT,
TOKEN_FLOAT_CONSTANT,
TOKEN_INT8_CONSTANT, TOKEN_UINT8_CONSTANT,
TOKEN_INT16_CONSTANT, TOKEN_UINT16_CONSTANT,
TOKEN_INT32_CONSTANT, TOKEN_UINT32_CONSTANT,
TOKEN_INT64_CONSTANT, TOKEN_UINT64_CONSTANT,
TOKEN_INC_OP, TOKEN_DEC_OP, TOKEN_LEFT_OP, TOKEN_RIGHT_OP, TOKEN_LE_OP,
@@ -150,6 +152,10 @@ void ParserInit() {
tokenToName[TOKEN_STRING_C_LITERAL] = "\"C\"";
tokenToName[TOKEN_DOTDOTDOT] = "...";
tokenToName[TOKEN_FLOAT_CONSTANT] = "TOKEN_FLOAT_CONSTANT";
tokenToName[TOKEN_INT8_CONSTANT] = "TOKEN_INT8_CONSTANT";
tokenToName[TOKEN_UINT8_CONSTANT] = "TOKEN_UINT8_CONSTANT";
tokenToName[TOKEN_INT16_CONSTANT] = "TOKEN_INT16_CONSTANT";
tokenToName[TOKEN_UINT16_CONSTANT] = "TOKEN_UINT16_CONSTANT";
tokenToName[TOKEN_INT32_CONSTANT] = "TOKEN_INT32_CONSTANT";
tokenToName[TOKEN_UINT32_CONSTANT] = "TOKEN_UINT32_CONSTANT";
tokenToName[TOKEN_INT64_CONSTANT] = "TOKEN_INT64_CONSTANT";
@@ -260,6 +266,10 @@ void ParserInit() {
tokenNameRemap["TOKEN_STRING_C_LITERAL"] = "\"C\"";
tokenNameRemap["TOKEN_DOTDOTDOT"] = "\'...\'";
tokenNameRemap["TOKEN_FLOAT_CONSTANT"] = "float constant";
tokenNameRemap["TOKEN_INT8_CONSTANT"] = "int8 constant";
tokenNameRemap["TOKEN_UINT8_CONSTANT"] = "unsigned int8 constant";
tokenNameRemap["TOKEN_INT16_CONSTANT"] = "int16 constant";
tokenNameRemap["TOKEN_UINT16_CONSTANT"] = "unsigned int16 constant";
tokenNameRemap["TOKEN_INT32_CONSTANT"] = "int32 constant";
tokenNameRemap["TOKEN_UINT32_CONSTANT"] = "unsigned int32 constant";
tokenNameRemap["TOKEN_INT64_CONSTANT"] = "int64 constant";
@@ -599,7 +609,22 @@ lParseInteger(bool dotdotdot) {
}
else {
// No u or l suffix
// First, see if we can fit this into a 32-bit integer...
// If we're compiling to an 8-bit mask target and the constant
// fits into 8 bits, return an 8-bit int.
if (g->target->getMaskBitCount() == 8) {
if (yylval.intVal <= 0x7fULL)
return TOKEN_INT8_CONSTANT;
else if (yylval.intVal <= 0xffULL)
return TOKEN_UINT8_CONSTANT;
}
// And similarly for 16-bit masks and constants
if (g->target->getMaskBitCount() == 16) {
if (yylval.intVal <= 0x7fffULL)
return TOKEN_INT16_CONSTANT;
else if (yylval.intVal <= 0xffffULL)
return TOKEN_UINT16_CONSTANT;
}
// Otherwise, see if we can fit this into a 32-bit integer...
if (yylval.intVal <= 0x7fffffffULL)
return TOKEN_INT32_CONSTANT;
else if (yylval.intVal <= 0xffffffffULL)

View File

@@ -179,6 +179,8 @@ struct ForeachDimension {
}
%token TOKEN_INT8_CONSTANT TOKEN_UINT8_CONSTANT
%token TOKEN_INT16_CONSTANT TOKEN_UINT16_CONSTANT
%token TOKEN_INT32_CONSTANT TOKEN_UINT32_CONSTANT
%token TOKEN_INT64_CONSTANT TOKEN_UINT64_CONSTANT
%token TOKEN_INT32DOTDOTDOT_CONSTANT TOKEN_UINT32DOTDOTDOT_CONSTANT
@@ -291,6 +293,22 @@ primary_expression
Error(@1, "Undeclared symbol \"%s\".%s", name, alts.c_str());
}
}
| TOKEN_INT8_CONSTANT {
$$ = new ConstExpr(AtomicType::UniformInt8->GetAsConstType(),
(int8_t)yylval.intVal, @1);
}
| TOKEN_UINT8_CONSTANT {
$$ = new ConstExpr(AtomicType::UniformUInt8->GetAsConstType(),
(uint8_t)yylval.intVal, @1);
}
| TOKEN_INT16_CONSTANT {
$$ = new ConstExpr(AtomicType::UniformInt16->GetAsConstType(),
(int16_t)yylval.intVal, @1);
}
| TOKEN_UINT16_CONSTANT {
$$ = new ConstExpr(AtomicType::UniformUInt16->GetAsConstType(),
(uint16_t)yylval.intVal, @1);
}
| TOKEN_INT32_CONSTANT {
$$ = new ConstExpr(AtomicType::UniformInt32->GetAsConstType(),
(int32_t)yylval.intVal, @1);
@@ -1233,7 +1251,10 @@ declarator
;
int_constant
: TOKEN_INT32_CONSTANT { $$ = yylval.intVal; }
: TOKEN_INT8_CONSTANT { $$ = yylval.intVal; }
| TOKEN_INT16_CONSTANT { $$ = yylval.intVal; }
| TOKEN_INT32_CONSTANT { $$ = yylval.intVal; }
| TOKEN_INT64_CONSTANT { $$ = yylval.intVal; }
;
direct_declarator

View File

@@ -37,7 +37,7 @@ parser.add_option("-g", "--generics-include", dest="include_file", help="Filenam
parser.add_option("-f", "--ispc-flags", dest="ispc_flags", help="Additional flags for ispc (-g, -O1, ...)",
default="")
parser.add_option('-t', '--target', dest='target',
help='Set compilation target (neon, sse2, sse2-x2, sse4, sse4-x2, avx, avx-x2, generic-4, generic-8, generic-16, generic-32)',
help='Set compilation target (neon, sse2, sse2-x2, sse4, sse4-x2, sse4-8, avx, avx-x2, generic-4, generic-8, generic-16, generic-32)',
default="sse4")
parser.add_option('-a', '--arch', dest='arch',
help='Set architecture (arm, x86, x86-64)',
@@ -294,7 +294,7 @@ def run_test(testname):
firstline = firstline.rstrip()
file.close()
if (output.find(firstline) == -1):
if re.search(firstline, output) == None:
sys.stderr.write("Didn't see expected error message %s from test %s.\nActual output:\n%s\n" % \
(firstline, testname, output))
return (1, 0)

View File

@@ -3126,7 +3126,7 @@ static inline void __range_reduce_log(float input, varying float * uniform reduc
static const int nonexponent_mask = 0x807FFFFF;
// We want the reduced version to have an exponent of -1 which is -1 + 127 after biasing or 126
static const int exponent_neg1 = (126 << 23);
static const int exponent_neg1 = (126l << 23);
// NOTE(boulos): We don't need to mask anything out since we know
// the sign bit has to be 0. If it's 1, we need to return infinity/nan
// anyway (log(x), x = +-0 -> infinity, x < 0 -> NaN).
@@ -3149,7 +3149,7 @@ static inline void __range_reduce_log(uniform float input, uniform float * unifo
uniform int int_version = intbits(input);
static const uniform int nonexponent_mask = 0x807FFFFF;
static const uniform int exponent_neg1 = (126 << 23);
static const uniform int exponent_neg1 = (126ul << 23);
uniform int biased_exponent = int_version >> 23;
uniform int offset_exponent = biased_exponent + 1;
*exponent = offset_exponent - 127; // get the real value
@@ -3647,18 +3647,18 @@ static inline uniform float half_to_float(uniform unsigned int16 h) {
else {
// https://gist.github.com/2144712
// Fabian "ryg" Giesen.
static const uniform unsigned int32 shifted_exp = 0x7c00 << 13; // exponent mask after shift
static const uniform unsigned int32 shifted_exp = 0x7c00ul << 13; // exponent mask after shift
uniform int32 o = ((int32)(h & 0x7fff)) << 13; // exponent/mantissa bits
uniform unsigned int32 exp = shifted_exp & o; // just the exponent
o += (127 - 15) << 23; // exponent adjust
o += (uniform int32)(127 - 15) << 23; // exponent adjust
// handle exponent special cases
if (exp == shifted_exp) // Inf/NaN?
o += (128 - 16) << 23; // extra exp adjust
o += (uniform unsigned int32)(128 - 16) << 23; // extra exp adjust
else if (exp == 0) { // Zero/Denormal?
o += 1 << 23; // extra exp adjust
o = intbits(floatbits(o) - floatbits(113 << 23)); // renormalize
o += 1ul << 23; // extra exp adjust
o = intbits(floatbits(o) - floatbits(113ul << 23)); // renormalize
}
o |= ((int32)(h & 0x8000)) << 16; // sign bit
@@ -3675,17 +3675,17 @@ static inline float half_to_float(unsigned int16 h) {
// https://gist.github.com/2144712
// Fabian "ryg" Giesen.
const unsigned int32 shifted_exp = 0x7c00 << 13; // exponent mask after shift
const unsigned int32 shifted_exp = 0x7c00ul << 13; // exponent mask after shift
int32 o = ((int32)(h & 0x7fff)) << 13; // exponent/mantissa bits
int32 o = ((int32)(h & 0x7ffful)) << 13; // exponent/mantissa bits
unsigned int32 exp = shifted_exp & o; // just the exponent
o += (127 - 15) << 23; // exponent adjust
o += (int32)(127 - 15) << 23; // exponent adjust
int32 infnan_val = o + ((128 - 16) << 23);
int32 zerodenorm_val = intbits(floatbits(o + (1<<23)) - floatbits(113 << 23));
int32 infnan_val = o + ((int32)(128 - 16) << 23);
int32 zerodenorm_val = intbits(floatbits(o + (1ul<<23)) - floatbits(113ul << 23));
int32 reg_val = (exp == 0) ? zerodenorm_val : o;
int32 sign_bit = ((int32)(h & 0x8000)) << 16;
int32 sign_bit = ((int32)(h & 0x8000ul)) << 16;
return floatbits(((exp == shifted_exp) ? infnan_val : reg_val) | sign_bit);
}
}
@@ -3715,16 +3715,16 @@ static inline uniform int16 float_to_half(uniform float f) {
// NaN->qNaN and Inf->Inf
// unconditional assignment here, will override with right value for
// the regular case below.
uniform int32 f32infty = 255 << 23;
o = (fint > f32infty) ? 0x7e00 : 0x7c00;
uniform int32 f32infty = 255ul << 23;
o = (fint > f32infty) ? 0x7e00u : 0x7c00u;
// (De)normalized number or zero
// update fint unconditionally to save the blending; we don't need it
// anymore for the Inf/NaN case anyway.
const uniform unsigned int32 round_mask = ~0xfffu;
const uniform int32 magic = 15 << 23;
const uniform int32 f16infty = 31 << 23;
const uniform unsigned int32 round_mask = ~0xffful;
const uniform int32 magic = 15ul << 23;
const uniform int32 f16infty = 31ul << 23;
uniform int32 fint2 = intbits(floatbits(fint & round_mask) * floatbits(magic)) - round_mask;
fint2 = (fint2 > f16infty) ? f16infty : fint2; // Clamp to signed infinity if overflowed
@@ -3761,16 +3761,16 @@ static inline int16 float_to_half(float f) {
// NaN->qNaN and Inf->Inf
// unconditional assignment here, will override with right value for
// the regular case below.
int32 f32infty = 255 << 23;
o = (fint > f32infty) ? 0x7e00 : 0x7c00;
int32 f32infty = 255ul << 23;
o = (fint > f32infty) ? 0x7e00u : 0x7c00u;
// (De)normalized number or zero
// update fint unconditionally to save the blending; we don't need it
// anymore for the Inf/NaN case anyway.
const unsigned int32 round_mask = ~0xfffu;
const int32 magic = 15 << 23;
const int32 f16infty = 31 << 23;
const unsigned int32 round_mask = ~0xffful;
const int32 magic = 15ul << 23;
const int32 f16infty = 31ul << 23;
// Shift exponent down, denormalize if necessary.
// NOTE This represents half-float denormals using single precision denormals.
@@ -3789,7 +3789,7 @@ static inline int16 float_to_half(float f) {
// FP16 denormals are rare in practice, I don't know. Whatever slow path your HW
// may or may not have for denormals, this may well hit it.
float fscale = floatbits(fint & round_mask) * floatbits(magic);
fscale = min(fscale, floatbits((31 << 23) - 0x1000));
fscale = min(fscale, floatbits((31ul << 23) - 0x1000ul));
int32 fint2 = intbits(fscale) - round_mask;
if (fint < f32infty)
@@ -3956,7 +3956,7 @@ float_to_srgb8(float inval)
// Do the table lookup and unpack bias, scale
unsigned int tab = table[(intbits(inval) - 0x39000000u) >> 20];
unsigned int bias = (tab >> 16) << 9;
unsigned int scale = tab & 0xffff;
unsigned int scale = tab & 0xfffful;
// Grab next-highest mantissa bits and perform linear interpolation
unsigned int t = (intbits(inval) >> 12) & 0xff;
@@ -4006,7 +4006,7 @@ float_to_srgb8(uniform float inval)
// Do the table lookup and unpack bias, scale
uniform unsigned int tab = table[(intbits(inval) - 0x39000000u) >> 20];
uniform unsigned int bias = (tab >> 16) << 9;
uniform unsigned int scale = tab & 0xffff;
uniform unsigned int scale = tab & 0xfffful;
// Grab next-highest mantissa bits and perform linear interpolation
uniform unsigned int t = (intbits(inval) >> 12) & 0xff;
@@ -4053,14 +4053,14 @@ static inline uniform unsigned int random(uniform RNGState * uniform state)
static inline float frandom(varying RNGState * uniform state)
{
unsigned int irand = random(state);
irand &= (1<<23)-1;
irand &= (1ul<<23)-1;
return floatbits(0x3F800000 | irand)-1.0f;
}
static inline uniform float frandom(uniform RNGState * uniform state)
{
uniform unsigned int irand = random(state);
irand &= (1<<23)-1;
irand &= (1ul<<23)-1;
return floatbits(0x3F800000 | irand)-1.0f;
}
@@ -4068,18 +4068,18 @@ static inline void seed_rng(varying RNGState * uniform state,
unsigned int seed) {
state->z1 = seed;
state->z2 = seed ^ 0xbeeff00d;
state->z3 = ((seed & 0xffff) << 16) | (seed >> 16);
state->z4 = (((seed & 0xff) << 24) | ((seed & 0xff00) << 8) |
((seed & 0xff0000) >> 8) | (seed & 0xff000000) >> 24);
state->z3 = ((seed & 0xfffful) << 16) | (seed >> 16);
state->z4 = (((seed & 0xfful) << 24) | ((seed & 0xff00ul) << 8) |
((seed & 0xff0000ul) >> 8) | (seed & 0xff000000ul) >> 24);
}
static inline void seed_rng(uniform RNGState * uniform state,
uniform unsigned int seed) {
state->z1 = seed;
state->z2 = seed ^ 0xbeeff00d;
state->z3 = ((seed & 0xffff) << 16) | (seed >> 16);
state->z4 = (((seed & 0xff) << 24) | ((seed & 0xff00) << 8) |
((seed & 0xff0000) >> 8) | (seed & 0xff000000) >> 24);
state->z3 = ((seed & 0xfffful) << 16) | (seed >> 16);
state->z4 = (((seed & 0xfful) << 24) | ((seed & 0xff00ul) << 8) |
((seed & 0xff0000ul) >> 8) | (seed & 0xff000000ul) >> 24);
}
@@ -4097,7 +4097,7 @@ static inline uniform bool rdrand(float * uniform ptr) {
uniform int32 irand;
uniform bool success = __rdrand_i32(&irand);
if (success) {
irand &= (1<<23)-1;
irand &= (1ul<<23)-1;
*ptr = floatbits(0x3F800000 | irand)-1.0f;
}
return success;
@@ -4117,7 +4117,7 @@ static inline bool rdrand(varying float * uniform ptr) {
// in vector form. However, we need to be careful to not
// clobber any existing already-set values in *ptr with
// inactive lanes here...
irand &= (1<<23)-1;
irand &= (1ul<<23)-1;
*ptr = floatbits(0x3F800000 | irand)-1.0f;
success = true;
}
@@ -4137,7 +4137,7 @@ static inline bool rdrand(float * ptr) {
foreach_active (index) {
uniform int32 irand;
if (__rdrand_i32(&irand)) {
irand &= (1<<23)-1;
irand &= (1ul<<23)-1;
*ptrs[index] = floatbits(0x3F800000 | irand)-1.0f;
success = true;
}

View File

@@ -2,8 +2,8 @@
export uniform int width() { return programCount; }
export void f_v(uniform float RET[]) {
#define width 3
#define maxProgramCount 64
#define width 3ul
#define maxProgramCount 64ul
assert(programCount <= maxProgramCount);
//CO const uniform int width = 3;

View File

@@ -2,8 +2,8 @@
export uniform int width() { return programCount; }
export void f_v(uniform float RET[]) {
#define width 4
#define maxProgramCount 64
#define width 4ul
#define maxProgramCount 64ul
assert(programCount <= maxProgramCount);
//CO const uniform int width = 4;

View File

@@ -2,8 +2,8 @@
export uniform int width() { return programCount; }
export void f_v(uniform float RET[]) {
#define width 3
#define maxProgramCount 64
#define width 3ul
#define maxProgramCount 64ul
assert(programCount <= maxProgramCount);
//CO const uniform int width = 3;

View File

@@ -2,8 +2,8 @@
export uniform int width() { return programCount; }
export void f_v(uniform float RET[]) {
#define width 4
#define maxProgramCount 64
#define width 4ul
#define maxProgramCount 64ul
assert(programCount <= maxProgramCount);
//CO const uniform int width = 4;

View File

@@ -7,7 +7,7 @@ export void f_f(uniform float RET[], uniform float aFOO[]) {
float a = aFOO[programIndex];
float b = 0;
if (programIndex < 30 && programIndex & 1)
b = atomic_or_global(&s, (1 << programIndex));
b = atomic_or_global(&s, (1ul << programIndex));
RET[programIndex] = s;
}
@@ -15,6 +15,6 @@ export void result(uniform float RET[]) {
uniform int sum = 0;
for (uniform int i = 0; i < min(30, programCount); ++i)
if (i & 1)
sum += (1 << i);
sum += (1ul << i);
RET[programIndex] = sum;
}

View File

@@ -7,7 +7,7 @@ export void f_f(uniform float RET[], uniform float aFOO[]) {
float a = aFOO[programIndex];
int32 b = 0;
if (programIndex < 32 && programIndex & 1)
b = atomic_or_global(&s, (1 << programIndex));
b = atomic_or_global(&s, (1ul << programIndex));
RET[programIndex] = popcnt(reduce_max((int32)b));
}

View File

@@ -5,10 +5,10 @@ uniform int32 s = 0;
export void f_f(uniform float RET[], uniform float aFOO[]) {
float a = aFOO[programIndex];
float b = atomic_or_global(&s, (1<<min(programIndex,30)));
float b = atomic_or_global(&s, (1ul<<min(programIndex,30)));
RET[programIndex] = s;
}
export void result(uniform float RET[]) {
RET[programIndex] = (1<<min(programCount,31))-1;
RET[programIndex] = (1ul<<min(programCount,31))-1;
}

View File

@@ -2,8 +2,8 @@
export uniform int width() { return programCount; }
export void f_f(uniform float RET[], uniform float aFOO[]) {
uniform float * uniform buf = uniform new uniform float[32*32];
for (uniform int i = 0; i < 32*32; ++i)
uniform float * uniform buf = uniform new uniform float[32l*32l];
for (uniform int i = 0; i < 32l*32l; ++i)
buf[i] = i;
assert(programIndex <= 64);

View File

@@ -2,8 +2,8 @@
export uniform int width() { return programCount; }
export void f_f(uniform float RET[], uniform float aFOO[]) {
uniform float * uniform buf = uniform new uniform float[32*32];
for (uniform int i = 0; i < 32*32; ++i)
uniform float * uniform buf = uniform new uniform float[32l*32l];
for (uniform int i = 0; i < 32l*32l; ++i)
buf[i] = i;
RET[programIndex] = buf[programIndex & 1];

View File

@@ -2,8 +2,8 @@
export uniform int width() { return programCount; }
export void f_f(uniform float RET[], uniform float aFOO[]) {
uniform float * uniform buf = uniform new uniform float[32*32];
for (uniform int i = 0; i < 32*32; ++i)
uniform float * uniform buf = uniform new uniform float[32l*32l];
for (uniform int i = 0; i < 32l*32l; ++i)
buf[i] = i;
RET[programIndex] = buf[(programIndex >> 2) * 16 + (programIndex & 3)];

View File

@@ -2,8 +2,8 @@
export uniform int width() { return programCount; }
export void f_f(uniform float RET[], uniform float aFOO[]) {
uniform float * uniform buf = uniform new uniform float[32*32];
for (uniform int i = 0; i < 32*32; ++i)
uniform float * uniform buf = uniform new uniform float[32l*32l];
for (uniform int i = 0; i < 32l*32l; ++i)
buf[i] = i;
float a = buf[2*programIndex];

View File

@@ -2,8 +2,8 @@
export uniform int width() { return programCount; }
export void f_f(uniform float RET[], uniform float aFOO[]) {
uniform float * uniform buf = uniform new uniform float[32*32];
for (uniform int i = 0; i < 32*32; ++i)
uniform float * uniform buf = uniform new uniform float[32l*32l];
for (uniform int i = 0; i < 32l*32l; ++i)
buf[i] = i;
float a = buf[4*programIndex];

View File

@@ -2,8 +2,8 @@
export uniform int width() { return programCount; }
export void f_f(uniform float RET[], uniform float aFOO[]) {
uniform float * uniform buf = uniform new uniform float[32*32];
for (uniform int i = 0; i < 32*32; ++i)
uniform float * uniform buf = uniform new uniform float[32l*32l];
for (uniform int i = 0; i < 32l*32l; ++i)
buf[i] = i;
float a = buf[4*programIndex];

View File

@@ -2,8 +2,8 @@
export uniform int width() { return programCount; }
export void f_f(uniform float RET[], uniform float aFOO[]) {
uniform float * uniform buf = uniform new uniform float[32*32];
for (uniform int i = 0; i < 32*32; ++i)
uniform float * uniform buf = uniform new uniform float[32l*32l];
for (uniform int i = 0; i < 32l*32l; ++i)
buf[i] = i;
float a = buf[4*programIndex];

View File

@@ -2,8 +2,8 @@
export uniform int width() { return programCount; }
export void f_f(uniform float RET[], uniform float aFOO[]) {
uniform float * uniform buf = uniform new uniform float[32*32];
for (uniform int i = 0; i < 32*32; ++i)
uniform float * uniform buf = uniform new uniform float[32l*32l];
for (uniform int i = 0; i < 32l*32l; ++i)
buf[i] = i;
int index = (programIndex < 4) ? (programIndex & 1) :

View File

@@ -3,7 +3,7 @@ export uniform int width() { return programCount; }
export void f_f(uniform float RET[], uniform float aFOO[]) {
RET[programIndex] = count_trailing_zeros(0xf0);
RET[programIndex] = count_trailing_zeros(0xf0ul);
}
export void result(uniform float RET[]) {

View File

@@ -3,7 +3,7 @@ export uniform int width() { return programCount; }
export void f_f(uniform float RET[], uniform float aFOO[]) {
int32 i = (1 << (programIndex % 28));
int32 i = (1ul << (programIndex % 28));
RET[programIndex] = count_leading_zeros(i);
}

View File

@@ -3,7 +3,7 @@ export uniform int width() { return programCount; }
export void f_f(uniform float RET[], uniform float aFOO[]) {
RET[programIndex] = -1;
int32 a = ~(1 << programIndex);
int32 a = ~(1ul << programIndex);
if ((programIndex < 32) && (programIndex & 1) == 0) {
RET[programIndex] = exclusive_scan_and(a);
}
@@ -15,7 +15,7 @@ export void result(uniform float RET[]) {
if ((programIndex & 1) == 0 && programIndex > 0 && programIndex < 32) {
int val = 0xffffffff;
for (int i = 0; i < programIndex-1; i += 2)
val &= ~(1<<i);
val &= ~(1ul<<i);
RET[programIndex] = val;
}
}

View File

@@ -3,11 +3,11 @@ export uniform int width() { return programCount; }
export void f_f(uniform float RET[], uniform float aFOO[]) {
RET[programIndex] = -1;
int32 a = (1 << (min(programIndex, 30)));
int32 a = (1ul << (min(programIndex, 30)));
RET[programIndex] = exclusive_scan_or(a);
}
export void result(uniform float RET[]) {
RET[programIndex] = (1 << (min(programIndex, 31))) - 1;
RET[programIndex] = (1ul << (min(programIndex, 31))) - 1;
}

View File

@@ -3,7 +3,7 @@ export uniform int width() { return programCount; }
export void f_f(uniform float RET[], uniform float aFOO[]) {
double a = (1<< (programIndex % 28)) * 1.5;
double a = (1ul<< (programIndex % 28)) * 1.5;
if (programIndex & 1)
a = -a;
int exponent;

View File

@@ -3,7 +3,7 @@ export uniform int width() { return programCount; }
export void f_f(uniform float RET[], uniform float aFOO[]) {
double a = (1<< (programIndex%28)) * 1.5;
double a = (1ul << (programIndex%28)) * 1.5;
if (programIndex & 1)
a = -a;
int exponent;

View File

@@ -3,7 +3,7 @@ export uniform int width() { return programCount; }
export void f_f(uniform float RET[], uniform float aFOO[]) {
float a = (1<< (programIndex%28)) * 1.5;
float a = (1ul << (programIndex%28)) * 1.5;
if (programIndex & 1)
a = -a;
int exponent;

View File

@@ -3,7 +3,7 @@ export uniform int width() { return programCount; }
export void f_f(uniform float RET[], uniform float aFOO[]) {
float a = (1<< (programIndex%28)) * 1.5;
float a = (1ul << (programIndex%28)) * 1.5;
if (programIndex & 1)
a = -a;
int exponent;

View File

@@ -8,5 +8,5 @@ export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
}
export void result(uniform float RET[]) {
RET[programIndex] = 2*1024*1024 + 5;
RET[programIndex] = 2ul*1024ul*1024ul + 5;
}

View File

@@ -3,7 +3,7 @@ export uniform int width() { return programCount; }
export void f_f(uniform float RET[], uniform float aFOO[]) {
double a = 1 << (programIndex % 28);
double a = 1ul << (programIndex % 28);
if (programIndex & 1)
a = -a;
RET[programIndex] = ldexp(a, 2);
@@ -11,7 +11,7 @@ export void f_f(uniform float RET[], uniform float aFOO[]) {
export void result(uniform float RET[]) {
int pi = programIndex % 28;
RET[programIndex] = (1 << (pi + 2));
RET[programIndex] = (1ul << (pi + 2));
if (programIndex & 1)
RET[programIndex] = -RET[programIndex];
}

View File

@@ -3,7 +3,7 @@ export uniform int width() { return programCount; }
export void f_f(uniform float RET[], uniform float aFOO[]) {
float a = 1 << (programIndex % 28);
float a = 1ul << (programIndex % 28);
if (programIndex & 1)
a = -a;
RET[programIndex] = ldexp(a, 2);
@@ -11,7 +11,7 @@ export void f_f(uniform float RET[], uniform float aFOO[]) {
export void result(uniform float RET[]) {
int pi = programIndex % 28;
RET[programIndex] = (1 << (pi + 2));
RET[programIndex] = (1ul << (pi + 2));
if (programIndex & 1)
RET[programIndex] = -RET[programIndex];
}

View File

@@ -7,7 +7,7 @@ export void f_f(uniform float RET[], uniform float aFOO[]) {
float a = aFOO[programIndex];
float b = 0;
if (programIndex < 29 && (programIndex & 1))
b = atomic_or_local(&s, (1 << programIndex));
b = atomic_or_local(&s, (1ul << programIndex));
RET[programIndex] = s;
}
@@ -15,6 +15,6 @@ export void result(uniform float RET[]) {
uniform int sum = 0;
for (uniform int i = 0; i < min(programCount, 29); ++i)
if (i & 1)
sum += (1 << i);
sum += (1ul << i);
RET[programIndex] = sum;
}

View File

@@ -7,7 +7,7 @@ export void f_f(uniform float RET[], uniform float aFOO[]) {
float a = aFOO[programIndex];
int32 b = 0;
if (programIndex < 28 && (programIndex & 1))
b = atomic_or_local(&s, (1 << programIndex));
b = atomic_or_local(&s, (1ul << programIndex));
RET[programIndex] = popcnt(reduce_max(b));
}

View File

@@ -7,7 +7,7 @@ export void f_f(uniform float RET[], uniform float aFOO[]) {
float a = aFOO[programIndex];
float b = 0;
if (programIndex < 32 && (programIndex & 1))
b = atomic_or_local(&s, (1 << programIndex));
b = atomic_or_local(&s, (1ul << programIndex));
RET[programIndex] = (s>>20);
}
@@ -15,6 +15,6 @@ export void result(uniform float RET[]) {
uniform int sum = 0;
for (uniform int i = 0; i < min(32, programCount); ++i)
if (i & 1)
sum += (1 << i);
sum += (1ul << i);
RET[programIndex] = ((unsigned int64)(0xffffffffff000000 | sum)) >> 20;
}

View File

@@ -7,10 +7,10 @@ export void f_f(uniform float RET[], uniform float aFOO[]) {
float a = aFOO[programIndex];
float b = 0;
if (programIndex < 29)
atomic_or_local(&s, (1<<programIndex));
atomic_or_local(&s, (1ul<<programIndex));
RET[programIndex] = s;
}
export void result(uniform float RET[]) {
RET[programIndex] = (1<<min(29,programCount))-1;
RET[programIndex] = (1ul<<min(29,programCount))-1;
}

View File

@@ -11,7 +11,7 @@ export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
for (uniform int i = 0; i < iters; ++i) {
unsigned int val = random(&state);
for (uniform int j = 0; j < 32; ++j) {
if (val & (1<<j))
if (val & (1ul<<j))
++count[j];
}
}

View File

@@ -2,7 +2,7 @@
export uniform int width() { return programCount; }
export void f_f(uniform float RET[], uniform float aFOO[]) {
RET[programIndex] = sizeof 1;
RET[programIndex] = sizeof 1u;
}
export void result(uniform float RET[]) {

View File

@@ -6,7 +6,7 @@ float f(int i) { return i + 1.; }
float f(float v) { return 2 * v; }
export void f_f(uniform float RET[], uniform float aFOO[]) {
float a = aFOO[programIndex];
RET[programIndex] = f(a) + f(10);
RET[programIndex] = f(a) + f(10l);
}
export void result(uniform float RET[]) {

View File

@@ -6,7 +6,7 @@ float f(float v) { return 2 * v; }
float f(int i) { return i + 1.; }
export void f_f(uniform float RET[], uniform float aFOO[]) {
float a = aFOO[programIndex];
RET[programIndex] = f(a) + f(10);
RET[programIndex] = f(a) + f(10l);
}
export void result(uniform float RET[]) {

View File

@@ -8,7 +8,7 @@ float f(float a, int b) { return a + b; }
float f(int i) { return i + 1.; }
export void f_f(uniform float RET[], uniform float aFOO[]) {
float a = aFOO[programIndex];
RET[programIndex] = f(a) + f() + f(a, a) + f(10);
RET[programIndex] = f(a) + f() + f(a, a) + f(10l);
}
export void result(uniform float RET[]) {

View File

@@ -1,4 +1,4 @@
// Illegal to assign to array type "varying float[5]"
// Illegal to assign to array type "varying float\[5\]"
void foo(float *x) {
float a[5] = { 1,2,3,4,5};

View File

@@ -1,4 +1,4 @@
// Illegal to assign to array type "varying float[5]"
// Illegal to assign to array type "varying float\[5\]"
void foo(float *x) {
float a[5] = { 1,2,3,4,5};

View File

@@ -1,4 +1,4 @@
// Illegal to use ^= operator with floating-point
// Illegal to use \^= operator with floating-point
float foo(float a, float b) {
return a ^= b;

View File

@@ -1,4 +1,4 @@
// Can't convert argument of type "void * uniform" to type "varying float" for function call argument.
// Can't convert argument of type "void \* uniform" to type "varying float" for function call argument.
float bar(float a, float b);

View File

@@ -1,4 +1,4 @@
// Too few parameter values provided in function call (1 provided, 2 expected).
// Too few parameter values provided in function call \(1 provided, 2 expected\).
float bar(float a, float b);

View File

@@ -1,3 +1,3 @@
// Initializer list for array "varying int32[2][4]" must have no more than 2 elements (has 3)
// Initializer list for array "varying int32\[2\]\[4\]" must have no more than 2 elements \(has 3\)
int a[2][4] = { { 1, 2, 3 }, { 1, 2, 3, 4 }, 1 };

View File

@@ -1,5 +1,5 @@
// Type conversion from "const uniform int32" to "uniform int32 * varying" for initializer is not possible
// Type conversion from "const uniform int32" to "uniform int32 \* varying" for initializer is not possible
int voo() {
int * varying foo = 1;
int * varying foo = 1l;
}

View File

@@ -1,4 +1,4 @@
// Can't assign to type "const uniform int32" on left-hand side of expression
// Can't assign to type "const uniform int[0-9]*" on left-hand side of expression
int bar(){
4 = 0;

View File

@@ -1,4 +1,4 @@
// Can't assign to type "const uniform int32" on left-hand side of expression
// Can't assign to type "const uniform int[0-9]*" on left-hand side of expression
int bar(){
int x;

View File

@@ -1,4 +1,4 @@
// syntax error, unexpected '('
// syntax error, unexpected '\('
int * func(int a) {
return new int[a](10);

View File

@@ -1,4 +1,4 @@
// Can't convert from type "uniform int32 * varying" to type "uniform int32 * uniform" for return
// Can't convert from type "uniform int32 \* varying" to type "uniform int32 \* uniform" for return
int * uniform func(int x) {
return new int[x];

View File

@@ -1,4 +1,4 @@
// Can't convert from pointer type "void * varying" to incompatible pointer type "uniform int32 * varying" for return statement
// Can't convert from pointer type "void \* varying" to incompatible pointer type "uniform int32 \* varying" for return statement
int *foo(void *p) {
return p;

View File

@@ -1,4 +1,4 @@
// Can't assign to type "const uniform int32 * const varying"
// Can't assign to type "const uniform int32 \* const varying"
void foo(const int * const p) {
++p;

View File

@@ -1,4 +1,4 @@
// Pointer type cast of type "uniform int32 * uniform" to integer type "uniform int32" may lose information.
// Pointer type cast of type "uniform int32 \* uniform" to integer type "uniform int32" may lose information.
// rule: run on arch=x86-64
int32 foo(int * uniform x) {

View File

@@ -1,4 +1,4 @@
// syntax error, unexpected '*',
// syntax error, unexpected '\*',
void foo(int & * x) {
*x = NULL;

View File

@@ -1,4 +1,4 @@
// Type conversion from "const uniform int32" to "soa<4> struct Foo" for assignment operator is not possible
// Type conversion from "const uniform int[0-9]*" to "soa<4> struct Foo" for assignment operator is not possible
struct Pt { float x, y, z; };

View File

@@ -1,4 +1,4 @@
// Can't convert between types "const uniform int32" and "soa<4> float" with different SOA widths
// Can't convert between types "const uniform int[0-9]*" and "soa<4> float" with different SOA widths
struct Pt { float x, y, z; };

View File

@@ -1,4 +1,4 @@
// syntax error, unexpected '-', expecting int32 constant
// syntax error, unexpected '-', expecting int
struct F { float a, b, c; };

View File

@@ -1,4 +1,4 @@
// syntax error, unexpected '-', expecting int32 constant
// syntax error, unexpected '-', expecting int
struct F { float a, b, c; };

View File

@@ -1,4 +1,4 @@
// Can't convert from pointer to SOA type "soa<8> struct A * uniform" to pointer to non-SOA type "void * varying"
// Can't convert from pointer to SOA type "soa<8> struct A \* uniform" to pointer to non-SOA type "void \* varying"
struct A { float a, b; };

View File

@@ -1,4 +1,4 @@
// Assignment operator "+=" is illegal with struct type
// Assignment operator "\+=" is illegal with struct type
struct Point { float x, y, z; };

View File

@@ -1,4 +1,4 @@
// syntax error, unexpected identifier, expecting int32 constant
// syntax error, unexpected identifier, expecting int
void foo(uniform int i) {
float<i> a;