From b773dce440da6392c74a64ef55ebba39ebe51521 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Fri, 3 Jul 2026 12:51:21 +0300 Subject: [PATCH 01/31] Support for SIMD vector instructions (incomplete) --- c.g | 2 +- rcc.c | 9 ++ rcc.h | 14 +- rcc_parser.c | 2 +- rcc_semantic.c | 374 +++++++++++++++++++++++++++++++++++++++++++++---- 5 files changed, 372 insertions(+), 29 deletions(-) diff --git a/c.g b/c.g index eaa9a11..ccfe738 100644 --- a/c.g +++ b/c.g @@ -487,7 +487,7 @@ attrib(rcc_ctx *rcc, c_dcl *d): {c_name name = sym;} "(" constant_expression(rcc, &v) ")" {c_gcc_attribute_regparm(rcc, d, name, &v);} | ("unused"|"__unused__") {d->attr |= C_ATTR_UNUSED;} | ("vector_size"|"__vector_size__") {c_value_clear(&v);} - ( "(" constant_expression(rcc, &v) ")" )? {yy_error_fmt("unsupported attribute \"%s\"", yy_sym2str(rcc, name));} + ( "(" constant_expression(rcc, &v) ")" )? {c_gcc_attribute_vector_size(rcc, d, name, &v);} | ("weak"|"__weak__") {d->attr |= C_ATTR_WEAK;} | ID(rcc, &name) {sym = c_gcc_attribute(rcc, d, name, sym);} )? diff --git a/rcc.c b/rcc.c index ddd0143..883270f 100644 --- a/rcc.c +++ b/rcc.c @@ -1303,6 +1303,15 @@ static size_t rcc_emit_ir_data(rcc_ctx *rcc, FILE *f, const c_type *type, const offset++; } return offset; + } else if (type->kind == C_TYPE_VECTOR) { + size_t offset = 0, el_offset = 0; + int i; + + for (i = 0; i < type->vec.length; el_offset += type->vec.type->size, i++) { + IR_ASSERT(offset == el_offset); + offset += rcc_emit_ir_data(rcc, f, type->vec.type, (const char*)addr + el_offset, base + el_offset, rel); + } + return offset; } else { IR_ASSERT(0); } diff --git a/rcc.h b/rcc.h index fdb8147..7725c8d 100644 --- a/rcc.h +++ b/rcc.h @@ -730,6 +730,7 @@ typedef enum { C_TYPE_ARRAY, C_TYPE_STRUCT, C_TYPE_UNION, + C_TYPE_VECTOR, C_TYPE_FLOAT_COMPLEX, C_TYPE_DOUBLE_COMPLEX, C_TYPE_LONG_DOUBLE_COMPLEX, @@ -797,6 +798,10 @@ struct _c_type { const c_type *ret_type; c_param *params; } func; + struct { + const c_type *type; + int32_t length; + } vec; c_name tag; }; }; @@ -824,6 +829,7 @@ struct _c_dcl { c_name cleanup_func; /* may be set for local variables */ int8_t reg; uint32_t attr2; + uint32_t vector_size; }; typedef enum { @@ -892,7 +898,8 @@ struct _c_tag { #define C_CODE_STARTED 2 #define C_CODE_DONE 3 -#define C_IS_BIT_FIELD(bit_field) ((bit_field) != 0) +#define C_IS_SIMPLE_VAL(bit_field) ((bit_field) == 0) +#define C_IS_BIT_FIELD(bit_field) ((bit_field) & (1 << 12)) #define C_BIT_FIELD(start, lenght) ((1 << 12) | ((start) << 6) | (lenght)) #define C_BIT_FIELD_START(bit_field) (((bit_field) >> 6) & 0x3f) #define C_BIT_FIELD_SIZE(bit_field) ((bit_field) & 0x3f) @@ -900,6 +907,10 @@ struct _c_tag { #define C_IS_BIT_FIELD_PACKED(bit_field) ((bit_field) & (1 << 13)) #define C_SET_BIT_FIELD_PACKED(bit_field) do {(bit_field) |= (1 << 13);} while (0) +#define C_IS_VECTOR_DIM(proto) ((proto) & (1 << 14)) +#define C_VECTOR_DIM(type) ((1 << 14) | (type)) +#define C_VECTOR_DIM_TYPE(proto) (proto & 0xff) + struct _c_field { c_name name; uint16_t bit_field; /* 1-bit - is bit-field, 6-bits - first bit, 6-bits - bit lenght */ @@ -1099,6 +1110,7 @@ void c_gcc_attribute_aligned(rcc_ctx *rcc, c_dcl *d, c_name attr, c_value *v); void c_gcc_attribute_packed(rcc_ctx *rcc, c_dcl *d, c_name attr); void c_gcc_attribute_cleanup(rcc_ctx *rcc, c_dcl *d, c_name attr, c_name func); void c_gcc_attribute_regparm(rcc_ctx *rcc, c_dcl *d, c_name attr, c_value *v); +void c_gcc_attribute_vector_size(rcc_ctx *rcc, c_dcl *d, c_name attr, c_value *v); yy_sym c_gcc_attribute(rcc_ctx *rcc, c_dcl *dcl, c_name attr, yy_sym sym); void c_gcc_attribute_alias(rcc_ctx *rcc, c_dcl *d, c_name attr, c_value *v); void c_asm_alias(rcc_ctx *rcc, c_dcl *d, c_value *v); diff --git a/rcc_parser.c b/rcc_parser.c index e0d0c5c..6b5fa3a 100644 --- a/rcc_parser.c +++ b/rcc_parser.c @@ -960,7 +960,7 @@ static yy_sym parse_attrib(yy_sym sym, rcc_ctx *rcc, c_dcl *d) { } sym = get_sym(); } - yy_error_fmt("unsupported attribute \"%s\"", yy_sym2str(rcc, name)); + c_gcc_attribute_vector_size(rcc, d, name, &v); } else if (sym == YY_WEAK || sym == YY___WEAK__) { sym = get_sym(); d->attr |= C_ATTR_WEAK; diff --git a/rcc_semantic.c b/rcc_semantic.c index b6d607b..316a574 100644 --- a/rcc_semantic.c +++ b/rcc_semantic.c @@ -191,14 +191,36 @@ ir_type c_type2ir(rcc_ctx *rcc, const c_type *t) case C_TYPE_FUNC: return IR_ADDR; case C_TYPE_STRUCT: return IR_ADDR; case C_TYPE_UNION: return IR_ADDR; +#if IR_SIMD + case C_TYPE_VECTOR: + switch (t->vec.type->kind) { + case C_TYPE_I8: return IR_MAKE_VECTOR_TYPE(IR_I8, t->vec.length); + case C_TYPE_I16: return IR_MAKE_VECTOR_TYPE(IR_I16, t->vec.length); + case C_TYPE_I32: return IR_MAKE_VECTOR_TYPE(IR_I32, t->vec.length); + case C_TYPE_IL: return IR_MAKE_VECTOR_TYPE(IR_LONG, t->vec.length); + case C_TYPE_ILL: return IR_MAKE_VECTOR_TYPE(IR_I64, t->vec.length); + case C_TYPE_U8: return IR_MAKE_VECTOR_TYPE(IR_U8, t->vec.length); + case C_TYPE_U16: return IR_MAKE_VECTOR_TYPE(IR_U16, t->vec.length); + case C_TYPE_U32: return IR_MAKE_VECTOR_TYPE(IR_U32, t->vec.length); + case C_TYPE_UL: return IR_MAKE_VECTOR_TYPE(IR_ULONG, t->vec.length); + case C_TYPE_ULL: return IR_MAKE_VECTOR_TYPE(IR_U64, t->vec.length); + case C_TYPE_FLOAT: return IR_MAKE_VECTOR_TYPE(IR_FLOAT, t->vec.length); + case C_TYPE_DOUBLE: return IR_MAKE_VECTOR_TYPE(IR_DOUBLE, t->vec.length); + case C_TYPE_CHAR: return IR_MAKE_VECTOR_TYPE(IR_I8, t->vec.length); + default: + break; + } + break; +#endif case C_TYPE_FLOAT_COMPLEX: case C_TYPE_DOUBLE_COMPLEX: case C_TYPE_LONG_DOUBLE_COMPLEX: yy_error("complex numbers are not supported yet"); //??? default: - IR_ASSERT(0); - return IR_VOID; + break; } + IR_ASSERT(0); + return IR_VOID; } #define MAX_ABI_TYPES 2 @@ -785,6 +807,31 @@ static void c_finalize_type(rcc_ctx *rcc, c_dcl *d) c_validate_dcl(rcc, d); + if (d->vector_size) { + c_type *type; + + if (d->type->kind < C_TYPE_U8 || d->type->kind > C_TYPE_DOUBLE) { + yy_error("invalid vector type for attribute \"vector_size\")"); +#if IR_SIMD + } else if (d->vector_size / d->type->size <= 64) { + /* General IR limitation */ +#endif + } else { + yy_error_fmt("unsupported attribute \"vector_size(%u)\"", d->vector_size); + } + + type = ir_arena_alloc(&rcc->c_arena, sizeof(c_type)); + type->size = d->vector_size; + type->kind = C_TYPE_ARRAY; + type->kind = C_TYPE_VECTOR; + type->flags = rcc->active_scope ? 0 : C_TYPE_GLOBAL; + type->attr = c_align2attr(IR_MIN(d->vector_size, 16)); /* 16 byte allgnment */ + type->vec.type = d->type; + type->vec.length = d->vector_size / d->type->size; + d->type = type; + d->vector_size = 0; + } + if ((d->flags & C_TYPE_SPEC_NAME) && (d->attr & C_TYPE_ATTRS) && (d->type->kind == C_TYPE_ARRAY)) { @@ -915,7 +962,7 @@ static void c_do_grow_flexible(rcc_ctx *rcc, c_sym *obj, size_t old_size, size_t memset((char*)obj->value.u.val.ptr + old_size, 0, size - old_size); if (c_value_is_ref(&obj->value)) { ir_str name = rcc->active_ctx->ir_base[obj->value.u.ref].val.name; - + IR_ASSERT(IR_IS_EXT_STR(name)); rcc->yy_hash.data[IR_EXT_STR(name)].sym->value.u.val.ptr = obj->value.u.val.ptr; } @@ -2684,6 +2731,21 @@ void c_gcc_attribute_regparm(rcc_ctx *rcc, c_dcl *d, c_name attr, c_value *val) yy_warning_ex_fmt(E_UNSUPPORTED, "unsupported attribure \"%s(%d)\"", yy_sym2str(rcc, attr), val->u.val.u32); } +void c_gcc_attribute_vector_size(rcc_ctx *rcc, c_dcl *d, c_name attr, c_value *val) +{ + if (!c_value_is_set(val) + || !c_value_is_const(val) + || !C_IS_TYPE_INT(val->type) + || val->u.val.u64 == 0 + || (C_IS_TYPE_SIGNED(val->type) && val->u.val.i64 < 0)) { + yy_error_fmt("attribute \"%s\" value must be a positive integer constant", yy_sym2str(rcc, attr)); + } else if ((val->u.val.u64 & (val->u.val.u64 - 1)) != 0) { + yy_error_fmt("attribute \"%s\" value must be a power of two", yy_sym2str(rcc, attr)); + } + + d->vector_size = val->u.val.u32; +} + yy_sym c_gcc_attribute(rcc_ctx *rcc, c_dcl *d, c_name attr, yy_sym sym) { if (attr == YY_FORMAT @@ -3528,7 +3590,7 @@ void c_value_rval(rcc_ctx *rcc, c_value *val) } else if (c_value_is_reg(val)) { val->u.ref = ir_RLOAD(val->u.type, val->u.ref); } else if (val->type->kind != C_TYPE_STRUCT && val->type->kind != C_TYPE_UNION) { - if (!C_IS_BIT_FIELD(val->u.proto)) { + if (C_IS_SIMPLE_VAL(val->u.proto)) { if (IR_IS_CONST_REF(val->u.ref) && ((rcc->active_ctx->ir_base[val->u.ref].op == IR_SYM && ((val->type->attr & (C_ATTR_CONST|C_ATTR_VOLATILE)) == C_ATTR_CONST)) @@ -3564,10 +3626,31 @@ void c_value_rval(rcc_ctx *rcc, c_value *val) } else { val->u.ref = ir_LOAD(val->u.type, val->u.ref); } - } else if (!C_IS_BIT_FIELD_PACKED(val->u.proto)) { - c_do_load_bit_field(rcc, val, C_BIT_FIELD_START(val->u.proto), C_BIT_FIELD_SIZE(val->u.proto)); + } else if (C_IS_BIT_FIELD(val->u.proto)) { + if (!C_IS_BIT_FIELD_PACKED(val->u.proto)) { + c_do_load_bit_field(rcc, val, C_BIT_FIELD_START(val->u.proto), C_BIT_FIELD_SIZE(val->u.proto)); + } else { + c_do_load_bit_field_packed(rcc, val, C_BIT_FIELD_START(val->u.proto), C_BIT_FIELD_SIZE(val->u.proto)); + } } else { - c_do_load_bit_field_packed(rcc, val, C_BIT_FIELD_START(val->u.proto), C_BIT_FIELD_SIZE(val->u.proto)); + ir_ref ref; + ir_type t; + + IR_ASSERT(C_IS_VECTOR_DIM(val->u.proto)); + if (c_value_is_lval(val)) { + t = C_VECTOR_DIM_TYPE(val->u.proto); + if (rcc->active_ctx->ir_base[val->u.ref].op == IR_VAR) { + ref = ir_VLOAD(t, val->u.ref); + } else { + IR_ASSERT(rcc->active_ctx->ir_base[val->u.ref].type == IR_ADDR); + ref = ir_LOAD(t, val->u.ref); + } + } else { + ref = val->u.ref; + } + t = c_type2ir(rcc, val->type); + c_value_set_rval(val, val->type, t, ir_EXTRACT(t, ref, val->u.op2)); + return; } } val->u.op &= ~(C_VAL_LVAL|C_VAL_VAR|C_VAL_REG|C_VAL_VOLATILE); @@ -3619,8 +3702,8 @@ static void c_do_trunc(rcc_ctx *rcc, const c_type *t, ir_type type, c_value *v) static void c_do_bitcast(rcc_ctx *rcc, const c_type *t, ir_type type, c_value *v) { IR_ASSERT(t->size == v->type->size || (t->size == sizeof(void*) && v->type->kind == C_TYPE_ARRAY)); - IR_ASSERT(ir_type_size[type] == ir_type_size[v->u.type]); - if (c_value_is_ref(v) || c_value_is_const_str(v)) { + IR_ASSERT(ir_get_type_size(type) == ir_get_type_size(v->u.type)); + if (c_value_is_ref(v) || c_value_is_const_str(v) || t->kind == C_TYPE_VECTOR) { c_value_set_rval(v, t, type, ir_BITCAST(type, c_value_ref(rcc, v))); } else { switch (type) { @@ -3854,6 +3937,8 @@ void c_do_addr(rcc_ctx *rcc, c_value *v) } } else if (C_IS_BIT_FIELD(v->u.proto)) { yy_error("cannot take address of bit-field"); + } else if (C_IS_VECTOR_DIM(v->u.proto)) { + yy_error("cannot take address of vector element"); } type = c_create_pointer_type(rcc, v->type); @@ -4043,7 +4128,7 @@ static ir_ref c_do_store(rcc_ctx *rcc, c_value *addr, c_value *val) { ir_ref ref; - if (!C_IS_BIT_FIELD(addr->u.proto)) { + if (C_IS_SIMPLE_VAL(addr->u.proto)) { ref = c_value_ref(rcc, val); if (c_value_is_var(addr)) { if ((addr->type->attr & C_ATTR_VOLATILE) || (addr->u.op & C_VAL_VOLATILE)) { @@ -4061,12 +4146,38 @@ static ir_ref c_do_store(rcc_ctx *rcc, c_value *addr, c_value *val) } } return ref; - } else if (!C_IS_BIT_FIELD_PACKED(addr->u.proto)) { - return c_do_store_bit_field(rcc, addr->u.ref, - C_BIT_FIELD_START(addr->u.proto), C_BIT_FIELD_SIZE(addr->u.proto), val); + } else if (C_IS_BIT_FIELD(addr->u.proto)) { + if (!C_IS_BIT_FIELD_PACKED(addr->u.proto)) { + return c_do_store_bit_field(rcc, addr->u.ref, + C_BIT_FIELD_START(addr->u.proto), C_BIT_FIELD_SIZE(addr->u.proto), val); + } else { + return c_do_store_bit_field_packed(rcc, addr->u.ref, + C_BIT_FIELD_START(addr->u.proto), C_BIT_FIELD_SIZE(addr->u.proto), val); + } } else { - return c_do_store_bit_field_packed(rcc, addr->u.ref, - C_BIT_FIELD_START(addr->u.proto), C_BIT_FIELD_SIZE(addr->u.proto), val); + ir_type vt; + ir_ref vref; + + IR_ASSERT(C_IS_VECTOR_DIM(addr->u.proto) && c_value_is_lval(addr)); + vt = C_VECTOR_DIM_TYPE(addr->u.proto); + if (rcc->active_ctx->ir_base[addr->u.ref].op == IR_VAR) { + vref = ir_VLOAD(vt, addr->u.ref); + } else { + IR_ASSERT(rcc->active_ctx->ir_base[addr->u.ref].type == IR_ADDR); + vref = ir_LOAD(vt, addr->u.ref); + } + + ref = c_value_ref(rcc, val); + vref = ir_REPLACE(vt, vref, addr->u.op2, ref); + + if (rcc->active_ctx->ir_base[addr->u.ref].op == IR_VAR) { + ir_VSTORE(addr->u.ref, vref); + } else { + IR_ASSERT(rcc->active_ctx->ir_base[addr->u.ref].type == IR_ADDR); + ir_STORE(addr->u.ref, vref); + } + + return ref; } } @@ -4187,6 +4298,12 @@ static void c_do_check_cvt(rcc_ctx *rcc, const c_type *type, c_value *val, int32 && c_compatible_types(type, val_type, 1, 0)) { val->type = type; return; + } else if (type->kind == C_TYPE_VECTOR + && val->type->kind == C_TYPE_VECTOR + && type->vec.type->kind == val->type->vec.type->kind + && type->vec.length == val->type->vec.length) { + /* identicl vector types */ + return; } else { goto incompatible; } @@ -4208,7 +4325,7 @@ void c_do_cast(rcc_ctx *rcc, const c_type *t, c_value *v) if (f->type == v->type || c_compatible_types(f->type, v->type, 1, 0)) { ir_ref addr = c_do_alloca(rcc, t->size, c_attr2align(t->attr), 0); - if (C_IS_TYPE_SCALAR_OR_PTR(v->type)) { + if (C_IS_TYPE_SCALAR_OR_PTR(v->type) || v->type->kind == C_TYPE_VECTOR) { ir_STORE(addr, c_value_ref(rcc, v)); } else { IR_ASSERT(v->type->size); @@ -4219,12 +4336,26 @@ void c_do_cast(rcc_ctx *rcc, const c_type *t, c_value *v) return; } } + } else if (t->kind == C_TYPE_VECTOR) { + if (t->size == v->type->size + && (v->type->kind == C_TYPE_VECTOR || C_IS_TYPE_KIND_SCALAR(v->type->kind))) { + c_do_bitcast(rcc, t, c_type2ir(rcc, t), v); + return; + } + yy_error("cannot convert a value to vector of different size"); } yy_error("conversion to non-scalar type requested"); } else if (t->flags & C_TYPE_INCOMPLETE) { yy_error("conversion to incomplete type"); } else if (v->type->kind == C_TYPE_VOID || v->type->kind == C_TYPE_STRUCT || v->type->kind == C_TYPE_UNION) { yy_error("conversion of non-scalar type requested"); + } else if (v->type->kind == C_TYPE_VECTOR) { + if (t->size == v->type->size + && (t->kind == C_TYPE_VECTOR || C_IS_TYPE_KIND_SCALAR(t->kind))) { + c_do_bitcast(rcc, t, c_type2ir(rcc, t), v); + return; + } + yy_error("cannot convert a vector to type of different size"); } else if (t->kind == C_TYPE_POINTER) { if (C_IS_TYPE_FP(v->type)) { yy_error("cannot convert floating point value to a pointer"); @@ -4394,11 +4525,12 @@ void c_do_neg(rcc_ctx *rcc, c_value *v) if (t->size < 4) { c_do_cvt(rcc, &c_type_i32, IR_I32, v); } - } else if (!C_IS_TYPE_FP(t)) { + } else if (!C_IS_TYPE_FP(t) && t->kind != C_TYPE_VECTOR) { yy_error("invalid type argument of unary \"-\""); } - if (c_value_is_ref(v)) { + if (c_value_is_ref(v) || t->kind == C_TYPE_VECTOR) { + // TODO: constant folding for vectors ??? v->u.ref = ir_NEG(v->u.type, c_value_ref(rcc, v)); } else { switch (v->u.type) { @@ -4422,10 +4554,11 @@ void c_do_not(rcc_ctx *rcc, c_value *v) if (t->size < 4) { c_do_cvt(rcc, &c_type_i32, IR_I32, v); } - } else { + } else if (t->kind != C_TYPE_VECTOR || !C_IS_TYPE_INT(t->vec.type)) { yy_error("invalid type argument of unary \"~\""); } - if (c_value_is_ref(v)) { + if (c_value_is_ref(v) || t->kind == C_TYPE_VECTOR) { + // TODO: constant folding for vectors ??? v->u.ref = ir_NOT(v->u.type, c_value_ref(rcc, v)); } else { switch (v->u.type) { @@ -4482,6 +4615,20 @@ void c_do_array_dim(rcc_ctx *rcc, c_value *v, c_value *dim) } type = type->pointer.type; ref = c_value_ref(rcc, v); + } else if (type->kind == C_TYPE_VECTOR) { + ir_type vt = c_type2ir(rcc, type); + + if (!C_IS_TYPE_INT(dim->type) && dim->type->kind != C_TYPE_ENUM) yy_error("array subscript is not an integer"); + // TODO: constant range check ??? + c_value_rval(rcc, dim); + if (c_value_is_lval(v)) { + c_value_set_lval(v, type->vec.type, c_type2ir(rcc, type->vec.type), v->u.ref); + } else { + c_value_set_rval(v, type->vec.type, c_type2ir(rcc, type->vec.type), c_value_ref(rcc, v)); + } + v->u.proto = C_VECTOR_DIM(vt); + v->u.op2 = c_value_ref(rcc, dim);; + return; } else { type = dim->type; if (type->kind == C_TYPE_ARRAY) { @@ -5714,6 +5861,58 @@ void c_do_call(rcc_ctx *rcc, c_value *func, int32_t num_args, c_value *args, c_v if (num_args > C_ALLOCA_PARAMS) ir_mem_free(args); } +static bool c_do_splat(rcc_ctx *rcc, const c_type *type, c_value *val) +{ + ir_type t; + + IR_ASSERT(type->kind == C_TYPE_VECTOR); + + if (C_IS_TYPE_KIND_FP(type->vec.type->kind)) { + if (C_IS_TYPE_KIND_FP(val->type->kind)) { + if (val->type->size > type->vec.type->size) { + // TODO: constant folding ??? + yy_error("cannot convert value to a vector (conversion involves truncation)"); + } else if (val->type->size < type->vec.type->size) { + c_do_fp2fp(rcc, type->vec.type, c_type2ir(rcc, type->vec.type), val); + } + } else if (C_IS_TYPE_KIND_INT(val->type->kind)) { + if (val->type->size >= type->vec.type->size) { + // TODO: constant folding ??? + yy_error("cannot convert value to a vector (conversion involves truncation)"); + } else { + c_do_int2fp(rcc, type->vec.type, c_type2ir(rcc, type->vec.type), val); + } + } else { + return 0; + } + } else { + IR_ASSERT(C_IS_TYPE_KIND_INT(type->vec.type->kind)); + if (C_IS_TYPE_KIND_FP(val->type->kind)) { + yy_error("cannot convert value to a vector"); + } else if (C_IS_TYPE_KIND_INT(val->type->kind)) { + if (val->type->size > type->vec.type->size) { + // TODO: constant folding ??? + yy_error("cannot convert value to a vector (conversion involves truncation)"); + } else if (val->type->size < type->vec.type->size) { + if (C_IS_TYPE_KIND_SIGNED(val->type->kind)) { + c_do_sext(rcc, type->vec.type, c_type2ir(rcc, type->vec.type), val); + } else { + c_do_zext(rcc, type->vec.type, c_type2ir(rcc, type->vec.type), val); + } + } else if (val->type->kind != type->vec.type->kind) { + c_do_bitcast(rcc, type->vec.type, c_type2ir(rcc, type->vec.type), val); + } + } else { + return 0; + } + } + + t = c_type2ir(rcc, type); + c_value_set_rval(val, type, t, ir_SPLAT(t, c_value_ref(rcc, val))); + + return 1; +} + static const c_type *c_common_type(rcc_ctx *rcc, yy_sym sym, c_value *op1, c_value *op2) { const c_type *op1_type = op1->type; @@ -5819,6 +6018,22 @@ static const c_type *c_common_type(rcc_ctx *rcc, yy_sym sym, c_value *op1, c_val } } return NULL; + } else if (t1 == C_TYPE_VECTOR) { + if (t2 == C_TYPE_VECTOR) { + if (op1->type->size == op2->type->size) { + if (op1->type->vec.type == op2->type->vec.type) { + return op1->type; + } + } + } else if (C_IS_TYPE_KIND_SCALAR(t2)) { + if (c_do_splat(rcc, op1->type, op2)) { + return op1->type; + } + } + } else if (t2 == C_TYPE_VECTOR && C_IS_TYPE_KIND_SCALAR(t1)) { + if (c_do_splat(rcc, op2->type, op1)) { + return op2->type; + } } else if (t2 == C_TYPE_FUNC) { if (sym == YY__LESS || sym == YY__LESS_EQUAL || sym == YY__GREATER || sym == YY__GREATER_EQUAL || sym == YY__EQUAL_EQUAL || sym == YY__BANG_EQUAL || sym == YY__COLON) { @@ -6402,6 +6617,13 @@ static void c_do_lt(rcc_ctx *rcc, const c_type *type, c_value *op1, c_value *op2 default: IR_ASSERT(0); return; } c_value_set_const(op1, &c_type_bool, IR_BOOL, val); + } else if (type->kind == C_TYPE_VECTOR) { + ir_type t = c_type2ir(rcc, type); + if (C_IS_TYPE_SIGNED(type->vec.type) || C_IS_TYPE_FP(type->vec.type)) { + c_value_set_rval(op1, type, t, ir_BINARY_OP(IR_LT, t, c_value_ref(rcc, op1), c_value_ref(rcc, op2))); + } else { + c_value_set_rval(op1, type, t, ir_BINARY_OP(IR_ULT, t, c_value_ref(rcc, op1), c_value_ref(rcc, op2))); + } } else { if (C_IS_TYPE_SIGNED(type) || C_IS_TYPE_FP(type)) { c_value_set_rval(op1, &c_type_bool, IR_BOOL, ir_LT(c_value_ref(rcc, op1), c_value_ref(rcc, op2))); @@ -6432,6 +6654,13 @@ static void c_do_gt(rcc_ctx *rcc, const c_type *type, c_value *op1, c_value *op2 default: IR_ASSERT(0); return; } c_value_set_const(op1, &c_type_bool, IR_BOOL, val); + } else if (type->kind == C_TYPE_VECTOR) { + ir_type t = c_type2ir(rcc, type); + if (C_IS_TYPE_SIGNED(type->vec.type) || C_IS_TYPE_FP(type->vec.type)) { + c_value_set_rval(op1, type, t, ir_BINARY_OP(IR_GT, t, c_value_ref(rcc, op1), c_value_ref(rcc, op2))); + } else { + c_value_set_rval(op1, type, t, ir_BINARY_OP(IR_UGT, t, c_value_ref(rcc, op1), c_value_ref(rcc, op2))); + } } else { if (C_IS_TYPE_SIGNED(type) || C_IS_TYPE_FP(type)) { c_value_set_rval(op1, &c_type_bool, IR_BOOL, ir_GT(c_value_ref(rcc, op1), c_value_ref(rcc, op2))); @@ -6462,6 +6691,13 @@ static void c_do_le(rcc_ctx *rcc, const c_type *type, c_value *op1, c_value *op2 default: IR_ASSERT(0); return; } c_value_set_const(op1, &c_type_bool, IR_BOOL, val); + } else if (type->kind == C_TYPE_VECTOR) { + ir_type t = c_type2ir(rcc, type); + if (C_IS_TYPE_SIGNED(type->vec.type) || C_IS_TYPE_FP(type->vec.type)) { + c_value_set_rval(op1, type, t, ir_BINARY_OP(IR_LE, t, c_value_ref(rcc, op1), c_value_ref(rcc, op2))); + } else { + c_value_set_rval(op1, type, t, ir_BINARY_OP(IR_ULE, t, c_value_ref(rcc, op1), c_value_ref(rcc, op2))); + } } else { if (C_IS_TYPE_SIGNED(type) || C_IS_TYPE_FP(type)) { c_value_set_rval(op1, &c_type_bool, IR_BOOL, ir_LE(c_value_ref(rcc, op1), c_value_ref(rcc, op2))); @@ -6492,6 +6728,13 @@ static void c_do_ge(rcc_ctx *rcc, const c_type *type, c_value *op1, c_value *op2 default: IR_ASSERT(0); return; } c_value_set_const(op1, &c_type_bool, IR_BOOL, val); + } else if (type->kind == C_TYPE_VECTOR) { + ir_type t = c_type2ir(rcc, type); + if (C_IS_TYPE_SIGNED(type->vec.type) || C_IS_TYPE_FP(type->vec.type)) { + c_value_set_rval(op1, type, t, ir_BINARY_OP(IR_GE, t, c_value_ref(rcc, op1), c_value_ref(rcc, op2))); + } else { + c_value_set_rval(op1, type, t, ir_BINARY_OP(IR_UGE, t, c_value_ref(rcc, op1), c_value_ref(rcc, op2))); + } } else { if (C_IS_TYPE_SIGNED(type) || C_IS_TYPE_FP(type)) { c_value_set_rval(op1, &c_type_bool, IR_BOOL, ir_GE(c_value_ref(rcc, op1), c_value_ref(rcc, op2))); @@ -6522,6 +6765,9 @@ static void c_do_eq(rcc_ctx *rcc, const c_type *type, c_value *op1, c_value *op2 default: IR_ASSERT(0); return; } c_value_set_const(op1, &c_type_bool, IR_BOOL, val); + } else if (type->kind == C_TYPE_VECTOR) { + ir_type t = c_type2ir(rcc, type); + c_value_set_rval(op1, type, t, ir_BINARY_OP(IR_EQ, t, c_value_ref(rcc, op1), c_value_ref(rcc, op2))); } else { c_value_set_rval(op1, &c_type_bool, IR_BOOL, ir_EQ(c_value_ref(rcc, op1), c_value_ref(rcc, op2))); } @@ -6548,6 +6794,9 @@ static void c_do_ne(rcc_ctx *rcc, const c_type *type, c_value *op1, c_value *op2 default: IR_ASSERT(0); return; } c_value_set_const(op1, &c_type_bool, IR_BOOL, val); + } else if (type->kind == C_TYPE_VECTOR) { + ir_type t = c_type2ir(rcc, type); + c_value_set_rval(op1, type, t, ir_BINARY_OP(IR_NE, t, c_value_ref(rcc, op1), c_value_ref(rcc, op2))); } else { c_value_set_rval(op1, &c_type_bool, IR_BOOL, ir_NE(c_value_ref(rcc, op1), c_value_ref(rcc, op2))); } @@ -6611,7 +6860,7 @@ void c_do_assign_op(rcc_ctx *rcc, yy_sym sym, c_value *op1, c_value *op2) } if (op1->type != op2->type) c_do_check_cvt(rcc, op1->type, op2, -1); if (op1->type->attr & C_ATTR_CONST) yy_error_fmt("%s of read-only location", "assignment"); - if (C_IS_TYPE_SCALAR_OR_PTR(op1->type)) { + if (C_IS_TYPE_SCALAR_OR_PTR(op1->type) || op1->type->kind == C_TYPE_VECTOR) { ir_ref ref = c_do_store(rcc, op1, op2); if (!IR_IS_CONST_REF(ref) || IR_IS_SYM_CONST(rcc->active_ctx->ir_base[ref].op)) { @@ -8140,7 +8389,7 @@ void c_do_init_obj(rcc_ctx *rcc, c_sym *obj, c_value *val) yy_error("initializer element is not constant"); } c_do_init(obj->value.u.val.ptr, val); - } else if (C_IS_TYPE_SCALAR_OR_PTR(obj->value.type)) { + } else if (C_IS_TYPE_SCALAR_OR_PTR(obj->value.type) || obj->value.type->kind == C_TYPE_VECTOR) { IR_ASSERT(c_value_is_ref(&obj->value)); if (rcc->active_ctx->ir_base[obj->value.u.ref].op == IR_VAR) { ir_VSTORE(obj->value.u.ref, c_value_ref(rcc, val)); @@ -8288,6 +8537,13 @@ void c_do_init_next(rcc_ctx *rcc, c_sym *obj, c_init *init) yy_warning("excess elements in union initializer"); return; } + } else if (type->kind == C_TYPE_VECTOR) { + pos = init->stack[init->level].pos; + if (++pos < type->vec.length) { + init->stack[init->level].pos = pos; + return; + } + if (init->level == 0) yy_error("excess elements in vector initializer"); } else { if (init->level == 0) yy_error("excess elements in scalar initializer"); } @@ -8402,6 +8658,9 @@ void c_do_init_set(rcc_ctx *rcc, c_sym *obj, c_init *init, c_value *val) // TODO: select best type ??? type = type->record.fields[0].type; if (type->kind != C_TYPE_ARRAY && type->kind != C_TYPE_STRUCT && type->kind != C_TYPE_UNION) break; + } else if (type->kind == C_TYPE_VECTOR) { + type = type->vec.type; + break; } else { break; } @@ -8444,6 +8703,8 @@ void c_do_init_set(rcc_ctx *rcc, c_sym *obj, c_init *init, c_value *val) } else { IR_ASSERT(i == init->level); } + } else if (t->kind == C_TYPE_VECTOR) { + offset += t->vec.type->size * init->stack[i].pos; } else { IR_ASSERT(i == init->level); } @@ -8585,18 +8846,79 @@ void c_do_init_set(rcc_ctx *rcc, c_sym *obj, c_init *init, c_value *val) ir_const_size_t(rcc->active_ctx, type->size), c_attr2align(type->attr)); } + } else if (type->kind == C_TYPE_VECTOR && C_IS_TYPE_SCALAR(val->type)) { + ir_ref ref; + ir_type t; + ir_val v; + + if (offset == 0) { + t = c_type2ir(rcc, type->vec.type); + v.u64 = 0; + ref = ir_const(rcc->active_ctx, v, t); + t = c_type2ir(rcc, type); + ref = ir_SPLAT(t, ref); + } else { + + } + + t = c_type2ir(rcc, type); + ref = ir_REPLACE(t, ref, ir_const_u8(rcc->active_ctx, offset / sizeof(type->vec.type->size)), + c_value_ref(rcc, val)); + + IR_ASSERT(0 && "INIT_VEC NIY???"); } else if (rcc->active_ctx->ir_base[obj->value.u.ref].op == IR_VAR) { IR_ASSERT(!C_IS_BIT_FIELD(bit_field)); - ir_VSTORE(obj->value.u.ref, c_value_ref(rcc, val)); + + if (init->stack[init->level].type->kind == C_TYPE_VECTOR) { + const c_type *t = init->stack[init->level].type; + ir_type vt = c_type2ir(rcc, t); + ir_ref ref; + + offset -= t->vec.type->size * init->stack[init->level].pos; + IR_ASSERT(offset == 0); + if (init->stack[init->level].pos == 0) { + ir_val v; + v.u64 = 0; + ref = ir_SPLAT(vt, ir_const(rcc->active_ctx, v, c_type2ir(rcc, t->vec.type))); + } else { + ref = ir_VLOAD(vt, obj->value.u.ref); + } + ref = ir_REPLACE(vt, ref, ir_const_u8(rcc->active_ctx, offset / sizeof(type->vec.type->size)), + c_value_ref(rcc, val)); + ir_VSTORE(obj->value.u.ref, ref); + } else { + ir_VSTORE(obj->value.u.ref, c_value_ref(rcc, val)); + } } else if (c_value_is_reg(&obj->value)) { IR_ASSERT(!C_IS_BIT_FIELD(bit_field)); ir_RSTORE(obj->value.u.ref, c_value_ref(rcc, val)); } else { IR_ASSERT(rcc->active_ctx->ir_base[obj->value.u.ref].op == IR_ALLOCA); if (!C_IS_BIT_FIELD(bit_field)) { - ir_STORE( - ir_ADD_A(obj->value.u.ref, ir_const_size_t(rcc->active_ctx, offset)), - c_value_ref(rcc, val)); + if (init->stack[init->level].type->kind == C_TYPE_VECTOR) { + const c_type *t = init->stack[init->level].type; + ir_type vt = c_type2ir(rcc, t); + ir_ref ref; + + offset -= t->vec.type->size * init->stack[init->level].pos; + IR_ASSERT(offset == 0); + if (init->stack[init->level].pos == 0) { + ir_val v; + v.u64 = 0; + ref = ir_SPLAT(vt, ir_const(rcc->active_ctx, v, c_type2ir(rcc, t->vec.type))); + } else { + ref = ir_LOAD(vt, ir_ADD_A(obj->value.u.ref, ir_const_size_t(rcc->active_ctx, offset))); + } + ref = ir_REPLACE(vt, ref, ir_const_u8(rcc->active_ctx, offset / sizeof(type->vec.type->size)), + c_value_ref(rcc, val)); + ir_STORE( + ir_ADD_A(obj->value.u.ref, ir_const_size_t(rcc->active_ctx, offset)), + ref); + } else { + ir_STORE( + ir_ADD_A(obj->value.u.ref, ir_const_size_t(rcc->active_ctx, offset)), + c_value_ref(rcc, val)); + } } else if (!C_IS_BIT_FIELD_PACKED(bit_field)) { c_do_store_bit_field(rcc, ir_ADD_A(obj->value.u.ref, ir_const_size_t(rcc->active_ctx, offset)), From 819b7b8792368c714a3f115db390a6ea3651bdc9 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Mon, 6 Jul 2026 11:07:06 +0300 Subject: [PATCH 02/31] Allow opeartions between vectors and scalar constants if the constant fits into vector element type --- rcc_semantic.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 74 insertions(+), 6 deletions(-) diff --git a/rcc_semantic.c b/rcc_semantic.c index 316a574..ca9b513 100644 --- a/rcc_semantic.c +++ b/rcc_semantic.c @@ -5861,6 +5861,71 @@ void c_do_call(rcc_ctx *rcc, c_value *func, int32_t num_args, c_value *args, c_v if (num_args > C_ALLOCA_PARAMS) ir_mem_free(args); } +static bool c_try_convert_const_fp2fp(rcc_ctx *rcc, const c_type *type, c_value *val) +{ + ir_val v; + + IR_ASSERT(type->kind == C_TYPE_FLOAT && val->type->kind == C_TYPE_DOUBLE); + v.f = (float)val->u.val.d; + v.u32_hi = 0; + if ((double)v.f != val->u.val.d) return 0; + + c_value_set_const(val, type, IR_FLOAT, v); + return 1; +} + +static bool c_try_convert_const_int2fp(rcc_ctx *rcc, const c_type *type, c_value *val) +{ + ir_val v; + + switch (type->kind) { + case C_TYPE_FLOAT: + if (C_IS_TYPE_SIGNED(val->type)) { + v.f = (float)val->u.val.i64; + v.u32_hi = 0; + if ((int64_t)v.f != val->u.val.i64) return 0; + } else { + v.f = (float)val->u.val.u64; + v.u32_hi = 0; + if ((uint64_t)v.f != val->u.val.u64) return 0; + } + c_value_set_const(val, type, IR_FLOAT, v); + return 1; + case C_TYPE_DOUBLE: + if (C_IS_TYPE_SIGNED(val->type)) { + v.d = (double)val->u.val.i64; + if ((int64_t)v.d != val->u.val.i64) return 0; + } else { + v.d = (double)val->u.val.u64; + if ((uint64_t)v.d != val->u.val.u64) return 0; + } + c_value_set_const(val, type, IR_DOUBLE, v); + return 1; + default: + IR_ASSERT(0); + return 0; + } +} + +static bool c_try_convert_const_int2int(rcc_ctx *rcc, const c_type *type, c_value *val) +{ + ir_val v; + + v.u64 = val->u.val.u64; + if (type->size < 8) { + uint32_t shift = (8 - type->size) * 8; + + if (C_IS_TYPE_SIGNED(type)) { + v.i64 = (int64_t)(v.u64 << shift) >> shift; + } else { + v.u64 = (v.u64 << shift) >> shift; + } + } + if (v.u64 != val->u.val.u64) return 0; + c_value_set_const(val, type, c_type2ir(rcc, type), v); + return 1; +} + static bool c_do_splat(rcc_ctx *rcc, const c_type *type, c_value *val) { ir_type t; @@ -5870,15 +5935,17 @@ static bool c_do_splat(rcc_ctx *rcc, const c_type *type, c_value *val) if (C_IS_TYPE_KIND_FP(type->vec.type->kind)) { if (C_IS_TYPE_KIND_FP(val->type->kind)) { if (val->type->size > type->vec.type->size) { - // TODO: constant folding ??? - yy_error("cannot convert value to a vector (conversion involves truncation)"); + if (!c_value_is_const(val) || !c_try_convert_const_fp2fp(rcc, type->vec.type, val)) { + yy_error("cannot convert value to a vector (conversion involves truncation)"); + } } else if (val->type->size < type->vec.type->size) { c_do_fp2fp(rcc, type->vec.type, c_type2ir(rcc, type->vec.type), val); } } else if (C_IS_TYPE_KIND_INT(val->type->kind)) { if (val->type->size >= type->vec.type->size) { - // TODO: constant folding ??? - yy_error("cannot convert value to a vector (conversion involves truncation)"); + if (!c_value_is_const(val) || !c_try_convert_const_int2fp(rcc, type->vec.type, val)) { + yy_error("cannot convert value to a vector (conversion involves truncation)"); + } } else { c_do_int2fp(rcc, type->vec.type, c_type2ir(rcc, type->vec.type), val); } @@ -5891,8 +5958,9 @@ static bool c_do_splat(rcc_ctx *rcc, const c_type *type, c_value *val) yy_error("cannot convert value to a vector"); } else if (C_IS_TYPE_KIND_INT(val->type->kind)) { if (val->type->size > type->vec.type->size) { - // TODO: constant folding ??? - yy_error("cannot convert value to a vector (conversion involves truncation)"); + if (!c_value_is_const(val) || !c_try_convert_const_int2int(rcc, type->vec.type, val)) { + yy_error("cannot convert value to a vector (conversion involves truncation)"); + } } else if (val->type->size < type->vec.type->size) { if (C_IS_TYPE_KIND_SIGNED(val->type->kind)) { c_do_sext(rcc, type->vec.type, c_type2ir(rcc, type->vec.type), val); From 565535f39d2dd359619b412a1134deec984830ff Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Mon, 6 Jul 2026 11:36:56 +0300 Subject: [PATCH 03/31] Fix incorrect warning --- rcc_semantic.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rcc_semantic.c b/rcc_semantic.c index ca9b513..c0bf35c 100644 --- a/rcc_semantic.c +++ b/rcc_semantic.c @@ -9017,7 +9017,10 @@ void c_do_init_nested(rcc_ctx *rcc, c_sym *obj, c_init *init, bool b) } } - if (type->kind != C_TYPE_ARRAY && type->kind != C_TYPE_STRUCT && type->kind != C_TYPE_UNION) { + if (type->kind != C_TYPE_ARRAY + && type->kind != C_TYPE_STRUCT + && type->kind != C_TYPE_UNION + && type->kind != C_TYPE_VECTOR) { yy_warning("braces around scalar initializer"); } else if (!b) { init->level++; From 413d9c7d1a6eb6943d6342cb02004f68217b8788 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Tue, 7 Jul 2026 11:24:47 +0300 Subject: [PATCH 04/31] Fix incorrect IR generation for vector initialization --- rcc_semantic.c | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-) diff --git a/rcc_semantic.c b/rcc_semantic.c index c0bf35c..c88a604 100644 --- a/rcc_semantic.c +++ b/rcc_semantic.c @@ -8914,26 +8914,6 @@ void c_do_init_set(rcc_ctx *rcc, c_sym *obj, c_init *init, c_value *val) ir_const_size_t(rcc->active_ctx, type->size), c_attr2align(type->attr)); } - } else if (type->kind == C_TYPE_VECTOR && C_IS_TYPE_SCALAR(val->type)) { - ir_ref ref; - ir_type t; - ir_val v; - - if (offset == 0) { - t = c_type2ir(rcc, type->vec.type); - v.u64 = 0; - ref = ir_const(rcc->active_ctx, v, t); - t = c_type2ir(rcc, type); - ref = ir_SPLAT(t, ref); - } else { - - } - - t = c_type2ir(rcc, type); - ref = ir_REPLACE(t, ref, ir_const_u8(rcc->active_ctx, offset / sizeof(type->vec.type->size)), - c_value_ref(rcc, val)); - - IR_ASSERT(0 && "INIT_VEC NIY???"); } else if (rcc->active_ctx->ir_base[obj->value.u.ref].op == IR_VAR) { IR_ASSERT(!C_IS_BIT_FIELD(bit_field)); @@ -8951,7 +8931,7 @@ void c_do_init_set(rcc_ctx *rcc, c_sym *obj, c_init *init, c_value *val) } else { ref = ir_VLOAD(vt, obj->value.u.ref); } - ref = ir_REPLACE(vt, ref, ir_const_u8(rcc->active_ctx, offset / sizeof(type->vec.type->size)), + ref = ir_REPLACE(vt, ref, ir_const_u8(rcc->active_ctx, init->stack[init->level].pos), c_value_ref(rcc, val)); ir_VSTORE(obj->value.u.ref, ref); } else { @@ -8977,7 +8957,7 @@ void c_do_init_set(rcc_ctx *rcc, c_sym *obj, c_init *init, c_value *val) } else { ref = ir_LOAD(vt, ir_ADD_A(obj->value.u.ref, ir_const_size_t(rcc->active_ctx, offset))); } - ref = ir_REPLACE(vt, ref, ir_const_u8(rcc->active_ctx, offset / sizeof(type->vec.type->size)), + ref = ir_REPLACE(vt, ref, ir_const_u8(rcc->active_ctx, init->stack[init->level].pos), c_value_ref(rcc, val)); ir_STORE( ir_ADD_A(obj->value.u.ref, ir_const_size_t(rcc->active_ctx, offset)), From 64ae5968be0576c614ce0fc8d9c147388ba94f7b Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Tue, 7 Jul 2026 12:37:42 +0300 Subject: [PATCH 05/31] Fix nested vector initialization --- rcc_semantic.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/rcc_semantic.c b/rcc_semantic.c index c88a604..8ca40a4 100644 --- a/rcc_semantic.c +++ b/rcc_semantic.c @@ -8298,7 +8298,19 @@ void c_do_computed_goto(rcc_ctx *rcc, c_value *v) ir_BEGIN(IR_UNUSED); } -static void c_do_init(void *addr, c_value *val) +static void c_do_init_vector(rcc_ctx *rcc, void *addr, c_value *val) +{ + IR_ASSERT(c_value_is_ref(val) && IR_IS_CONST_REF(val->u.ref)); + if (rcc->active_ctx->ir_base[val->u.ref].op == IR_SYM) { + IR_ASSERT(val->u.val.ptr); + memcpy(addr, val->u.val.ptr, val->type->size); + } else { + IR_ASSERT(rcc->active_ctx->ir_base[val->u.ref].op == IR_LONG_CONST); + memcpy(addr, ir_long_const_ptr(rcc->active_ctx, val->u.ref), val->type->size); + } +} + +static void c_do_init(rcc_ctx *rcc, void *addr, c_value *val) { const c_type *type = val->type; c_type_kind kind = type->kind; @@ -8329,6 +8341,7 @@ static void c_do_init(void *addr, c_value *val) case C_TYPE_STRUCT: case C_TYPE_UNION: memcpy(addr, val->u.val.ptr, type->size); break; case C_TYPE_ENUM: kind = type->enumeration.kind; goto repeat; + case C_TYPE_VECTOR: c_do_init_vector(rcc, addr, val); break; default: IR_ASSERT(0); } } @@ -8456,7 +8469,7 @@ void c_do_init_obj(rcc_ctx *rcc, c_sym *obj, c_value *val) if (!c_value_is_const(val) && !c_linker_fix_reloc(rcc, obj, 0, val)) { yy_error("initializer element is not constant"); } - c_do_init(obj->value.u.val.ptr, val); + c_do_init(rcc, obj->value.u.val.ptr, val); } else if (C_IS_TYPE_SCALAR_OR_PTR(obj->value.type) || obj->value.type->kind == C_TYPE_VECTOR) { IR_ASSERT(c_value_is_ref(&obj->value)); if (rcc->active_ctx->ir_base[obj->value.u.ref].op == IR_VAR) { @@ -8865,7 +8878,9 @@ void c_do_init_set(rcc_ctx *rcc, c_sym *obj, c_init *init, c_value *val) * We have to remove relocations added previously. */ c_linker_del_reloc(rcc, obj, offset); } - if (!c_value_is_const(val) && !c_linker_fix_reloc(rcc, obj, offset, val)) { + if (!c_value_is_const(val) + && !c_linker_fix_reloc(rcc, obj, offset, val) + && !(IR_IS_CONST_REF(val->u.ref) && val->type->kind == C_TYPE_VECTOR)) { yy_error("initializer element is not constant"); } IR_ASSERT(/*obj->value.u.type == IR_ADDR &&*/ obj->value.u.val.ptr); @@ -8874,7 +8889,7 @@ void c_do_init_set(rcc_ctx *rcc, c_sym *obj, c_init *init, c_value *val) init->size = new_size; } if (!C_IS_BIT_FIELD(bit_field)) { - c_do_init((char*)obj->value.u.val.ptr + offset, val); + c_do_init(rcc, (char*)obj->value.u.val.ptr + offset, val); } else { uint32_t first_bit = C_BIT_FIELD_START(bit_field); uint32_t bits = C_BIT_FIELD_SIZE(bit_field); @@ -8949,7 +8964,6 @@ void c_do_init_set(rcc_ctx *rcc, c_sym *obj, c_init *init, c_value *val) ir_ref ref; offset -= t->vec.type->size * init->stack[init->level].pos; - IR_ASSERT(offset == 0); if (init->stack[init->level].pos == 0) { ir_val v; v.u64 = 0; From cf2f2c0e323f63041355245c7d590cbeedb04537 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Tue, 7 Jul 2026 14:52:29 +0300 Subject: [PATCH 06/31] Support for __builtin_convertvector() --- c.g | 8 ++++++ rcc.h | 4 +++ rcc_parser.c | 77 ++++++++++++++++++++++++++++++-------------------- rcc_semantic.c | 53 ++++++++++++++++++++++++++++++++++ 4 files changed, 112 insertions(+), 30 deletions(-) diff --git a/c.g b/c.g index ccfe738..1a82b1c 100644 --- a/c.g +++ b/c.g @@ -1205,6 +1205,8 @@ unary_expression(rcc_ctx *rcc, c_value *val): | "__builtin_umul_overflow" | "__builtin_umull_overflow" | "__builtin_umulll_overflow" + | "__builtin_shuffle" + | "__builtin_shufflevector" ) "(" builtin_parameters(rcc, &v, name) ")" | {ir_ref old = c_do_nocode(rcc);} @@ -1218,6 +1220,12 @@ unary_expression(rcc_ctx *rcc, c_value *val): "," type_name(rcc, &t) {c_do_builtin_va_arg(rcc, &v, t);} ")" + | "__builtin_convertvector" + "(" + assignment_expression(rcc, &v) + "," + type_name(rcc, &t) {c_do_builtin_convertvector(rcc, &v, t);} + ")" ) ( {c_value dim;} {c_value_clear(&dim);} diff --git a/rcc.h b/rcc.h index 7725c8d..c026643 100644 --- a/rcc.h +++ b/rcc.h @@ -233,6 +233,9 @@ _("__builtin_umul_overflow", YY___BUILTIN_UMUL_OVERFLOW) \ _("__builtin_umull_overflow", YY___BUILTIN_UMULL_OVERFLOW) \ _("__builtin_umulll_overflow", YY___BUILTIN_UMULLL_OVERFLOW) \ + _("__builtin_convertvector", YY___BUILTIN_CONVERTVECTOR) \ + _("__builtin_shuffle", YY___BUILTIN_SHUFFLE) \ + _("__builtin_shufflevector", YY___BUILTIN_SHUFFLEVECTOR) \ _("__builtin_expect", YY___BUILTIN_EXPECT) \ _("__builtin_prefetch", YY___BUILTIN_PREFETCH) \ _("__builtin_unreachable", YY___BUILTIN_UNREACHABLE) \ @@ -1155,6 +1158,7 @@ c_value *c_do_grow_actual_parameters(c_value *args, int32_t num_args); void c_do_builtin(rcc_ctx *rcc, c_value *val, c_name name, int32_t num_args, c_value *args); void c_do_builtin_constant_p(rcc_ctx *rcc, c_value *val); void c_do_builtin_va_arg(rcc_ctx *rcc, c_value *val, const c_type *type); +void c_do_builtin_convertvector(rcc_ctx *rcc, c_value *val, const c_type *type); void c_do_call(rcc_ctx *rcc, c_value *func, int32_t num_args, c_value *args, c_value *res); void c_do_binary_op(rcc_ctx *rcc, yy_sym sym, c_value *v, c_value *op2); void c_do_assign_op(rcc_ctx *rcc, yy_sym sym, c_value *v, c_value *op2); diff --git a/rcc_parser.c b/rcc_parser.c index 6b5fa3a..540ea4c 100644 --- a/rcc_parser.c +++ b/rcc_parser.c @@ -315,7 +315,7 @@ static yy_sym parse_declaration(yy_sym sym, rcc_ctx *rcc, uint32_t flags) { /* Use IR_TAILCALL in val.u.proto to prevent inlining */ val.u.proto = IR_TAILCALL; sym = get_sym(); - if (sym == YY__LPAREN || C_IS_ID(sym) || sym == YY_DECIMAL_NUMBER || sym == YY_OCTAL_NUMBER || sym == YY_HEXADECIMAL_NUMBER || sym == YY_BINARY_NUMBER || sym == YY_FLOATING_NUMBER || sym == YY_HEXADECIMAL_FLOATING_NUMBER || sym == YY_CHARACTER || sym == YY_STRING || sym == YY__GENERIC || sym == YY___EXTENSION__ || sym == YY__PLUS_PLUS || sym == YY__MINUS_MINUS || sym == YY__AND || sym == YY__STAR || sym == YY__PLUS || sym == YY__MINUS || sym == YY__TILDE || sym == YY__BANG || sym == YY_SIZEOF || sym == YY__ALIGNOF || sym == YY___ALIGNOF__ || sym == YY___ALIGNOF || sym == YY__AND_AND || sym == YY___BUILTIN_VA_START || sym == YY___BUILTIN_VA_END || sym == YY___BUILTIN_VA_COPY || sym == YY___BUILTIN_ALLOCA || sym == YY___BUILTIN_ABORT || sym == YY___BUILTIN_TRAP || sym == YY___BUILTIN_DEBUGTRAP || sym == YY___BUILTIN_FRAME_ADDRESS || sym == YY___BUILTIN_ABS || sym == YY___BUILTIN_LABS || sym == YY___BUILTIN_LLABS || sym == YY___BUILTIN_FABS || sym == YY___BUILTIN_FABSF || sym == YY___BUILTIN_BSWAP16 || sym == YY___BUILTIN_BSWAP32 || sym == YY___BUILTIN_BSWAP64 || sym == YY___BUILTIN_POPCOUNT || sym == YY___BUILTIN_POPCOUNTL || sym == YY___BUILTIN_POPCOUNTLL || sym == YY___BUILTIN_CLZ || sym == YY___BUILTIN_CLZL || sym == YY___BUILTIN_CLZLL || sym == YY___BUILTIN_CTZ || sym == YY___BUILTIN_CTZL || sym == YY___BUILTIN_CTZLL || sym == YY___BUILTIN_FFS || sym == YY___BUILTIN_FFSL || sym == YY___BUILTIN_FFSLL || sym == YY___BUILTIN_MEMCPY || sym == YY___BUILTIN_MEMSET || sym == YY___BUILTIN_EXPECT || sym == YY___BUILTIN_PREFETCH || sym == YY___BUILTIN_UNREACHABLE || sym == YY___BUILTIN_HUGE_VAL || sym == YY___BUILTIN_HUGE_VALF || sym == YY___BUILTIN_INF || sym == YY___BUILTIN_INFF || sym == YY___BUILTIN_ISUNORDERED || sym == YY___BUILTIN_NAN || sym == YY___BUILTIN_NANF || sym == YY___BUILTIN_ADD_OVERFLOW || sym == YY___BUILTIN_ADD_OVERFLOW_P || sym == YY___BUILTIN_SADD_OVERFLOW || sym == YY___BUILTIN_SADDL_OVERFLOW || sym == YY___BUILTIN_SADDLL_OVERFLOW || sym == YY___BUILTIN_UADD_OVERFLOW || sym == YY___BUILTIN_UADDL_OVERFLOW || sym == YY___BUILTIN_UADDLL_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW_P || sym == YY___BUILTIN_SSUB_OVERFLOW || sym == YY___BUILTIN_SSUBL_OVERFLOW || sym == YY___BUILTIN_SSUBLL_OVERFLOW || sym == YY___BUILTIN_USUB_OVERFLOW || sym == YY___BUILTIN_USUBL_OVERFLOW || sym == YY___BUILTIN_USUBLL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW_P || sym == YY___BUILTIN_SMUL_OVERFLOW || sym == YY___BUILTIN_SMULL_OVERFLOW || sym == YY___BUILTIN_SMULLL_OVERFLOW || sym == YY___BUILTIN_UMUL_OVERFLOW || sym == YY___BUILTIN_UMULL_OVERFLOW || sym == YY___BUILTIN_UMULLL_OVERFLOW || sym == YY___BUILTIN_CONSTANT_P || sym == YY___BUILTIN_VA_ARG) { + if (sym == YY__LPAREN || C_IS_ID(sym) || sym == YY_DECIMAL_NUMBER || sym == YY_OCTAL_NUMBER || sym == YY_HEXADECIMAL_NUMBER || sym == YY_BINARY_NUMBER || sym == YY_FLOATING_NUMBER || sym == YY_HEXADECIMAL_FLOATING_NUMBER || sym == YY_CHARACTER || sym == YY_STRING || sym == YY__GENERIC || sym == YY___EXTENSION__ || sym == YY__PLUS_PLUS || sym == YY__MINUS_MINUS || sym == YY__AND || sym == YY__STAR || sym == YY__PLUS || sym == YY__MINUS || sym == YY__TILDE || sym == YY__BANG || sym == YY_SIZEOF || sym == YY__ALIGNOF || sym == YY___ALIGNOF__ || sym == YY___ALIGNOF || sym == YY__AND_AND || sym == YY___BUILTIN_VA_START || sym == YY___BUILTIN_VA_END || sym == YY___BUILTIN_VA_COPY || sym == YY___BUILTIN_ALLOCA || sym == YY___BUILTIN_ABORT || sym == YY___BUILTIN_TRAP || sym == YY___BUILTIN_DEBUGTRAP || sym == YY___BUILTIN_FRAME_ADDRESS || sym == YY___BUILTIN_ABS || sym == YY___BUILTIN_LABS || sym == YY___BUILTIN_LLABS || sym == YY___BUILTIN_FABS || sym == YY___BUILTIN_FABSF || sym == YY___BUILTIN_BSWAP16 || sym == YY___BUILTIN_BSWAP32 || sym == YY___BUILTIN_BSWAP64 || sym == YY___BUILTIN_POPCOUNT || sym == YY___BUILTIN_POPCOUNTL || sym == YY___BUILTIN_POPCOUNTLL || sym == YY___BUILTIN_CLZ || sym == YY___BUILTIN_CLZL || sym == YY___BUILTIN_CLZLL || sym == YY___BUILTIN_CTZ || sym == YY___BUILTIN_CTZL || sym == YY___BUILTIN_CTZLL || sym == YY___BUILTIN_FFS || sym == YY___BUILTIN_FFSL || sym == YY___BUILTIN_FFSLL || sym == YY___BUILTIN_MEMCPY || sym == YY___BUILTIN_MEMSET || sym == YY___BUILTIN_EXPECT || sym == YY___BUILTIN_PREFETCH || sym == YY___BUILTIN_UNREACHABLE || sym == YY___BUILTIN_HUGE_VAL || sym == YY___BUILTIN_HUGE_VALF || sym == YY___BUILTIN_INF || sym == YY___BUILTIN_INFF || sym == YY___BUILTIN_ISUNORDERED || sym == YY___BUILTIN_NAN || sym == YY___BUILTIN_NANF || sym == YY___BUILTIN_ADD_OVERFLOW || sym == YY___BUILTIN_ADD_OVERFLOW_P || sym == YY___BUILTIN_SADD_OVERFLOW || sym == YY___BUILTIN_SADDL_OVERFLOW || sym == YY___BUILTIN_SADDLL_OVERFLOW || sym == YY___BUILTIN_UADD_OVERFLOW || sym == YY___BUILTIN_UADDL_OVERFLOW || sym == YY___BUILTIN_UADDLL_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW_P || sym == YY___BUILTIN_SSUB_OVERFLOW || sym == YY___BUILTIN_SSUBL_OVERFLOW || sym == YY___BUILTIN_SSUBLL_OVERFLOW || sym == YY___BUILTIN_USUB_OVERFLOW || sym == YY___BUILTIN_USUBL_OVERFLOW || sym == YY___BUILTIN_USUBLL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW_P || sym == YY___BUILTIN_SMUL_OVERFLOW || sym == YY___BUILTIN_SMULL_OVERFLOW || sym == YY___BUILTIN_SMULLL_OVERFLOW || sym == YY___BUILTIN_UMUL_OVERFLOW || sym == YY___BUILTIN_UMULL_OVERFLOW || sym == YY___BUILTIN_UMULLL_OVERFLOW || sym == YY___BUILTIN_SHUFFLE || sym == YY___BUILTIN_SHUFFLEVECTOR || sym == YY___BUILTIN_CONSTANT_P || sym == YY___BUILTIN_VA_ARG || sym == YY___BUILTIN_CONVERTVECTOR) { sym = parse_expression(sym, rcc, &val); } if (sym != YY__SEMICOLON) { @@ -597,7 +597,7 @@ static yy_sym parse_type_specifier_or_qualifier(yy_sym sym, rcc_ctx *rcc, c_dcl sym = get_sym(); if ((sym == YY_VOID || sym == YY_CHAR || sym == YY_SHORT || sym == YY_INT || sym == YY_LONG || sym == YY_FLOAT || sym == YY_DOUBLE || sym == YY_SIGNED || sym == YY___SIGNED || sym == YY___SIGNED__ || sym == YY_UNSIGNED || sym == YY__BOOL || sym == YY__COMPLEX || sym == YY___COMPLEX || sym == YY___COMPLEX__ || sym == YY__ATOMIC || sym == YY_TYPEOF || sym == YY___TYPEOF || sym == YY___TYPEOF__ || sym == YY_STRUCT || sym == YY_UNION || sym == YY_ENUM || C_IS_ID(sym) || sym == YY_CONST || sym == YY___CONST || sym == YY___CONST__ || sym == YY_RESTRICT || sym == YY___RESTRICT || sym == YY___RESTRICT__ || sym == YY_VOLATILE || sym == YY___VOLATILE || sym == YY___VOLATILE__ || sym == YY___ATTRIBUTE || sym == YY___ATTRIBUTE__ || sym == YY___DECLSPEC || sym == YY___CDECL || sym == YY___FASTCALL || sym == YY___UNALIGNED) && (!C_IS_ID(sym) || is_typedef_name(rcc, sym))) { sym = parse_type_name(sym, rcc, &d->type); - } else if (sym == YY__LPAREN || C_IS_ID(sym) || sym == YY_DECIMAL_NUMBER || sym == YY_OCTAL_NUMBER || sym == YY_HEXADECIMAL_NUMBER || sym == YY_BINARY_NUMBER || sym == YY_FLOATING_NUMBER || sym == YY_HEXADECIMAL_FLOATING_NUMBER || sym == YY_CHARACTER || sym == YY_STRING || sym == YY__GENERIC || sym == YY___EXTENSION__ || sym == YY__PLUS_PLUS || sym == YY__MINUS_MINUS || sym == YY__AND || sym == YY__STAR || sym == YY__PLUS || sym == YY__MINUS || sym == YY__TILDE || sym == YY__BANG || sym == YY_SIZEOF || sym == YY__ALIGNOF || sym == YY___ALIGNOF__ || sym == YY___ALIGNOF || sym == YY__AND_AND || sym == YY___BUILTIN_VA_START || sym == YY___BUILTIN_VA_END || sym == YY___BUILTIN_VA_COPY || sym == YY___BUILTIN_ALLOCA || sym == YY___BUILTIN_ABORT || sym == YY___BUILTIN_TRAP || sym == YY___BUILTIN_DEBUGTRAP || sym == YY___BUILTIN_FRAME_ADDRESS || sym == YY___BUILTIN_ABS || sym == YY___BUILTIN_LABS || sym == YY___BUILTIN_LLABS || sym == YY___BUILTIN_FABS || sym == YY___BUILTIN_FABSF || sym == YY___BUILTIN_BSWAP16 || sym == YY___BUILTIN_BSWAP32 || sym == YY___BUILTIN_BSWAP64 || sym == YY___BUILTIN_POPCOUNT || sym == YY___BUILTIN_POPCOUNTL || sym == YY___BUILTIN_POPCOUNTLL || sym == YY___BUILTIN_CLZ || sym == YY___BUILTIN_CLZL || sym == YY___BUILTIN_CLZLL || sym == YY___BUILTIN_CTZ || sym == YY___BUILTIN_CTZL || sym == YY___BUILTIN_CTZLL || sym == YY___BUILTIN_FFS || sym == YY___BUILTIN_FFSL || sym == YY___BUILTIN_FFSLL || sym == YY___BUILTIN_MEMCPY || sym == YY___BUILTIN_MEMSET || sym == YY___BUILTIN_EXPECT || sym == YY___BUILTIN_PREFETCH || sym == YY___BUILTIN_UNREACHABLE || sym == YY___BUILTIN_HUGE_VAL || sym == YY___BUILTIN_HUGE_VALF || sym == YY___BUILTIN_INF || sym == YY___BUILTIN_INFF || sym == YY___BUILTIN_ISUNORDERED || sym == YY___BUILTIN_NAN || sym == YY___BUILTIN_NANF || sym == YY___BUILTIN_ADD_OVERFLOW || sym == YY___BUILTIN_ADD_OVERFLOW_P || sym == YY___BUILTIN_SADD_OVERFLOW || sym == YY___BUILTIN_SADDL_OVERFLOW || sym == YY___BUILTIN_SADDLL_OVERFLOW || sym == YY___BUILTIN_UADD_OVERFLOW || sym == YY___BUILTIN_UADDL_OVERFLOW || sym == YY___BUILTIN_UADDLL_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW_P || sym == YY___BUILTIN_SSUB_OVERFLOW || sym == YY___BUILTIN_SSUBL_OVERFLOW || sym == YY___BUILTIN_SSUBLL_OVERFLOW || sym == YY___BUILTIN_USUB_OVERFLOW || sym == YY___BUILTIN_USUBL_OVERFLOW || sym == YY___BUILTIN_USUBLL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW_P || sym == YY___BUILTIN_SMUL_OVERFLOW || sym == YY___BUILTIN_SMULL_OVERFLOW || sym == YY___BUILTIN_SMULLL_OVERFLOW || sym == YY___BUILTIN_UMUL_OVERFLOW || sym == YY___BUILTIN_UMULL_OVERFLOW || sym == YY___BUILTIN_UMULLL_OVERFLOW || sym == YY___BUILTIN_CONSTANT_P || sym == YY___BUILTIN_VA_ARG) { + } else if (sym == YY__LPAREN || C_IS_ID(sym) || sym == YY_DECIMAL_NUMBER || sym == YY_OCTAL_NUMBER || sym == YY_HEXADECIMAL_NUMBER || sym == YY_BINARY_NUMBER || sym == YY_FLOATING_NUMBER || sym == YY_HEXADECIMAL_FLOATING_NUMBER || sym == YY_CHARACTER || sym == YY_STRING || sym == YY__GENERIC || sym == YY___EXTENSION__ || sym == YY__PLUS_PLUS || sym == YY__MINUS_MINUS || sym == YY__AND || sym == YY__STAR || sym == YY__PLUS || sym == YY__MINUS || sym == YY__TILDE || sym == YY__BANG || sym == YY_SIZEOF || sym == YY__ALIGNOF || sym == YY___ALIGNOF__ || sym == YY___ALIGNOF || sym == YY__AND_AND || sym == YY___BUILTIN_VA_START || sym == YY___BUILTIN_VA_END || sym == YY___BUILTIN_VA_COPY || sym == YY___BUILTIN_ALLOCA || sym == YY___BUILTIN_ABORT || sym == YY___BUILTIN_TRAP || sym == YY___BUILTIN_DEBUGTRAP || sym == YY___BUILTIN_FRAME_ADDRESS || sym == YY___BUILTIN_ABS || sym == YY___BUILTIN_LABS || sym == YY___BUILTIN_LLABS || sym == YY___BUILTIN_FABS || sym == YY___BUILTIN_FABSF || sym == YY___BUILTIN_BSWAP16 || sym == YY___BUILTIN_BSWAP32 || sym == YY___BUILTIN_BSWAP64 || sym == YY___BUILTIN_POPCOUNT || sym == YY___BUILTIN_POPCOUNTL || sym == YY___BUILTIN_POPCOUNTLL || sym == YY___BUILTIN_CLZ || sym == YY___BUILTIN_CLZL || sym == YY___BUILTIN_CLZLL || sym == YY___BUILTIN_CTZ || sym == YY___BUILTIN_CTZL || sym == YY___BUILTIN_CTZLL || sym == YY___BUILTIN_FFS || sym == YY___BUILTIN_FFSL || sym == YY___BUILTIN_FFSLL || sym == YY___BUILTIN_MEMCPY || sym == YY___BUILTIN_MEMSET || sym == YY___BUILTIN_EXPECT || sym == YY___BUILTIN_PREFETCH || sym == YY___BUILTIN_UNREACHABLE || sym == YY___BUILTIN_HUGE_VAL || sym == YY___BUILTIN_HUGE_VALF || sym == YY___BUILTIN_INF || sym == YY___BUILTIN_INFF || sym == YY___BUILTIN_ISUNORDERED || sym == YY___BUILTIN_NAN || sym == YY___BUILTIN_NANF || sym == YY___BUILTIN_ADD_OVERFLOW || sym == YY___BUILTIN_ADD_OVERFLOW_P || sym == YY___BUILTIN_SADD_OVERFLOW || sym == YY___BUILTIN_SADDL_OVERFLOW || sym == YY___BUILTIN_SADDLL_OVERFLOW || sym == YY___BUILTIN_UADD_OVERFLOW || sym == YY___BUILTIN_UADDL_OVERFLOW || sym == YY___BUILTIN_UADDLL_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW_P || sym == YY___BUILTIN_SSUB_OVERFLOW || sym == YY___BUILTIN_SSUBL_OVERFLOW || sym == YY___BUILTIN_SSUBLL_OVERFLOW || sym == YY___BUILTIN_USUB_OVERFLOW || sym == YY___BUILTIN_USUBL_OVERFLOW || sym == YY___BUILTIN_USUBLL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW_P || sym == YY___BUILTIN_SMUL_OVERFLOW || sym == YY___BUILTIN_SMULL_OVERFLOW || sym == YY___BUILTIN_SMULLL_OVERFLOW || sym == YY___BUILTIN_UMUL_OVERFLOW || sym == YY___BUILTIN_UMULL_OVERFLOW || sym == YY___BUILTIN_UMULLL_OVERFLOW || sym == YY___BUILTIN_SHUFFLE || sym == YY___BUILTIN_SHUFFLEVECTOR || sym == YY___BUILTIN_CONSTANT_P || sym == YY___BUILTIN_VA_ARG || sym == YY___BUILTIN_CONVERTVECTOR) { c_value v; ir_ref old = c_do_nocode(rcc); c_value_clear(&v); @@ -687,7 +687,7 @@ static yy_sym parse_alignment_specifier(yy_sym sym, rcc_ctx *rcc, c_dcl *d) { const c_type *t; sym = parse_type_name(sym, rcc, &t); d->attr |= t->attr & C_ATTR_ALIGN_MASK; - } else if (sym == YY__LPAREN || C_IS_ID(sym) || sym == YY_DECIMAL_NUMBER || sym == YY_OCTAL_NUMBER || sym == YY_HEXADECIMAL_NUMBER || sym == YY_BINARY_NUMBER || sym == YY_FLOATING_NUMBER || sym == YY_HEXADECIMAL_FLOATING_NUMBER || sym == YY_CHARACTER || sym == YY_STRING || sym == YY__GENERIC || sym == YY___EXTENSION__ || sym == YY__PLUS_PLUS || sym == YY__MINUS_MINUS || sym == YY__AND || sym == YY__STAR || sym == YY__PLUS || sym == YY__MINUS || sym == YY__TILDE || sym == YY__BANG || sym == YY_SIZEOF || sym == YY__ALIGNOF || sym == YY___ALIGNOF__ || sym == YY___ALIGNOF || sym == YY__AND_AND || sym == YY___BUILTIN_VA_START || sym == YY___BUILTIN_VA_END || sym == YY___BUILTIN_VA_COPY || sym == YY___BUILTIN_ALLOCA || sym == YY___BUILTIN_ABORT || sym == YY___BUILTIN_TRAP || sym == YY___BUILTIN_DEBUGTRAP || sym == YY___BUILTIN_FRAME_ADDRESS || sym == YY___BUILTIN_ABS || sym == YY___BUILTIN_LABS || sym == YY___BUILTIN_LLABS || sym == YY___BUILTIN_FABS || sym == YY___BUILTIN_FABSF || sym == YY___BUILTIN_BSWAP16 || sym == YY___BUILTIN_BSWAP32 || sym == YY___BUILTIN_BSWAP64 || sym == YY___BUILTIN_POPCOUNT || sym == YY___BUILTIN_POPCOUNTL || sym == YY___BUILTIN_POPCOUNTLL || sym == YY___BUILTIN_CLZ || sym == YY___BUILTIN_CLZL || sym == YY___BUILTIN_CLZLL || sym == YY___BUILTIN_CTZ || sym == YY___BUILTIN_CTZL || sym == YY___BUILTIN_CTZLL || sym == YY___BUILTIN_FFS || sym == YY___BUILTIN_FFSL || sym == YY___BUILTIN_FFSLL || sym == YY___BUILTIN_MEMCPY || sym == YY___BUILTIN_MEMSET || sym == YY___BUILTIN_EXPECT || sym == YY___BUILTIN_PREFETCH || sym == YY___BUILTIN_UNREACHABLE || sym == YY___BUILTIN_HUGE_VAL || sym == YY___BUILTIN_HUGE_VALF || sym == YY___BUILTIN_INF || sym == YY___BUILTIN_INFF || sym == YY___BUILTIN_ISUNORDERED || sym == YY___BUILTIN_NAN || sym == YY___BUILTIN_NANF || sym == YY___BUILTIN_ADD_OVERFLOW || sym == YY___BUILTIN_ADD_OVERFLOW_P || sym == YY___BUILTIN_SADD_OVERFLOW || sym == YY___BUILTIN_SADDL_OVERFLOW || sym == YY___BUILTIN_SADDLL_OVERFLOW || sym == YY___BUILTIN_UADD_OVERFLOW || sym == YY___BUILTIN_UADDL_OVERFLOW || sym == YY___BUILTIN_UADDLL_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW_P || sym == YY___BUILTIN_SSUB_OVERFLOW || sym == YY___BUILTIN_SSUBL_OVERFLOW || sym == YY___BUILTIN_SSUBLL_OVERFLOW || sym == YY___BUILTIN_USUB_OVERFLOW || sym == YY___BUILTIN_USUBL_OVERFLOW || sym == YY___BUILTIN_USUBLL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW_P || sym == YY___BUILTIN_SMUL_OVERFLOW || sym == YY___BUILTIN_SMULL_OVERFLOW || sym == YY___BUILTIN_SMULLL_OVERFLOW || sym == YY___BUILTIN_UMUL_OVERFLOW || sym == YY___BUILTIN_UMULL_OVERFLOW || sym == YY___BUILTIN_UMULLL_OVERFLOW || sym == YY___BUILTIN_CONSTANT_P || sym == YY___BUILTIN_VA_ARG) { + } else if (sym == YY__LPAREN || C_IS_ID(sym) || sym == YY_DECIMAL_NUMBER || sym == YY_OCTAL_NUMBER || sym == YY_HEXADECIMAL_NUMBER || sym == YY_BINARY_NUMBER || sym == YY_FLOATING_NUMBER || sym == YY_HEXADECIMAL_FLOATING_NUMBER || sym == YY_CHARACTER || sym == YY_STRING || sym == YY__GENERIC || sym == YY___EXTENSION__ || sym == YY__PLUS_PLUS || sym == YY__MINUS_MINUS || sym == YY__AND || sym == YY__STAR || sym == YY__PLUS || sym == YY__MINUS || sym == YY__TILDE || sym == YY__BANG || sym == YY_SIZEOF || sym == YY__ALIGNOF || sym == YY___ALIGNOF__ || sym == YY___ALIGNOF || sym == YY__AND_AND || sym == YY___BUILTIN_VA_START || sym == YY___BUILTIN_VA_END || sym == YY___BUILTIN_VA_COPY || sym == YY___BUILTIN_ALLOCA || sym == YY___BUILTIN_ABORT || sym == YY___BUILTIN_TRAP || sym == YY___BUILTIN_DEBUGTRAP || sym == YY___BUILTIN_FRAME_ADDRESS || sym == YY___BUILTIN_ABS || sym == YY___BUILTIN_LABS || sym == YY___BUILTIN_LLABS || sym == YY___BUILTIN_FABS || sym == YY___BUILTIN_FABSF || sym == YY___BUILTIN_BSWAP16 || sym == YY___BUILTIN_BSWAP32 || sym == YY___BUILTIN_BSWAP64 || sym == YY___BUILTIN_POPCOUNT || sym == YY___BUILTIN_POPCOUNTL || sym == YY___BUILTIN_POPCOUNTLL || sym == YY___BUILTIN_CLZ || sym == YY___BUILTIN_CLZL || sym == YY___BUILTIN_CLZLL || sym == YY___BUILTIN_CTZ || sym == YY___BUILTIN_CTZL || sym == YY___BUILTIN_CTZLL || sym == YY___BUILTIN_FFS || sym == YY___BUILTIN_FFSL || sym == YY___BUILTIN_FFSLL || sym == YY___BUILTIN_MEMCPY || sym == YY___BUILTIN_MEMSET || sym == YY___BUILTIN_EXPECT || sym == YY___BUILTIN_PREFETCH || sym == YY___BUILTIN_UNREACHABLE || sym == YY___BUILTIN_HUGE_VAL || sym == YY___BUILTIN_HUGE_VALF || sym == YY___BUILTIN_INF || sym == YY___BUILTIN_INFF || sym == YY___BUILTIN_ISUNORDERED || sym == YY___BUILTIN_NAN || sym == YY___BUILTIN_NANF || sym == YY___BUILTIN_ADD_OVERFLOW || sym == YY___BUILTIN_ADD_OVERFLOW_P || sym == YY___BUILTIN_SADD_OVERFLOW || sym == YY___BUILTIN_SADDL_OVERFLOW || sym == YY___BUILTIN_SADDLL_OVERFLOW || sym == YY___BUILTIN_UADD_OVERFLOW || sym == YY___BUILTIN_UADDL_OVERFLOW || sym == YY___BUILTIN_UADDLL_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW_P || sym == YY___BUILTIN_SSUB_OVERFLOW || sym == YY___BUILTIN_SSUBL_OVERFLOW || sym == YY___BUILTIN_SSUBLL_OVERFLOW || sym == YY___BUILTIN_USUB_OVERFLOW || sym == YY___BUILTIN_USUBL_OVERFLOW || sym == YY___BUILTIN_USUBLL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW_P || sym == YY___BUILTIN_SMUL_OVERFLOW || sym == YY___BUILTIN_SMULL_OVERFLOW || sym == YY___BUILTIN_SMULLL_OVERFLOW || sym == YY___BUILTIN_UMUL_OVERFLOW || sym == YY___BUILTIN_UMULL_OVERFLOW || sym == YY___BUILTIN_UMULLL_OVERFLOW || sym == YY___BUILTIN_SHUFFLE || sym == YY___BUILTIN_SHUFFLEVECTOR || sym == YY___BUILTIN_CONSTANT_P || sym == YY___BUILTIN_VA_ARG || sym == YY___BUILTIN_CONVERTVECTOR) { c_value_clear(&v); sym = parse_constant_expression(sym, rcc, &v); c_alignas_expr(rcc, d, &v); @@ -1356,7 +1356,7 @@ static yy_sym parse_array_declarator(yy_sym sym, rcc_ctx *rcc, c_dcl *d, bool is attr |= C_ATTR_VLA; } else if (sym == YY__RBRACK) { attr |= C_ATTR_FLEXIBLE; - } else if (sym == YY__LPAREN || C_IS_ID(sym) || sym == YY_DECIMAL_NUMBER || sym == YY_OCTAL_NUMBER || sym == YY_HEXADECIMAL_NUMBER || sym == YY_BINARY_NUMBER || sym == YY_FLOATING_NUMBER || sym == YY_HEXADECIMAL_FLOATING_NUMBER || sym == YY_CHARACTER || sym == YY_STRING || sym == YY__GENERIC || sym == YY___EXTENSION__ || sym == YY__PLUS_PLUS || sym == YY__MINUS_MINUS || sym == YY__AND || sym == YY__STAR || sym == YY__PLUS || sym == YY__MINUS || sym == YY__TILDE || sym == YY__BANG || sym == YY_SIZEOF || sym == YY__ALIGNOF || sym == YY___ALIGNOF__ || sym == YY___ALIGNOF || sym == YY__AND_AND || sym == YY___BUILTIN_VA_START || sym == YY___BUILTIN_VA_END || sym == YY___BUILTIN_VA_COPY || sym == YY___BUILTIN_ALLOCA || sym == YY___BUILTIN_ABORT || sym == YY___BUILTIN_TRAP || sym == YY___BUILTIN_DEBUGTRAP || sym == YY___BUILTIN_FRAME_ADDRESS || sym == YY___BUILTIN_ABS || sym == YY___BUILTIN_LABS || sym == YY___BUILTIN_LLABS || sym == YY___BUILTIN_FABS || sym == YY___BUILTIN_FABSF || sym == YY___BUILTIN_BSWAP16 || sym == YY___BUILTIN_BSWAP32 || sym == YY___BUILTIN_BSWAP64 || sym == YY___BUILTIN_POPCOUNT || sym == YY___BUILTIN_POPCOUNTL || sym == YY___BUILTIN_POPCOUNTLL || sym == YY___BUILTIN_CLZ || sym == YY___BUILTIN_CLZL || sym == YY___BUILTIN_CLZLL || sym == YY___BUILTIN_CTZ || sym == YY___BUILTIN_CTZL || sym == YY___BUILTIN_CTZLL || sym == YY___BUILTIN_FFS || sym == YY___BUILTIN_FFSL || sym == YY___BUILTIN_FFSLL || sym == YY___BUILTIN_MEMCPY || sym == YY___BUILTIN_MEMSET || sym == YY___BUILTIN_EXPECT || sym == YY___BUILTIN_PREFETCH || sym == YY___BUILTIN_UNREACHABLE || sym == YY___BUILTIN_HUGE_VAL || sym == YY___BUILTIN_HUGE_VALF || sym == YY___BUILTIN_INF || sym == YY___BUILTIN_INFF || sym == YY___BUILTIN_ISUNORDERED || sym == YY___BUILTIN_NAN || sym == YY___BUILTIN_NANF || sym == YY___BUILTIN_ADD_OVERFLOW || sym == YY___BUILTIN_ADD_OVERFLOW_P || sym == YY___BUILTIN_SADD_OVERFLOW || sym == YY___BUILTIN_SADDL_OVERFLOW || sym == YY___BUILTIN_SADDLL_OVERFLOW || sym == YY___BUILTIN_UADD_OVERFLOW || sym == YY___BUILTIN_UADDL_OVERFLOW || sym == YY___BUILTIN_UADDLL_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW_P || sym == YY___BUILTIN_SSUB_OVERFLOW || sym == YY___BUILTIN_SSUBL_OVERFLOW || sym == YY___BUILTIN_SSUBLL_OVERFLOW || sym == YY___BUILTIN_USUB_OVERFLOW || sym == YY___BUILTIN_USUBL_OVERFLOW || sym == YY___BUILTIN_USUBLL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW_P || sym == YY___BUILTIN_SMUL_OVERFLOW || sym == YY___BUILTIN_SMULL_OVERFLOW || sym == YY___BUILTIN_SMULLL_OVERFLOW || sym == YY___BUILTIN_UMUL_OVERFLOW || sym == YY___BUILTIN_UMULL_OVERFLOW || sym == YY___BUILTIN_UMULLL_OVERFLOW || sym == YY___BUILTIN_CONSTANT_P || sym == YY___BUILTIN_VA_ARG) { + } else if (sym == YY__LPAREN || C_IS_ID(sym) || sym == YY_DECIMAL_NUMBER || sym == YY_OCTAL_NUMBER || sym == YY_HEXADECIMAL_NUMBER || sym == YY_BINARY_NUMBER || sym == YY_FLOATING_NUMBER || sym == YY_HEXADECIMAL_FLOATING_NUMBER || sym == YY_CHARACTER || sym == YY_STRING || sym == YY__GENERIC || sym == YY___EXTENSION__ || sym == YY__PLUS_PLUS || sym == YY__MINUS_MINUS || sym == YY__AND || sym == YY__STAR || sym == YY__PLUS || sym == YY__MINUS || sym == YY__TILDE || sym == YY__BANG || sym == YY_SIZEOF || sym == YY__ALIGNOF || sym == YY___ALIGNOF__ || sym == YY___ALIGNOF || sym == YY__AND_AND || sym == YY___BUILTIN_VA_START || sym == YY___BUILTIN_VA_END || sym == YY___BUILTIN_VA_COPY || sym == YY___BUILTIN_ALLOCA || sym == YY___BUILTIN_ABORT || sym == YY___BUILTIN_TRAP || sym == YY___BUILTIN_DEBUGTRAP || sym == YY___BUILTIN_FRAME_ADDRESS || sym == YY___BUILTIN_ABS || sym == YY___BUILTIN_LABS || sym == YY___BUILTIN_LLABS || sym == YY___BUILTIN_FABS || sym == YY___BUILTIN_FABSF || sym == YY___BUILTIN_BSWAP16 || sym == YY___BUILTIN_BSWAP32 || sym == YY___BUILTIN_BSWAP64 || sym == YY___BUILTIN_POPCOUNT || sym == YY___BUILTIN_POPCOUNTL || sym == YY___BUILTIN_POPCOUNTLL || sym == YY___BUILTIN_CLZ || sym == YY___BUILTIN_CLZL || sym == YY___BUILTIN_CLZLL || sym == YY___BUILTIN_CTZ || sym == YY___BUILTIN_CTZL || sym == YY___BUILTIN_CTZLL || sym == YY___BUILTIN_FFS || sym == YY___BUILTIN_FFSL || sym == YY___BUILTIN_FFSLL || sym == YY___BUILTIN_MEMCPY || sym == YY___BUILTIN_MEMSET || sym == YY___BUILTIN_EXPECT || sym == YY___BUILTIN_PREFETCH || sym == YY___BUILTIN_UNREACHABLE || sym == YY___BUILTIN_HUGE_VAL || sym == YY___BUILTIN_HUGE_VALF || sym == YY___BUILTIN_INF || sym == YY___BUILTIN_INFF || sym == YY___BUILTIN_ISUNORDERED || sym == YY___BUILTIN_NAN || sym == YY___BUILTIN_NANF || sym == YY___BUILTIN_ADD_OVERFLOW || sym == YY___BUILTIN_ADD_OVERFLOW_P || sym == YY___BUILTIN_SADD_OVERFLOW || sym == YY___BUILTIN_SADDL_OVERFLOW || sym == YY___BUILTIN_SADDLL_OVERFLOW || sym == YY___BUILTIN_UADD_OVERFLOW || sym == YY___BUILTIN_UADDL_OVERFLOW || sym == YY___BUILTIN_UADDLL_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW_P || sym == YY___BUILTIN_SSUB_OVERFLOW || sym == YY___BUILTIN_SSUBL_OVERFLOW || sym == YY___BUILTIN_SSUBLL_OVERFLOW || sym == YY___BUILTIN_USUB_OVERFLOW || sym == YY___BUILTIN_USUBL_OVERFLOW || sym == YY___BUILTIN_USUBLL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW_P || sym == YY___BUILTIN_SMUL_OVERFLOW || sym == YY___BUILTIN_SMULL_OVERFLOW || sym == YY___BUILTIN_SMULLL_OVERFLOW || sym == YY___BUILTIN_UMUL_OVERFLOW || sym == YY___BUILTIN_UMULL_OVERFLOW || sym == YY___BUILTIN_UMULLL_OVERFLOW || sym == YY___BUILTIN_SHUFFLE || sym == YY___BUILTIN_SHUFFLEVECTOR || sym == YY___BUILTIN_CONSTANT_P || sym == YY___BUILTIN_VA_ARG || sym == YY___BUILTIN_CONVERTVECTOR) { if (!is_param || (sym = parse_vla_param(sym, rcc, &len)) != YY__RBRACK) sym = parse_assignment_expression(sym, rcc, &len); } else if (sym == YY_CONST || sym == YY___CONST || sym == YY___CONST__ || sym == YY_RESTRICT || sym == YY___RESTRICT || sym == YY___RESTRICT__ || sym == YY_VOLATILE || sym == YY___VOLATILE || sym == YY___VOLATILE__ || sym == YY__ATOMIC || sym == YY___ATTRIBUTE || sym == YY___ATTRIBUTE__ || sym == YY___DECLSPEC || sym == YY___CDECL || sym == YY___FASTCALL || sym == YY___UNALIGNED) { @@ -1368,7 +1368,7 @@ static yy_sym parse_array_declarator(yy_sym sym, rcc_ctx *rcc, c_dcl *d, bool is attr |= C_ATTR_VLA; } else if (sym == YY__RBRACK) { attr |= C_ATTR_FLEXIBLE; - } else if (sym == YY_STATIC || sym == YY__LPAREN || C_IS_ID(sym) || sym == YY_DECIMAL_NUMBER || sym == YY_OCTAL_NUMBER || sym == YY_HEXADECIMAL_NUMBER || sym == YY_BINARY_NUMBER || sym == YY_FLOATING_NUMBER || sym == YY_HEXADECIMAL_FLOATING_NUMBER || sym == YY_CHARACTER || sym == YY_STRING || sym == YY__GENERIC || sym == YY___EXTENSION__ || sym == YY__PLUS_PLUS || sym == YY__MINUS_MINUS || sym == YY__AND || sym == YY__STAR || sym == YY__PLUS || sym == YY__MINUS || sym == YY__TILDE || sym == YY__BANG || sym == YY_SIZEOF || sym == YY__ALIGNOF || sym == YY___ALIGNOF__ || sym == YY___ALIGNOF || sym == YY__AND_AND || sym == YY___BUILTIN_VA_START || sym == YY___BUILTIN_VA_END || sym == YY___BUILTIN_VA_COPY || sym == YY___BUILTIN_ALLOCA || sym == YY___BUILTIN_ABORT || sym == YY___BUILTIN_TRAP || sym == YY___BUILTIN_DEBUGTRAP || sym == YY___BUILTIN_FRAME_ADDRESS || sym == YY___BUILTIN_ABS || sym == YY___BUILTIN_LABS || sym == YY___BUILTIN_LLABS || sym == YY___BUILTIN_FABS || sym == YY___BUILTIN_FABSF || sym == YY___BUILTIN_BSWAP16 || sym == YY___BUILTIN_BSWAP32 || sym == YY___BUILTIN_BSWAP64 || sym == YY___BUILTIN_POPCOUNT || sym == YY___BUILTIN_POPCOUNTL || sym == YY___BUILTIN_POPCOUNTLL || sym == YY___BUILTIN_CLZ || sym == YY___BUILTIN_CLZL || sym == YY___BUILTIN_CLZLL || sym == YY___BUILTIN_CTZ || sym == YY___BUILTIN_CTZL || sym == YY___BUILTIN_CTZLL || sym == YY___BUILTIN_FFS || sym == YY___BUILTIN_FFSL || sym == YY___BUILTIN_FFSLL || sym == YY___BUILTIN_MEMCPY || sym == YY___BUILTIN_MEMSET || sym == YY___BUILTIN_EXPECT || sym == YY___BUILTIN_PREFETCH || sym == YY___BUILTIN_UNREACHABLE || sym == YY___BUILTIN_HUGE_VAL || sym == YY___BUILTIN_HUGE_VALF || sym == YY___BUILTIN_INF || sym == YY___BUILTIN_INFF || sym == YY___BUILTIN_ISUNORDERED || sym == YY___BUILTIN_NAN || sym == YY___BUILTIN_NANF || sym == YY___BUILTIN_ADD_OVERFLOW || sym == YY___BUILTIN_ADD_OVERFLOW_P || sym == YY___BUILTIN_SADD_OVERFLOW || sym == YY___BUILTIN_SADDL_OVERFLOW || sym == YY___BUILTIN_SADDLL_OVERFLOW || sym == YY___BUILTIN_UADD_OVERFLOW || sym == YY___BUILTIN_UADDL_OVERFLOW || sym == YY___BUILTIN_UADDLL_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW_P || sym == YY___BUILTIN_SSUB_OVERFLOW || sym == YY___BUILTIN_SSUBL_OVERFLOW || sym == YY___BUILTIN_SSUBLL_OVERFLOW || sym == YY___BUILTIN_USUB_OVERFLOW || sym == YY___BUILTIN_USUBL_OVERFLOW || sym == YY___BUILTIN_USUBLL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW_P || sym == YY___BUILTIN_SMUL_OVERFLOW || sym == YY___BUILTIN_SMULL_OVERFLOW || sym == YY___BUILTIN_SMULLL_OVERFLOW || sym == YY___BUILTIN_UMUL_OVERFLOW || sym == YY___BUILTIN_UMULL_OVERFLOW || sym == YY___BUILTIN_UMULLL_OVERFLOW || sym == YY___BUILTIN_CONSTANT_P || sym == YY___BUILTIN_VA_ARG) { + } else if (sym == YY_STATIC || sym == YY__LPAREN || C_IS_ID(sym) || sym == YY_DECIMAL_NUMBER || sym == YY_OCTAL_NUMBER || sym == YY_HEXADECIMAL_NUMBER || sym == YY_BINARY_NUMBER || sym == YY_FLOATING_NUMBER || sym == YY_HEXADECIMAL_FLOATING_NUMBER || sym == YY_CHARACTER || sym == YY_STRING || sym == YY__GENERIC || sym == YY___EXTENSION__ || sym == YY__PLUS_PLUS || sym == YY__MINUS_MINUS || sym == YY__AND || sym == YY__STAR || sym == YY__PLUS || sym == YY__MINUS || sym == YY__TILDE || sym == YY__BANG || sym == YY_SIZEOF || sym == YY__ALIGNOF || sym == YY___ALIGNOF__ || sym == YY___ALIGNOF || sym == YY__AND_AND || sym == YY___BUILTIN_VA_START || sym == YY___BUILTIN_VA_END || sym == YY___BUILTIN_VA_COPY || sym == YY___BUILTIN_ALLOCA || sym == YY___BUILTIN_ABORT || sym == YY___BUILTIN_TRAP || sym == YY___BUILTIN_DEBUGTRAP || sym == YY___BUILTIN_FRAME_ADDRESS || sym == YY___BUILTIN_ABS || sym == YY___BUILTIN_LABS || sym == YY___BUILTIN_LLABS || sym == YY___BUILTIN_FABS || sym == YY___BUILTIN_FABSF || sym == YY___BUILTIN_BSWAP16 || sym == YY___BUILTIN_BSWAP32 || sym == YY___BUILTIN_BSWAP64 || sym == YY___BUILTIN_POPCOUNT || sym == YY___BUILTIN_POPCOUNTL || sym == YY___BUILTIN_POPCOUNTLL || sym == YY___BUILTIN_CLZ || sym == YY___BUILTIN_CLZL || sym == YY___BUILTIN_CLZLL || sym == YY___BUILTIN_CTZ || sym == YY___BUILTIN_CTZL || sym == YY___BUILTIN_CTZLL || sym == YY___BUILTIN_FFS || sym == YY___BUILTIN_FFSL || sym == YY___BUILTIN_FFSLL || sym == YY___BUILTIN_MEMCPY || sym == YY___BUILTIN_MEMSET || sym == YY___BUILTIN_EXPECT || sym == YY___BUILTIN_PREFETCH || sym == YY___BUILTIN_UNREACHABLE || sym == YY___BUILTIN_HUGE_VAL || sym == YY___BUILTIN_HUGE_VALF || sym == YY___BUILTIN_INF || sym == YY___BUILTIN_INFF || sym == YY___BUILTIN_ISUNORDERED || sym == YY___BUILTIN_NAN || sym == YY___BUILTIN_NANF || sym == YY___BUILTIN_ADD_OVERFLOW || sym == YY___BUILTIN_ADD_OVERFLOW_P || sym == YY___BUILTIN_SADD_OVERFLOW || sym == YY___BUILTIN_SADDL_OVERFLOW || sym == YY___BUILTIN_SADDLL_OVERFLOW || sym == YY___BUILTIN_UADD_OVERFLOW || sym == YY___BUILTIN_UADDL_OVERFLOW || sym == YY___BUILTIN_UADDLL_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW_P || sym == YY___BUILTIN_SSUB_OVERFLOW || sym == YY___BUILTIN_SSUBL_OVERFLOW || sym == YY___BUILTIN_SSUBLL_OVERFLOW || sym == YY___BUILTIN_USUB_OVERFLOW || sym == YY___BUILTIN_USUBL_OVERFLOW || sym == YY___BUILTIN_USUBLL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW_P || sym == YY___BUILTIN_SMUL_OVERFLOW || sym == YY___BUILTIN_SMULL_OVERFLOW || sym == YY___BUILTIN_SMULLL_OVERFLOW || sym == YY___BUILTIN_UMUL_OVERFLOW || sym == YY___BUILTIN_UMULL_OVERFLOW || sym == YY___BUILTIN_UMULLL_OVERFLOW || sym == YY___BUILTIN_SHUFFLE || sym == YY___BUILTIN_SHUFFLEVECTOR || sym == YY___BUILTIN_CONSTANT_P || sym == YY___BUILTIN_VA_ARG || sym == YY___BUILTIN_CONVERTVECTOR) { if (sym == YY_STATIC) { sym = get_sym(); } @@ -1482,7 +1482,7 @@ static yy_sym parse_type_name(yy_sym sym, rcc_ctx *rcc, const c_type **t) { static yy_sym parse_initializer(yy_sym sym, rcc_ctx *rcc, c_sym *obj) { rcc->c_static_data = (obj && obj->linkage); - if (sym == YY__LPAREN || C_IS_ID(sym) || sym == YY_DECIMAL_NUMBER || sym == YY_OCTAL_NUMBER || sym == YY_HEXADECIMAL_NUMBER || sym == YY_BINARY_NUMBER || sym == YY_FLOATING_NUMBER || sym == YY_HEXADECIMAL_FLOATING_NUMBER || sym == YY_CHARACTER || sym == YY_STRING || sym == YY__GENERIC || sym == YY___EXTENSION__ || sym == YY__PLUS_PLUS || sym == YY__MINUS_MINUS || sym == YY__AND || sym == YY__STAR || sym == YY__PLUS || sym == YY__MINUS || sym == YY__TILDE || sym == YY__BANG || sym == YY_SIZEOF || sym == YY__ALIGNOF || sym == YY___ALIGNOF__ || sym == YY___ALIGNOF || sym == YY__AND_AND || sym == YY___BUILTIN_VA_START || sym == YY___BUILTIN_VA_END || sym == YY___BUILTIN_VA_COPY || sym == YY___BUILTIN_ALLOCA || sym == YY___BUILTIN_ABORT || sym == YY___BUILTIN_TRAP || sym == YY___BUILTIN_DEBUGTRAP || sym == YY___BUILTIN_FRAME_ADDRESS || sym == YY___BUILTIN_ABS || sym == YY___BUILTIN_LABS || sym == YY___BUILTIN_LLABS || sym == YY___BUILTIN_FABS || sym == YY___BUILTIN_FABSF || sym == YY___BUILTIN_BSWAP16 || sym == YY___BUILTIN_BSWAP32 || sym == YY___BUILTIN_BSWAP64 || sym == YY___BUILTIN_POPCOUNT || sym == YY___BUILTIN_POPCOUNTL || sym == YY___BUILTIN_POPCOUNTLL || sym == YY___BUILTIN_CLZ || sym == YY___BUILTIN_CLZL || sym == YY___BUILTIN_CLZLL || sym == YY___BUILTIN_CTZ || sym == YY___BUILTIN_CTZL || sym == YY___BUILTIN_CTZLL || sym == YY___BUILTIN_FFS || sym == YY___BUILTIN_FFSL || sym == YY___BUILTIN_FFSLL || sym == YY___BUILTIN_MEMCPY || sym == YY___BUILTIN_MEMSET || sym == YY___BUILTIN_EXPECT || sym == YY___BUILTIN_PREFETCH || sym == YY___BUILTIN_UNREACHABLE || sym == YY___BUILTIN_HUGE_VAL || sym == YY___BUILTIN_HUGE_VALF || sym == YY___BUILTIN_INF || sym == YY___BUILTIN_INFF || sym == YY___BUILTIN_ISUNORDERED || sym == YY___BUILTIN_NAN || sym == YY___BUILTIN_NANF || sym == YY___BUILTIN_ADD_OVERFLOW || sym == YY___BUILTIN_ADD_OVERFLOW_P || sym == YY___BUILTIN_SADD_OVERFLOW || sym == YY___BUILTIN_SADDL_OVERFLOW || sym == YY___BUILTIN_SADDLL_OVERFLOW || sym == YY___BUILTIN_UADD_OVERFLOW || sym == YY___BUILTIN_UADDL_OVERFLOW || sym == YY___BUILTIN_UADDLL_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW_P || sym == YY___BUILTIN_SSUB_OVERFLOW || sym == YY___BUILTIN_SSUBL_OVERFLOW || sym == YY___BUILTIN_SSUBLL_OVERFLOW || sym == YY___BUILTIN_USUB_OVERFLOW || sym == YY___BUILTIN_USUBL_OVERFLOW || sym == YY___BUILTIN_USUBLL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW_P || sym == YY___BUILTIN_SMUL_OVERFLOW || sym == YY___BUILTIN_SMULL_OVERFLOW || sym == YY___BUILTIN_SMULLL_OVERFLOW || sym == YY___BUILTIN_UMUL_OVERFLOW || sym == YY___BUILTIN_UMULL_OVERFLOW || sym == YY___BUILTIN_UMULLL_OVERFLOW || sym == YY___BUILTIN_CONSTANT_P || sym == YY___BUILTIN_VA_ARG) { + if (sym == YY__LPAREN || C_IS_ID(sym) || sym == YY_DECIMAL_NUMBER || sym == YY_OCTAL_NUMBER || sym == YY_HEXADECIMAL_NUMBER || sym == YY_BINARY_NUMBER || sym == YY_FLOATING_NUMBER || sym == YY_HEXADECIMAL_FLOATING_NUMBER || sym == YY_CHARACTER || sym == YY_STRING || sym == YY__GENERIC || sym == YY___EXTENSION__ || sym == YY__PLUS_PLUS || sym == YY__MINUS_MINUS || sym == YY__AND || sym == YY__STAR || sym == YY__PLUS || sym == YY__MINUS || sym == YY__TILDE || sym == YY__BANG || sym == YY_SIZEOF || sym == YY__ALIGNOF || sym == YY___ALIGNOF__ || sym == YY___ALIGNOF || sym == YY__AND_AND || sym == YY___BUILTIN_VA_START || sym == YY___BUILTIN_VA_END || sym == YY___BUILTIN_VA_COPY || sym == YY___BUILTIN_ALLOCA || sym == YY___BUILTIN_ABORT || sym == YY___BUILTIN_TRAP || sym == YY___BUILTIN_DEBUGTRAP || sym == YY___BUILTIN_FRAME_ADDRESS || sym == YY___BUILTIN_ABS || sym == YY___BUILTIN_LABS || sym == YY___BUILTIN_LLABS || sym == YY___BUILTIN_FABS || sym == YY___BUILTIN_FABSF || sym == YY___BUILTIN_BSWAP16 || sym == YY___BUILTIN_BSWAP32 || sym == YY___BUILTIN_BSWAP64 || sym == YY___BUILTIN_POPCOUNT || sym == YY___BUILTIN_POPCOUNTL || sym == YY___BUILTIN_POPCOUNTLL || sym == YY___BUILTIN_CLZ || sym == YY___BUILTIN_CLZL || sym == YY___BUILTIN_CLZLL || sym == YY___BUILTIN_CTZ || sym == YY___BUILTIN_CTZL || sym == YY___BUILTIN_CTZLL || sym == YY___BUILTIN_FFS || sym == YY___BUILTIN_FFSL || sym == YY___BUILTIN_FFSLL || sym == YY___BUILTIN_MEMCPY || sym == YY___BUILTIN_MEMSET || sym == YY___BUILTIN_EXPECT || sym == YY___BUILTIN_PREFETCH || sym == YY___BUILTIN_UNREACHABLE || sym == YY___BUILTIN_HUGE_VAL || sym == YY___BUILTIN_HUGE_VALF || sym == YY___BUILTIN_INF || sym == YY___BUILTIN_INFF || sym == YY___BUILTIN_ISUNORDERED || sym == YY___BUILTIN_NAN || sym == YY___BUILTIN_NANF || sym == YY___BUILTIN_ADD_OVERFLOW || sym == YY___BUILTIN_ADD_OVERFLOW_P || sym == YY___BUILTIN_SADD_OVERFLOW || sym == YY___BUILTIN_SADDL_OVERFLOW || sym == YY___BUILTIN_SADDLL_OVERFLOW || sym == YY___BUILTIN_UADD_OVERFLOW || sym == YY___BUILTIN_UADDL_OVERFLOW || sym == YY___BUILTIN_UADDLL_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW_P || sym == YY___BUILTIN_SSUB_OVERFLOW || sym == YY___BUILTIN_SSUBL_OVERFLOW || sym == YY___BUILTIN_SSUBLL_OVERFLOW || sym == YY___BUILTIN_USUB_OVERFLOW || sym == YY___BUILTIN_USUBL_OVERFLOW || sym == YY___BUILTIN_USUBLL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW_P || sym == YY___BUILTIN_SMUL_OVERFLOW || sym == YY___BUILTIN_SMULL_OVERFLOW || sym == YY___BUILTIN_SMULLL_OVERFLOW || sym == YY___BUILTIN_UMUL_OVERFLOW || sym == YY___BUILTIN_UMULL_OVERFLOW || sym == YY___BUILTIN_UMULLL_OVERFLOW || sym == YY___BUILTIN_SHUFFLE || sym == YY___BUILTIN_SHUFFLEVECTOR || sym == YY___BUILTIN_CONSTANT_P || sym == YY___BUILTIN_VA_ARG || sym == YY___BUILTIN_CONVERTVECTOR) { c_value v; c_value_clear(&v); sym = parse_assignment_expression(sym, rcc, &v); @@ -1507,7 +1507,7 @@ static yy_sym parse_initializer_contents(yy_sym sym, rcc_ctx *rcc, c_sym *obj, s } static yy_sym parse_nested_initializer(yy_sym sym, rcc_ctx *rcc, c_sym *obj, c_init *init, bool b) { - if (sym == YY__LPAREN || C_IS_ID(sym) || sym == YY_DECIMAL_NUMBER || sym == YY_OCTAL_NUMBER || sym == YY_HEXADECIMAL_NUMBER || sym == YY_BINARY_NUMBER || sym == YY_FLOATING_NUMBER || sym == YY_HEXADECIMAL_FLOATING_NUMBER || sym == YY_CHARACTER || sym == YY_STRING || sym == YY__GENERIC || sym == YY___EXTENSION__ || sym == YY__PLUS_PLUS || sym == YY__MINUS_MINUS || sym == YY__AND || sym == YY__STAR || sym == YY__PLUS || sym == YY__MINUS || sym == YY__TILDE || sym == YY__BANG || sym == YY_SIZEOF || sym == YY__ALIGNOF || sym == YY___ALIGNOF__ || sym == YY___ALIGNOF || sym == YY__AND_AND || sym == YY___BUILTIN_VA_START || sym == YY___BUILTIN_VA_END || sym == YY___BUILTIN_VA_COPY || sym == YY___BUILTIN_ALLOCA || sym == YY___BUILTIN_ABORT || sym == YY___BUILTIN_TRAP || sym == YY___BUILTIN_DEBUGTRAP || sym == YY___BUILTIN_FRAME_ADDRESS || sym == YY___BUILTIN_ABS || sym == YY___BUILTIN_LABS || sym == YY___BUILTIN_LLABS || sym == YY___BUILTIN_FABS || sym == YY___BUILTIN_FABSF || sym == YY___BUILTIN_BSWAP16 || sym == YY___BUILTIN_BSWAP32 || sym == YY___BUILTIN_BSWAP64 || sym == YY___BUILTIN_POPCOUNT || sym == YY___BUILTIN_POPCOUNTL || sym == YY___BUILTIN_POPCOUNTLL || sym == YY___BUILTIN_CLZ || sym == YY___BUILTIN_CLZL || sym == YY___BUILTIN_CLZLL || sym == YY___BUILTIN_CTZ || sym == YY___BUILTIN_CTZL || sym == YY___BUILTIN_CTZLL || sym == YY___BUILTIN_FFS || sym == YY___BUILTIN_FFSL || sym == YY___BUILTIN_FFSLL || sym == YY___BUILTIN_MEMCPY || sym == YY___BUILTIN_MEMSET || sym == YY___BUILTIN_EXPECT || sym == YY___BUILTIN_PREFETCH || sym == YY___BUILTIN_UNREACHABLE || sym == YY___BUILTIN_HUGE_VAL || sym == YY___BUILTIN_HUGE_VALF || sym == YY___BUILTIN_INF || sym == YY___BUILTIN_INFF || sym == YY___BUILTIN_ISUNORDERED || sym == YY___BUILTIN_NAN || sym == YY___BUILTIN_NANF || sym == YY___BUILTIN_ADD_OVERFLOW || sym == YY___BUILTIN_ADD_OVERFLOW_P || sym == YY___BUILTIN_SADD_OVERFLOW || sym == YY___BUILTIN_SADDL_OVERFLOW || sym == YY___BUILTIN_SADDLL_OVERFLOW || sym == YY___BUILTIN_UADD_OVERFLOW || sym == YY___BUILTIN_UADDL_OVERFLOW || sym == YY___BUILTIN_UADDLL_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW_P || sym == YY___BUILTIN_SSUB_OVERFLOW || sym == YY___BUILTIN_SSUBL_OVERFLOW || sym == YY___BUILTIN_SSUBLL_OVERFLOW || sym == YY___BUILTIN_USUB_OVERFLOW || sym == YY___BUILTIN_USUBL_OVERFLOW || sym == YY___BUILTIN_USUBLL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW_P || sym == YY___BUILTIN_SMUL_OVERFLOW || sym == YY___BUILTIN_SMULL_OVERFLOW || sym == YY___BUILTIN_SMULLL_OVERFLOW || sym == YY___BUILTIN_UMUL_OVERFLOW || sym == YY___BUILTIN_UMULL_OVERFLOW || sym == YY___BUILTIN_UMULLL_OVERFLOW || sym == YY___BUILTIN_CONSTANT_P || sym == YY___BUILTIN_VA_ARG) { + if (sym == YY__LPAREN || C_IS_ID(sym) || sym == YY_DECIMAL_NUMBER || sym == YY_OCTAL_NUMBER || sym == YY_HEXADECIMAL_NUMBER || sym == YY_BINARY_NUMBER || sym == YY_FLOATING_NUMBER || sym == YY_HEXADECIMAL_FLOATING_NUMBER || sym == YY_CHARACTER || sym == YY_STRING || sym == YY__GENERIC || sym == YY___EXTENSION__ || sym == YY__PLUS_PLUS || sym == YY__MINUS_MINUS || sym == YY__AND || sym == YY__STAR || sym == YY__PLUS || sym == YY__MINUS || sym == YY__TILDE || sym == YY__BANG || sym == YY_SIZEOF || sym == YY__ALIGNOF || sym == YY___ALIGNOF__ || sym == YY___ALIGNOF || sym == YY__AND_AND || sym == YY___BUILTIN_VA_START || sym == YY___BUILTIN_VA_END || sym == YY___BUILTIN_VA_COPY || sym == YY___BUILTIN_ALLOCA || sym == YY___BUILTIN_ABORT || sym == YY___BUILTIN_TRAP || sym == YY___BUILTIN_DEBUGTRAP || sym == YY___BUILTIN_FRAME_ADDRESS || sym == YY___BUILTIN_ABS || sym == YY___BUILTIN_LABS || sym == YY___BUILTIN_LLABS || sym == YY___BUILTIN_FABS || sym == YY___BUILTIN_FABSF || sym == YY___BUILTIN_BSWAP16 || sym == YY___BUILTIN_BSWAP32 || sym == YY___BUILTIN_BSWAP64 || sym == YY___BUILTIN_POPCOUNT || sym == YY___BUILTIN_POPCOUNTL || sym == YY___BUILTIN_POPCOUNTLL || sym == YY___BUILTIN_CLZ || sym == YY___BUILTIN_CLZL || sym == YY___BUILTIN_CLZLL || sym == YY___BUILTIN_CTZ || sym == YY___BUILTIN_CTZL || sym == YY___BUILTIN_CTZLL || sym == YY___BUILTIN_FFS || sym == YY___BUILTIN_FFSL || sym == YY___BUILTIN_FFSLL || sym == YY___BUILTIN_MEMCPY || sym == YY___BUILTIN_MEMSET || sym == YY___BUILTIN_EXPECT || sym == YY___BUILTIN_PREFETCH || sym == YY___BUILTIN_UNREACHABLE || sym == YY___BUILTIN_HUGE_VAL || sym == YY___BUILTIN_HUGE_VALF || sym == YY___BUILTIN_INF || sym == YY___BUILTIN_INFF || sym == YY___BUILTIN_ISUNORDERED || sym == YY___BUILTIN_NAN || sym == YY___BUILTIN_NANF || sym == YY___BUILTIN_ADD_OVERFLOW || sym == YY___BUILTIN_ADD_OVERFLOW_P || sym == YY___BUILTIN_SADD_OVERFLOW || sym == YY___BUILTIN_SADDL_OVERFLOW || sym == YY___BUILTIN_SADDLL_OVERFLOW || sym == YY___BUILTIN_UADD_OVERFLOW || sym == YY___BUILTIN_UADDL_OVERFLOW || sym == YY___BUILTIN_UADDLL_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW_P || sym == YY___BUILTIN_SSUB_OVERFLOW || sym == YY___BUILTIN_SSUBL_OVERFLOW || sym == YY___BUILTIN_SSUBLL_OVERFLOW || sym == YY___BUILTIN_USUB_OVERFLOW || sym == YY___BUILTIN_USUBL_OVERFLOW || sym == YY___BUILTIN_USUBLL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW_P || sym == YY___BUILTIN_SMUL_OVERFLOW || sym == YY___BUILTIN_SMULL_OVERFLOW || sym == YY___BUILTIN_SMULLL_OVERFLOW || sym == YY___BUILTIN_UMUL_OVERFLOW || sym == YY___BUILTIN_UMULL_OVERFLOW || sym == YY___BUILTIN_UMULLL_OVERFLOW || sym == YY___BUILTIN_SHUFFLE || sym == YY___BUILTIN_SHUFFLEVECTOR || sym == YY___BUILTIN_CONSTANT_P || sym == YY___BUILTIN_VA_ARG || sym == YY___BUILTIN_CONVERTVECTOR) { c_value v; c_value_clear(&v); sym = parse_assignment_expression(sym, rcc, &v); @@ -1528,10 +1528,10 @@ static yy_sym parse_nested_initializer_contents(yy_sym sym, rcc_ctx *rcc, c_sym yy_error_sym("'{' expected, got", sym); } sym = get_sym(); - if (C_IS_ID(sym) || sym == YY__LPAREN || sym == YY_DECIMAL_NUMBER || sym == YY_OCTAL_NUMBER || sym == YY_HEXADECIMAL_NUMBER || sym == YY_BINARY_NUMBER || sym == YY_FLOATING_NUMBER || sym == YY_HEXADECIMAL_FLOATING_NUMBER || sym == YY_CHARACTER || sym == YY_STRING || sym == YY__GENERIC || sym == YY___EXTENSION__ || sym == YY__PLUS_PLUS || sym == YY__MINUS_MINUS || sym == YY__AND || sym == YY__STAR || sym == YY__PLUS || sym == YY__MINUS || sym == YY__TILDE || sym == YY__BANG || sym == YY_SIZEOF || sym == YY__ALIGNOF || sym == YY___ALIGNOF__ || sym == YY___ALIGNOF || sym == YY__AND_AND || sym == YY___BUILTIN_VA_START || sym == YY___BUILTIN_VA_END || sym == YY___BUILTIN_VA_COPY || sym == YY___BUILTIN_ALLOCA || sym == YY___BUILTIN_ABORT || sym == YY___BUILTIN_TRAP || sym == YY___BUILTIN_DEBUGTRAP || sym == YY___BUILTIN_FRAME_ADDRESS || sym == YY___BUILTIN_ABS || sym == YY___BUILTIN_LABS || sym == YY___BUILTIN_LLABS || sym == YY___BUILTIN_FABS || sym == YY___BUILTIN_FABSF || sym == YY___BUILTIN_BSWAP16 || sym == YY___BUILTIN_BSWAP32 || sym == YY___BUILTIN_BSWAP64 || sym == YY___BUILTIN_POPCOUNT || sym == YY___BUILTIN_POPCOUNTL || sym == YY___BUILTIN_POPCOUNTLL || sym == YY___BUILTIN_CLZ || sym == YY___BUILTIN_CLZL || sym == YY___BUILTIN_CLZLL || sym == YY___BUILTIN_CTZ || sym == YY___BUILTIN_CTZL || sym == YY___BUILTIN_CTZLL || sym == YY___BUILTIN_FFS || sym == YY___BUILTIN_FFSL || sym == YY___BUILTIN_FFSLL || sym == YY___BUILTIN_MEMCPY || sym == YY___BUILTIN_MEMSET || sym == YY___BUILTIN_EXPECT || sym == YY___BUILTIN_PREFETCH || sym == YY___BUILTIN_UNREACHABLE || sym == YY___BUILTIN_HUGE_VAL || sym == YY___BUILTIN_HUGE_VALF || sym == YY___BUILTIN_INF || sym == YY___BUILTIN_INFF || sym == YY___BUILTIN_ISUNORDERED || sym == YY___BUILTIN_NAN || sym == YY___BUILTIN_NANF || sym == YY___BUILTIN_ADD_OVERFLOW || sym == YY___BUILTIN_ADD_OVERFLOW_P || sym == YY___BUILTIN_SADD_OVERFLOW || sym == YY___BUILTIN_SADDL_OVERFLOW || sym == YY___BUILTIN_SADDLL_OVERFLOW || sym == YY___BUILTIN_UADD_OVERFLOW || sym == YY___BUILTIN_UADDL_OVERFLOW || sym == YY___BUILTIN_UADDLL_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW_P || sym == YY___BUILTIN_SSUB_OVERFLOW || sym == YY___BUILTIN_SSUBL_OVERFLOW || sym == YY___BUILTIN_SSUBLL_OVERFLOW || sym == YY___BUILTIN_USUB_OVERFLOW || sym == YY___BUILTIN_USUBL_OVERFLOW || sym == YY___BUILTIN_USUBLL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW_P || sym == YY___BUILTIN_SMUL_OVERFLOW || sym == YY___BUILTIN_SMULL_OVERFLOW || sym == YY___BUILTIN_SMULLL_OVERFLOW || sym == YY___BUILTIN_UMUL_OVERFLOW || sym == YY___BUILTIN_UMULL_OVERFLOW || sym == YY___BUILTIN_UMULLL_OVERFLOW || sym == YY___BUILTIN_CONSTANT_P || sym == YY___BUILTIN_VA_ARG || sym == YY__LBRACE || sym == YY__LBRACK || sym == YY__POINT) { + if (C_IS_ID(sym) || sym == YY__LPAREN || sym == YY_DECIMAL_NUMBER || sym == YY_OCTAL_NUMBER || sym == YY_HEXADECIMAL_NUMBER || sym == YY_BINARY_NUMBER || sym == YY_FLOATING_NUMBER || sym == YY_HEXADECIMAL_FLOATING_NUMBER || sym == YY_CHARACTER || sym == YY_STRING || sym == YY__GENERIC || sym == YY___EXTENSION__ || sym == YY__PLUS_PLUS || sym == YY__MINUS_MINUS || sym == YY__AND || sym == YY__STAR || sym == YY__PLUS || sym == YY__MINUS || sym == YY__TILDE || sym == YY__BANG || sym == YY_SIZEOF || sym == YY__ALIGNOF || sym == YY___ALIGNOF__ || sym == YY___ALIGNOF || sym == YY__AND_AND || sym == YY___BUILTIN_VA_START || sym == YY___BUILTIN_VA_END || sym == YY___BUILTIN_VA_COPY || sym == YY___BUILTIN_ALLOCA || sym == YY___BUILTIN_ABORT || sym == YY___BUILTIN_TRAP || sym == YY___BUILTIN_DEBUGTRAP || sym == YY___BUILTIN_FRAME_ADDRESS || sym == YY___BUILTIN_ABS || sym == YY___BUILTIN_LABS || sym == YY___BUILTIN_LLABS || sym == YY___BUILTIN_FABS || sym == YY___BUILTIN_FABSF || sym == YY___BUILTIN_BSWAP16 || sym == YY___BUILTIN_BSWAP32 || sym == YY___BUILTIN_BSWAP64 || sym == YY___BUILTIN_POPCOUNT || sym == YY___BUILTIN_POPCOUNTL || sym == YY___BUILTIN_POPCOUNTLL || sym == YY___BUILTIN_CLZ || sym == YY___BUILTIN_CLZL || sym == YY___BUILTIN_CLZLL || sym == YY___BUILTIN_CTZ || sym == YY___BUILTIN_CTZL || sym == YY___BUILTIN_CTZLL || sym == YY___BUILTIN_FFS || sym == YY___BUILTIN_FFSL || sym == YY___BUILTIN_FFSLL || sym == YY___BUILTIN_MEMCPY || sym == YY___BUILTIN_MEMSET || sym == YY___BUILTIN_EXPECT || sym == YY___BUILTIN_PREFETCH || sym == YY___BUILTIN_UNREACHABLE || sym == YY___BUILTIN_HUGE_VAL || sym == YY___BUILTIN_HUGE_VALF || sym == YY___BUILTIN_INF || sym == YY___BUILTIN_INFF || sym == YY___BUILTIN_ISUNORDERED || sym == YY___BUILTIN_NAN || sym == YY___BUILTIN_NANF || sym == YY___BUILTIN_ADD_OVERFLOW || sym == YY___BUILTIN_ADD_OVERFLOW_P || sym == YY___BUILTIN_SADD_OVERFLOW || sym == YY___BUILTIN_SADDL_OVERFLOW || sym == YY___BUILTIN_SADDLL_OVERFLOW || sym == YY___BUILTIN_UADD_OVERFLOW || sym == YY___BUILTIN_UADDL_OVERFLOW || sym == YY___BUILTIN_UADDLL_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW_P || sym == YY___BUILTIN_SSUB_OVERFLOW || sym == YY___BUILTIN_SSUBL_OVERFLOW || sym == YY___BUILTIN_SSUBLL_OVERFLOW || sym == YY___BUILTIN_USUB_OVERFLOW || sym == YY___BUILTIN_USUBL_OVERFLOW || sym == YY___BUILTIN_USUBLL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW_P || sym == YY___BUILTIN_SMUL_OVERFLOW || sym == YY___BUILTIN_SMULL_OVERFLOW || sym == YY___BUILTIN_SMULLL_OVERFLOW || sym == YY___BUILTIN_UMUL_OVERFLOW || sym == YY___BUILTIN_UMULL_OVERFLOW || sym == YY___BUILTIN_UMULLL_OVERFLOW || sym == YY___BUILTIN_SHUFFLE || sym == YY___BUILTIN_SHUFFLEVECTOR || sym == YY___BUILTIN_CONSTANT_P || sym == YY___BUILTIN_VA_ARG || sym == YY___BUILTIN_CONVERTVECTOR || sym == YY__LBRACE || sym == YY__LBRACK || sym == YY__POINT) { if ((C_IS_ID(sym)) && (!C_IS_ID(sym) || is_label(rcc, sym))) { sym = parse_gcc_field_initializer(sym, rcc, obj, init); - } else if (sym == YY__LPAREN || C_IS_ID(sym) || sym == YY_DECIMAL_NUMBER || sym == YY_OCTAL_NUMBER || sym == YY_HEXADECIMAL_NUMBER || sym == YY_BINARY_NUMBER || sym == YY_FLOATING_NUMBER || sym == YY_HEXADECIMAL_FLOATING_NUMBER || sym == YY_CHARACTER || sym == YY_STRING || sym == YY__GENERIC || sym == YY___EXTENSION__ || sym == YY__PLUS_PLUS || sym == YY__MINUS_MINUS || sym == YY__AND || sym == YY__STAR || sym == YY__PLUS || sym == YY__MINUS || sym == YY__TILDE || sym == YY__BANG || sym == YY_SIZEOF || sym == YY__ALIGNOF || sym == YY___ALIGNOF__ || sym == YY___ALIGNOF || sym == YY__AND_AND || sym == YY___BUILTIN_VA_START || sym == YY___BUILTIN_VA_END || sym == YY___BUILTIN_VA_COPY || sym == YY___BUILTIN_ALLOCA || sym == YY___BUILTIN_ABORT || sym == YY___BUILTIN_TRAP || sym == YY___BUILTIN_DEBUGTRAP || sym == YY___BUILTIN_FRAME_ADDRESS || sym == YY___BUILTIN_ABS || sym == YY___BUILTIN_LABS || sym == YY___BUILTIN_LLABS || sym == YY___BUILTIN_FABS || sym == YY___BUILTIN_FABSF || sym == YY___BUILTIN_BSWAP16 || sym == YY___BUILTIN_BSWAP32 || sym == YY___BUILTIN_BSWAP64 || sym == YY___BUILTIN_POPCOUNT || sym == YY___BUILTIN_POPCOUNTL || sym == YY___BUILTIN_POPCOUNTLL || sym == YY___BUILTIN_CLZ || sym == YY___BUILTIN_CLZL || sym == YY___BUILTIN_CLZLL || sym == YY___BUILTIN_CTZ || sym == YY___BUILTIN_CTZL || sym == YY___BUILTIN_CTZLL || sym == YY___BUILTIN_FFS || sym == YY___BUILTIN_FFSL || sym == YY___BUILTIN_FFSLL || sym == YY___BUILTIN_MEMCPY || sym == YY___BUILTIN_MEMSET || sym == YY___BUILTIN_EXPECT || sym == YY___BUILTIN_PREFETCH || sym == YY___BUILTIN_UNREACHABLE || sym == YY___BUILTIN_HUGE_VAL || sym == YY___BUILTIN_HUGE_VALF || sym == YY___BUILTIN_INF || sym == YY___BUILTIN_INFF || sym == YY___BUILTIN_ISUNORDERED || sym == YY___BUILTIN_NAN || sym == YY___BUILTIN_NANF || sym == YY___BUILTIN_ADD_OVERFLOW || sym == YY___BUILTIN_ADD_OVERFLOW_P || sym == YY___BUILTIN_SADD_OVERFLOW || sym == YY___BUILTIN_SADDL_OVERFLOW || sym == YY___BUILTIN_SADDLL_OVERFLOW || sym == YY___BUILTIN_UADD_OVERFLOW || sym == YY___BUILTIN_UADDL_OVERFLOW || sym == YY___BUILTIN_UADDLL_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW_P || sym == YY___BUILTIN_SSUB_OVERFLOW || sym == YY___BUILTIN_SSUBL_OVERFLOW || sym == YY___BUILTIN_SSUBLL_OVERFLOW || sym == YY___BUILTIN_USUB_OVERFLOW || sym == YY___BUILTIN_USUBL_OVERFLOW || sym == YY___BUILTIN_USUBLL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW_P || sym == YY___BUILTIN_SMUL_OVERFLOW || sym == YY___BUILTIN_SMULL_OVERFLOW || sym == YY___BUILTIN_SMULLL_OVERFLOW || sym == YY___BUILTIN_UMUL_OVERFLOW || sym == YY___BUILTIN_UMULL_OVERFLOW || sym == YY___BUILTIN_UMULLL_OVERFLOW || sym == YY___BUILTIN_CONSTANT_P || sym == YY___BUILTIN_VA_ARG || sym == YY__LBRACE) { + } else if (sym == YY__LPAREN || C_IS_ID(sym) || sym == YY_DECIMAL_NUMBER || sym == YY_OCTAL_NUMBER || sym == YY_HEXADECIMAL_NUMBER || sym == YY_BINARY_NUMBER || sym == YY_FLOATING_NUMBER || sym == YY_HEXADECIMAL_FLOATING_NUMBER || sym == YY_CHARACTER || sym == YY_STRING || sym == YY__GENERIC || sym == YY___EXTENSION__ || sym == YY__PLUS_PLUS || sym == YY__MINUS_MINUS || sym == YY__AND || sym == YY__STAR || sym == YY__PLUS || sym == YY__MINUS || sym == YY__TILDE || sym == YY__BANG || sym == YY_SIZEOF || sym == YY__ALIGNOF || sym == YY___ALIGNOF__ || sym == YY___ALIGNOF || sym == YY__AND_AND || sym == YY___BUILTIN_VA_START || sym == YY___BUILTIN_VA_END || sym == YY___BUILTIN_VA_COPY || sym == YY___BUILTIN_ALLOCA || sym == YY___BUILTIN_ABORT || sym == YY___BUILTIN_TRAP || sym == YY___BUILTIN_DEBUGTRAP || sym == YY___BUILTIN_FRAME_ADDRESS || sym == YY___BUILTIN_ABS || sym == YY___BUILTIN_LABS || sym == YY___BUILTIN_LLABS || sym == YY___BUILTIN_FABS || sym == YY___BUILTIN_FABSF || sym == YY___BUILTIN_BSWAP16 || sym == YY___BUILTIN_BSWAP32 || sym == YY___BUILTIN_BSWAP64 || sym == YY___BUILTIN_POPCOUNT || sym == YY___BUILTIN_POPCOUNTL || sym == YY___BUILTIN_POPCOUNTLL || sym == YY___BUILTIN_CLZ || sym == YY___BUILTIN_CLZL || sym == YY___BUILTIN_CLZLL || sym == YY___BUILTIN_CTZ || sym == YY___BUILTIN_CTZL || sym == YY___BUILTIN_CTZLL || sym == YY___BUILTIN_FFS || sym == YY___BUILTIN_FFSL || sym == YY___BUILTIN_FFSLL || sym == YY___BUILTIN_MEMCPY || sym == YY___BUILTIN_MEMSET || sym == YY___BUILTIN_EXPECT || sym == YY___BUILTIN_PREFETCH || sym == YY___BUILTIN_UNREACHABLE || sym == YY___BUILTIN_HUGE_VAL || sym == YY___BUILTIN_HUGE_VALF || sym == YY___BUILTIN_INF || sym == YY___BUILTIN_INFF || sym == YY___BUILTIN_ISUNORDERED || sym == YY___BUILTIN_NAN || sym == YY___BUILTIN_NANF || sym == YY___BUILTIN_ADD_OVERFLOW || sym == YY___BUILTIN_ADD_OVERFLOW_P || sym == YY___BUILTIN_SADD_OVERFLOW || sym == YY___BUILTIN_SADDL_OVERFLOW || sym == YY___BUILTIN_SADDLL_OVERFLOW || sym == YY___BUILTIN_UADD_OVERFLOW || sym == YY___BUILTIN_UADDL_OVERFLOW || sym == YY___BUILTIN_UADDLL_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW_P || sym == YY___BUILTIN_SSUB_OVERFLOW || sym == YY___BUILTIN_SSUBL_OVERFLOW || sym == YY___BUILTIN_SSUBLL_OVERFLOW || sym == YY___BUILTIN_USUB_OVERFLOW || sym == YY___BUILTIN_USUBL_OVERFLOW || sym == YY___BUILTIN_USUBLL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW_P || sym == YY___BUILTIN_SMUL_OVERFLOW || sym == YY___BUILTIN_SMULL_OVERFLOW || sym == YY___BUILTIN_SMULLL_OVERFLOW || sym == YY___BUILTIN_UMUL_OVERFLOW || sym == YY___BUILTIN_UMULL_OVERFLOW || sym == YY___BUILTIN_UMULLL_OVERFLOW || sym == YY___BUILTIN_SHUFFLE || sym == YY___BUILTIN_SHUFFLEVECTOR || sym == YY___BUILTIN_CONSTANT_P || sym == YY___BUILTIN_VA_ARG || sym == YY___BUILTIN_CONVERTVECTOR || sym == YY__LBRACE) { sym = parse_nested_initializer(sym, rcc, obj, init, 0); } else { sym = parse_designated_initializer(sym, rcc, obj, init); @@ -1543,7 +1543,7 @@ static yy_sym parse_nested_initializer_contents(yy_sym sym, rcc_ctx *rcc, c_sym sym = get_sym(); } else if ((C_IS_ID(sym)) && (!C_IS_ID(sym) || is_label(rcc, sym))) { sym = parse_gcc_field_initializer(sym, rcc, obj, init); - } else if (sym == YY__LPAREN || C_IS_ID(sym) || sym == YY_DECIMAL_NUMBER || sym == YY_OCTAL_NUMBER || sym == YY_HEXADECIMAL_NUMBER || sym == YY_BINARY_NUMBER || sym == YY_FLOATING_NUMBER || sym == YY_HEXADECIMAL_FLOATING_NUMBER || sym == YY_CHARACTER || sym == YY_STRING || sym == YY__GENERIC || sym == YY___EXTENSION__ || sym == YY__PLUS_PLUS || sym == YY__MINUS_MINUS || sym == YY__AND || sym == YY__STAR || sym == YY__PLUS || sym == YY__MINUS || sym == YY__TILDE || sym == YY__BANG || sym == YY_SIZEOF || sym == YY__ALIGNOF || sym == YY___ALIGNOF__ || sym == YY___ALIGNOF || sym == YY__AND_AND || sym == YY___BUILTIN_VA_START || sym == YY___BUILTIN_VA_END || sym == YY___BUILTIN_VA_COPY || sym == YY___BUILTIN_ALLOCA || sym == YY___BUILTIN_ABORT || sym == YY___BUILTIN_TRAP || sym == YY___BUILTIN_DEBUGTRAP || sym == YY___BUILTIN_FRAME_ADDRESS || sym == YY___BUILTIN_ABS || sym == YY___BUILTIN_LABS || sym == YY___BUILTIN_LLABS || sym == YY___BUILTIN_FABS || sym == YY___BUILTIN_FABSF || sym == YY___BUILTIN_BSWAP16 || sym == YY___BUILTIN_BSWAP32 || sym == YY___BUILTIN_BSWAP64 || sym == YY___BUILTIN_POPCOUNT || sym == YY___BUILTIN_POPCOUNTL || sym == YY___BUILTIN_POPCOUNTLL || sym == YY___BUILTIN_CLZ || sym == YY___BUILTIN_CLZL || sym == YY___BUILTIN_CLZLL || sym == YY___BUILTIN_CTZ || sym == YY___BUILTIN_CTZL || sym == YY___BUILTIN_CTZLL || sym == YY___BUILTIN_FFS || sym == YY___BUILTIN_FFSL || sym == YY___BUILTIN_FFSLL || sym == YY___BUILTIN_MEMCPY || sym == YY___BUILTIN_MEMSET || sym == YY___BUILTIN_EXPECT || sym == YY___BUILTIN_PREFETCH || sym == YY___BUILTIN_UNREACHABLE || sym == YY___BUILTIN_HUGE_VAL || sym == YY___BUILTIN_HUGE_VALF || sym == YY___BUILTIN_INF || sym == YY___BUILTIN_INFF || sym == YY___BUILTIN_ISUNORDERED || sym == YY___BUILTIN_NAN || sym == YY___BUILTIN_NANF || sym == YY___BUILTIN_ADD_OVERFLOW || sym == YY___BUILTIN_ADD_OVERFLOW_P || sym == YY___BUILTIN_SADD_OVERFLOW || sym == YY___BUILTIN_SADDL_OVERFLOW || sym == YY___BUILTIN_SADDLL_OVERFLOW || sym == YY___BUILTIN_UADD_OVERFLOW || sym == YY___BUILTIN_UADDL_OVERFLOW || sym == YY___BUILTIN_UADDLL_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW_P || sym == YY___BUILTIN_SSUB_OVERFLOW || sym == YY___BUILTIN_SSUBL_OVERFLOW || sym == YY___BUILTIN_SSUBLL_OVERFLOW || sym == YY___BUILTIN_USUB_OVERFLOW || sym == YY___BUILTIN_USUBL_OVERFLOW || sym == YY___BUILTIN_USUBLL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW_P || sym == YY___BUILTIN_SMUL_OVERFLOW || sym == YY___BUILTIN_SMULL_OVERFLOW || sym == YY___BUILTIN_SMULLL_OVERFLOW || sym == YY___BUILTIN_UMUL_OVERFLOW || sym == YY___BUILTIN_UMULL_OVERFLOW || sym == YY___BUILTIN_UMULLL_OVERFLOW || sym == YY___BUILTIN_CONSTANT_P || sym == YY___BUILTIN_VA_ARG || sym == YY__LBRACE) { + } else if (sym == YY__LPAREN || C_IS_ID(sym) || sym == YY_DECIMAL_NUMBER || sym == YY_OCTAL_NUMBER || sym == YY_HEXADECIMAL_NUMBER || sym == YY_BINARY_NUMBER || sym == YY_FLOATING_NUMBER || sym == YY_HEXADECIMAL_FLOATING_NUMBER || sym == YY_CHARACTER || sym == YY_STRING || sym == YY__GENERIC || sym == YY___EXTENSION__ || sym == YY__PLUS_PLUS || sym == YY__MINUS_MINUS || sym == YY__AND || sym == YY__STAR || sym == YY__PLUS || sym == YY__MINUS || sym == YY__TILDE || sym == YY__BANG || sym == YY_SIZEOF || sym == YY__ALIGNOF || sym == YY___ALIGNOF__ || sym == YY___ALIGNOF || sym == YY__AND_AND || sym == YY___BUILTIN_VA_START || sym == YY___BUILTIN_VA_END || sym == YY___BUILTIN_VA_COPY || sym == YY___BUILTIN_ALLOCA || sym == YY___BUILTIN_ABORT || sym == YY___BUILTIN_TRAP || sym == YY___BUILTIN_DEBUGTRAP || sym == YY___BUILTIN_FRAME_ADDRESS || sym == YY___BUILTIN_ABS || sym == YY___BUILTIN_LABS || sym == YY___BUILTIN_LLABS || sym == YY___BUILTIN_FABS || sym == YY___BUILTIN_FABSF || sym == YY___BUILTIN_BSWAP16 || sym == YY___BUILTIN_BSWAP32 || sym == YY___BUILTIN_BSWAP64 || sym == YY___BUILTIN_POPCOUNT || sym == YY___BUILTIN_POPCOUNTL || sym == YY___BUILTIN_POPCOUNTLL || sym == YY___BUILTIN_CLZ || sym == YY___BUILTIN_CLZL || sym == YY___BUILTIN_CLZLL || sym == YY___BUILTIN_CTZ || sym == YY___BUILTIN_CTZL || sym == YY___BUILTIN_CTZLL || sym == YY___BUILTIN_FFS || sym == YY___BUILTIN_FFSL || sym == YY___BUILTIN_FFSLL || sym == YY___BUILTIN_MEMCPY || sym == YY___BUILTIN_MEMSET || sym == YY___BUILTIN_EXPECT || sym == YY___BUILTIN_PREFETCH || sym == YY___BUILTIN_UNREACHABLE || sym == YY___BUILTIN_HUGE_VAL || sym == YY___BUILTIN_HUGE_VALF || sym == YY___BUILTIN_INF || sym == YY___BUILTIN_INFF || sym == YY___BUILTIN_ISUNORDERED || sym == YY___BUILTIN_NAN || sym == YY___BUILTIN_NANF || sym == YY___BUILTIN_ADD_OVERFLOW || sym == YY___BUILTIN_ADD_OVERFLOW_P || sym == YY___BUILTIN_SADD_OVERFLOW || sym == YY___BUILTIN_SADDL_OVERFLOW || sym == YY___BUILTIN_SADDLL_OVERFLOW || sym == YY___BUILTIN_UADD_OVERFLOW || sym == YY___BUILTIN_UADDL_OVERFLOW || sym == YY___BUILTIN_UADDLL_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW_P || sym == YY___BUILTIN_SSUB_OVERFLOW || sym == YY___BUILTIN_SSUBL_OVERFLOW || sym == YY___BUILTIN_SSUBLL_OVERFLOW || sym == YY___BUILTIN_USUB_OVERFLOW || sym == YY___BUILTIN_USUBL_OVERFLOW || sym == YY___BUILTIN_USUBLL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW_P || sym == YY___BUILTIN_SMUL_OVERFLOW || sym == YY___BUILTIN_SMULL_OVERFLOW || sym == YY___BUILTIN_SMULLL_OVERFLOW || sym == YY___BUILTIN_UMUL_OVERFLOW || sym == YY___BUILTIN_UMULL_OVERFLOW || sym == YY___BUILTIN_UMULLL_OVERFLOW || sym == YY___BUILTIN_SHUFFLE || sym == YY___BUILTIN_SHUFFLEVECTOR || sym == YY___BUILTIN_CONSTANT_P || sym == YY___BUILTIN_VA_ARG || sym == YY___BUILTIN_CONVERTVECTOR || sym == YY__LBRACE) { c_do_init_next(rcc, obj, init); sym = parse_nested_initializer(sym, rcc, obj, init, 0); } else if (sym == YY__LBRACK || sym == YY__POINT) { @@ -1654,14 +1654,14 @@ static yy_sym parse_compound_statement(yy_sym sym, rcc_ctx *rcc) { } sym = get_sym(); } - while (sym == YY__LBRACE || sym == YY_IF || sym == YY_SWITCH || sym == YY_WHILE || sym == YY_DO || sym == YY_FOR || sym == YY_GOTO || sym == YY_CONTINUE || sym == YY_BREAK || sym == YY_RETURN || sym == YY_ASM || sym == YY___ASM || sym == YY___ASM__ || C_IS_ID(sym) || sym == YY_CASE || sym == YY_DEFAULT || sym == YY__LPAREN || sym == YY_DECIMAL_NUMBER || sym == YY_OCTAL_NUMBER || sym == YY_HEXADECIMAL_NUMBER || sym == YY_BINARY_NUMBER || sym == YY_FLOATING_NUMBER || sym == YY_HEXADECIMAL_FLOATING_NUMBER || sym == YY_CHARACTER || sym == YY_STRING || sym == YY__GENERIC || sym == YY___EXTENSION__ || sym == YY__PLUS_PLUS || sym == YY__MINUS_MINUS || sym == YY__AND || sym == YY__STAR || sym == YY__PLUS || sym == YY__MINUS || sym == YY__TILDE || sym == YY__BANG || sym == YY_SIZEOF || sym == YY__ALIGNOF || sym == YY___ALIGNOF__ || sym == YY___ALIGNOF || sym == YY__AND_AND || sym == YY___BUILTIN_VA_START || sym == YY___BUILTIN_VA_END || sym == YY___BUILTIN_VA_COPY || sym == YY___BUILTIN_ALLOCA || sym == YY___BUILTIN_ABORT || sym == YY___BUILTIN_TRAP || sym == YY___BUILTIN_DEBUGTRAP || sym == YY___BUILTIN_FRAME_ADDRESS || sym == YY___BUILTIN_ABS || sym == YY___BUILTIN_LABS || sym == YY___BUILTIN_LLABS || sym == YY___BUILTIN_FABS || sym == YY___BUILTIN_FABSF || sym == YY___BUILTIN_BSWAP16 || sym == YY___BUILTIN_BSWAP32 || sym == YY___BUILTIN_BSWAP64 || sym == YY___BUILTIN_POPCOUNT || sym == YY___BUILTIN_POPCOUNTL || sym == YY___BUILTIN_POPCOUNTLL || sym == YY___BUILTIN_CLZ || sym == YY___BUILTIN_CLZL || sym == YY___BUILTIN_CLZLL || sym == YY___BUILTIN_CTZ || sym == YY___BUILTIN_CTZL || sym == YY___BUILTIN_CTZLL || sym == YY___BUILTIN_FFS || sym == YY___BUILTIN_FFSL || sym == YY___BUILTIN_FFSLL || sym == YY___BUILTIN_MEMCPY || sym == YY___BUILTIN_MEMSET || sym == YY___BUILTIN_EXPECT || sym == YY___BUILTIN_PREFETCH || sym == YY___BUILTIN_UNREACHABLE || sym == YY___BUILTIN_HUGE_VAL || sym == YY___BUILTIN_HUGE_VALF || sym == YY___BUILTIN_INF || sym == YY___BUILTIN_INFF || sym == YY___BUILTIN_ISUNORDERED || sym == YY___BUILTIN_NAN || sym == YY___BUILTIN_NANF || sym == YY___BUILTIN_ADD_OVERFLOW || sym == YY___BUILTIN_ADD_OVERFLOW_P || sym == YY___BUILTIN_SADD_OVERFLOW || sym == YY___BUILTIN_SADDL_OVERFLOW || sym == YY___BUILTIN_SADDLL_OVERFLOW || sym == YY___BUILTIN_UADD_OVERFLOW || sym == YY___BUILTIN_UADDL_OVERFLOW || sym == YY___BUILTIN_UADDLL_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW_P || sym == YY___BUILTIN_SSUB_OVERFLOW || sym == YY___BUILTIN_SSUBL_OVERFLOW || sym == YY___BUILTIN_SSUBLL_OVERFLOW || sym == YY___BUILTIN_USUB_OVERFLOW || sym == YY___BUILTIN_USUBL_OVERFLOW || sym == YY___BUILTIN_USUBLL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW_P || sym == YY___BUILTIN_SMUL_OVERFLOW || sym == YY___BUILTIN_SMULL_OVERFLOW || sym == YY___BUILTIN_SMULLL_OVERFLOW || sym == YY___BUILTIN_UMUL_OVERFLOW || sym == YY___BUILTIN_UMULL_OVERFLOW || sym == YY___BUILTIN_UMULLL_OVERFLOW || sym == YY___BUILTIN_CONSTANT_P || sym == YY___BUILTIN_VA_ARG || sym == YY__STATIC_ASSERT || sym == YY_TYPEDEF || sym == YY_EXTERN || sym == YY_STATIC || sym == YY_AUTO || sym == YY_REGISTER || sym == YY__THREAD_LOCAL || sym == YY_VOID || sym == YY_CHAR || sym == YY_SHORT || sym == YY_INT || sym == YY_LONG || sym == YY_FLOAT || sym == YY_DOUBLE || sym == YY_SIGNED || sym == YY___SIGNED || sym == YY___SIGNED__ || sym == YY_UNSIGNED || sym == YY__BOOL || sym == YY__COMPLEX || sym == YY___COMPLEX || sym == YY___COMPLEX__ || sym == YY__ATOMIC || sym == YY_TYPEOF || sym == YY___TYPEOF || sym == YY___TYPEOF__ || sym == YY_STRUCT || sym == YY_UNION || sym == YY_ENUM || sym == YY_CONST || sym == YY___CONST || sym == YY___CONST__ || sym == YY_RESTRICT || sym == YY___RESTRICT || sym == YY___RESTRICT__ || sym == YY_VOLATILE || sym == YY___VOLATILE || sym == YY___VOLATILE__ || sym == YY_INLINE || sym == YY___INLINE || sym == YY___INLINE__ || sym == YY__NORETURN || sym == YY___FORCEINLINE || sym == YY__ALIGNAS || sym == YY___ATTRIBUTE || sym == YY___ATTRIBUTE__ || sym == YY___DECLSPEC || sym == YY___CDECL || sym == YY___FASTCALL || sym == YY___UNALIGNED || sym == YY__SEMICOLON) { + while (sym == YY__LBRACE || sym == YY_IF || sym == YY_SWITCH || sym == YY_WHILE || sym == YY_DO || sym == YY_FOR || sym == YY_GOTO || sym == YY_CONTINUE || sym == YY_BREAK || sym == YY_RETURN || sym == YY_ASM || sym == YY___ASM || sym == YY___ASM__ || C_IS_ID(sym) || sym == YY_CASE || sym == YY_DEFAULT || sym == YY__LPAREN || sym == YY_DECIMAL_NUMBER || sym == YY_OCTAL_NUMBER || sym == YY_HEXADECIMAL_NUMBER || sym == YY_BINARY_NUMBER || sym == YY_FLOATING_NUMBER || sym == YY_HEXADECIMAL_FLOATING_NUMBER || sym == YY_CHARACTER || sym == YY_STRING || sym == YY__GENERIC || sym == YY___EXTENSION__ || sym == YY__PLUS_PLUS || sym == YY__MINUS_MINUS || sym == YY__AND || sym == YY__STAR || sym == YY__PLUS || sym == YY__MINUS || sym == YY__TILDE || sym == YY__BANG || sym == YY_SIZEOF || sym == YY__ALIGNOF || sym == YY___ALIGNOF__ || sym == YY___ALIGNOF || sym == YY__AND_AND || sym == YY___BUILTIN_VA_START || sym == YY___BUILTIN_VA_END || sym == YY___BUILTIN_VA_COPY || sym == YY___BUILTIN_ALLOCA || sym == YY___BUILTIN_ABORT || sym == YY___BUILTIN_TRAP || sym == YY___BUILTIN_DEBUGTRAP || sym == YY___BUILTIN_FRAME_ADDRESS || sym == YY___BUILTIN_ABS || sym == YY___BUILTIN_LABS || sym == YY___BUILTIN_LLABS || sym == YY___BUILTIN_FABS || sym == YY___BUILTIN_FABSF || sym == YY___BUILTIN_BSWAP16 || sym == YY___BUILTIN_BSWAP32 || sym == YY___BUILTIN_BSWAP64 || sym == YY___BUILTIN_POPCOUNT || sym == YY___BUILTIN_POPCOUNTL || sym == YY___BUILTIN_POPCOUNTLL || sym == YY___BUILTIN_CLZ || sym == YY___BUILTIN_CLZL || sym == YY___BUILTIN_CLZLL || sym == YY___BUILTIN_CTZ || sym == YY___BUILTIN_CTZL || sym == YY___BUILTIN_CTZLL || sym == YY___BUILTIN_FFS || sym == YY___BUILTIN_FFSL || sym == YY___BUILTIN_FFSLL || sym == YY___BUILTIN_MEMCPY || sym == YY___BUILTIN_MEMSET || sym == YY___BUILTIN_EXPECT || sym == YY___BUILTIN_PREFETCH || sym == YY___BUILTIN_UNREACHABLE || sym == YY___BUILTIN_HUGE_VAL || sym == YY___BUILTIN_HUGE_VALF || sym == YY___BUILTIN_INF || sym == YY___BUILTIN_INFF || sym == YY___BUILTIN_ISUNORDERED || sym == YY___BUILTIN_NAN || sym == YY___BUILTIN_NANF || sym == YY___BUILTIN_ADD_OVERFLOW || sym == YY___BUILTIN_ADD_OVERFLOW_P || sym == YY___BUILTIN_SADD_OVERFLOW || sym == YY___BUILTIN_SADDL_OVERFLOW || sym == YY___BUILTIN_SADDLL_OVERFLOW || sym == YY___BUILTIN_UADD_OVERFLOW || sym == YY___BUILTIN_UADDL_OVERFLOW || sym == YY___BUILTIN_UADDLL_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW_P || sym == YY___BUILTIN_SSUB_OVERFLOW || sym == YY___BUILTIN_SSUBL_OVERFLOW || sym == YY___BUILTIN_SSUBLL_OVERFLOW || sym == YY___BUILTIN_USUB_OVERFLOW || sym == YY___BUILTIN_USUBL_OVERFLOW || sym == YY___BUILTIN_USUBLL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW_P || sym == YY___BUILTIN_SMUL_OVERFLOW || sym == YY___BUILTIN_SMULL_OVERFLOW || sym == YY___BUILTIN_SMULLL_OVERFLOW || sym == YY___BUILTIN_UMUL_OVERFLOW || sym == YY___BUILTIN_UMULL_OVERFLOW || sym == YY___BUILTIN_UMULLL_OVERFLOW || sym == YY___BUILTIN_SHUFFLE || sym == YY___BUILTIN_SHUFFLEVECTOR || sym == YY___BUILTIN_CONSTANT_P || sym == YY___BUILTIN_VA_ARG || sym == YY___BUILTIN_CONVERTVECTOR || sym == YY__STATIC_ASSERT || sym == YY_TYPEDEF || sym == YY_EXTERN || sym == YY_STATIC || sym == YY_AUTO || sym == YY_REGISTER || sym == YY__THREAD_LOCAL || sym == YY_VOID || sym == YY_CHAR || sym == YY_SHORT || sym == YY_INT || sym == YY_LONG || sym == YY_FLOAT || sym == YY_DOUBLE || sym == YY_SIGNED || sym == YY___SIGNED || sym == YY___SIGNED__ || sym == YY_UNSIGNED || sym == YY__BOOL || sym == YY__COMPLEX || sym == YY___COMPLEX || sym == YY___COMPLEX__ || sym == YY__ATOMIC || sym == YY_TYPEOF || sym == YY___TYPEOF || sym == YY___TYPEOF__ || sym == YY_STRUCT || sym == YY_UNION || sym == YY_ENUM || sym == YY_CONST || sym == YY___CONST || sym == YY___CONST__ || sym == YY_RESTRICT || sym == YY___RESTRICT || sym == YY___RESTRICT__ || sym == YY_VOLATILE || sym == YY___VOLATILE || sym == YY___VOLATILE__ || sym == YY_INLINE || sym == YY___INLINE || sym == YY___INLINE__ || sym == YY__NORETURN || sym == YY___FORCEINLINE || sym == YY__ALIGNAS || sym == YY___ATTRIBUTE || sym == YY___ATTRIBUTE__ || sym == YY___DECLSPEC || sym == YY___CDECL || sym == YY___FASTCALL || sym == YY___UNALIGNED || sym == YY__SEMICOLON) { if ((C_IS_ID(sym) || sym == YY_CASE || sym == YY_DEFAULT) && (!C_IS_ID(sym) || is_label(rcc, sym))) { sym = parse_labels(sym, rcc); } else if (sym == YY__LBRACE || sym == YY_IF || sym == YY_SWITCH || sym == YY_WHILE || sym == YY_DO || sym == YY_FOR || sym == YY_GOTO || sym == YY_CONTINUE || sym == YY_BREAK || sym == YY_RETURN || sym == YY_ASM || sym == YY___ASM || sym == YY___ASM__) { sym = parse_c_statement(sym, rcc); } else { if (sym == YY___EXTENSION__) sym = yy_next(rcc); - if ((sym == YY__LPAREN || C_IS_ID(sym) || sym == YY_DECIMAL_NUMBER || sym == YY_OCTAL_NUMBER || sym == YY_HEXADECIMAL_NUMBER || sym == YY_BINARY_NUMBER || sym == YY_FLOATING_NUMBER || sym == YY_HEXADECIMAL_FLOATING_NUMBER || sym == YY_CHARACTER || sym == YY_STRING || sym == YY__GENERIC || sym == YY___EXTENSION__ || sym == YY__PLUS_PLUS || sym == YY__MINUS_MINUS || sym == YY__AND || sym == YY__STAR || sym == YY__PLUS || sym == YY__MINUS || sym == YY__TILDE || sym == YY__BANG || sym == YY_SIZEOF || sym == YY__ALIGNOF || sym == YY___ALIGNOF__ || sym == YY___ALIGNOF || sym == YY__AND_AND || sym == YY___BUILTIN_VA_START || sym == YY___BUILTIN_VA_END || sym == YY___BUILTIN_VA_COPY || sym == YY___BUILTIN_ALLOCA || sym == YY___BUILTIN_ABORT || sym == YY___BUILTIN_TRAP || sym == YY___BUILTIN_DEBUGTRAP || sym == YY___BUILTIN_FRAME_ADDRESS || sym == YY___BUILTIN_ABS || sym == YY___BUILTIN_LABS || sym == YY___BUILTIN_LLABS || sym == YY___BUILTIN_FABS || sym == YY___BUILTIN_FABSF || sym == YY___BUILTIN_BSWAP16 || sym == YY___BUILTIN_BSWAP32 || sym == YY___BUILTIN_BSWAP64 || sym == YY___BUILTIN_POPCOUNT || sym == YY___BUILTIN_POPCOUNTL || sym == YY___BUILTIN_POPCOUNTLL || sym == YY___BUILTIN_CLZ || sym == YY___BUILTIN_CLZL || sym == YY___BUILTIN_CLZLL || sym == YY___BUILTIN_CTZ || sym == YY___BUILTIN_CTZL || sym == YY___BUILTIN_CTZLL || sym == YY___BUILTIN_FFS || sym == YY___BUILTIN_FFSL || sym == YY___BUILTIN_FFSLL || sym == YY___BUILTIN_MEMCPY || sym == YY___BUILTIN_MEMSET || sym == YY___BUILTIN_EXPECT || sym == YY___BUILTIN_PREFETCH || sym == YY___BUILTIN_UNREACHABLE || sym == YY___BUILTIN_HUGE_VAL || sym == YY___BUILTIN_HUGE_VALF || sym == YY___BUILTIN_INF || sym == YY___BUILTIN_INFF || sym == YY___BUILTIN_ISUNORDERED || sym == YY___BUILTIN_NAN || sym == YY___BUILTIN_NANF || sym == YY___BUILTIN_ADD_OVERFLOW || sym == YY___BUILTIN_ADD_OVERFLOW_P || sym == YY___BUILTIN_SADD_OVERFLOW || sym == YY___BUILTIN_SADDL_OVERFLOW || sym == YY___BUILTIN_SADDLL_OVERFLOW || sym == YY___BUILTIN_UADD_OVERFLOW || sym == YY___BUILTIN_UADDL_OVERFLOW || sym == YY___BUILTIN_UADDLL_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW_P || sym == YY___BUILTIN_SSUB_OVERFLOW || sym == YY___BUILTIN_SSUBL_OVERFLOW || sym == YY___BUILTIN_SSUBLL_OVERFLOW || sym == YY___BUILTIN_USUB_OVERFLOW || sym == YY___BUILTIN_USUBL_OVERFLOW || sym == YY___BUILTIN_USUBLL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW_P || sym == YY___BUILTIN_SMUL_OVERFLOW || sym == YY___BUILTIN_SMULL_OVERFLOW || sym == YY___BUILTIN_SMULLL_OVERFLOW || sym == YY___BUILTIN_UMUL_OVERFLOW || sym == YY___BUILTIN_UMULL_OVERFLOW || sym == YY___BUILTIN_UMULLL_OVERFLOW || sym == YY___BUILTIN_CONSTANT_P || sym == YY___BUILTIN_VA_ARG) && (!C_IS_ID(sym) || !is_typedef_name(rcc, sym))) { + if ((sym == YY__LPAREN || C_IS_ID(sym) || sym == YY_DECIMAL_NUMBER || sym == YY_OCTAL_NUMBER || sym == YY_HEXADECIMAL_NUMBER || sym == YY_BINARY_NUMBER || sym == YY_FLOATING_NUMBER || sym == YY_HEXADECIMAL_FLOATING_NUMBER || sym == YY_CHARACTER || sym == YY_STRING || sym == YY__GENERIC || sym == YY___EXTENSION__ || sym == YY__PLUS_PLUS || sym == YY__MINUS_MINUS || sym == YY__AND || sym == YY__STAR || sym == YY__PLUS || sym == YY__MINUS || sym == YY__TILDE || sym == YY__BANG || sym == YY_SIZEOF || sym == YY__ALIGNOF || sym == YY___ALIGNOF__ || sym == YY___ALIGNOF || sym == YY__AND_AND || sym == YY___BUILTIN_VA_START || sym == YY___BUILTIN_VA_END || sym == YY___BUILTIN_VA_COPY || sym == YY___BUILTIN_ALLOCA || sym == YY___BUILTIN_ABORT || sym == YY___BUILTIN_TRAP || sym == YY___BUILTIN_DEBUGTRAP || sym == YY___BUILTIN_FRAME_ADDRESS || sym == YY___BUILTIN_ABS || sym == YY___BUILTIN_LABS || sym == YY___BUILTIN_LLABS || sym == YY___BUILTIN_FABS || sym == YY___BUILTIN_FABSF || sym == YY___BUILTIN_BSWAP16 || sym == YY___BUILTIN_BSWAP32 || sym == YY___BUILTIN_BSWAP64 || sym == YY___BUILTIN_POPCOUNT || sym == YY___BUILTIN_POPCOUNTL || sym == YY___BUILTIN_POPCOUNTLL || sym == YY___BUILTIN_CLZ || sym == YY___BUILTIN_CLZL || sym == YY___BUILTIN_CLZLL || sym == YY___BUILTIN_CTZ || sym == YY___BUILTIN_CTZL || sym == YY___BUILTIN_CTZLL || sym == YY___BUILTIN_FFS || sym == YY___BUILTIN_FFSL || sym == YY___BUILTIN_FFSLL || sym == YY___BUILTIN_MEMCPY || sym == YY___BUILTIN_MEMSET || sym == YY___BUILTIN_EXPECT || sym == YY___BUILTIN_PREFETCH || sym == YY___BUILTIN_UNREACHABLE || sym == YY___BUILTIN_HUGE_VAL || sym == YY___BUILTIN_HUGE_VALF || sym == YY___BUILTIN_INF || sym == YY___BUILTIN_INFF || sym == YY___BUILTIN_ISUNORDERED || sym == YY___BUILTIN_NAN || sym == YY___BUILTIN_NANF || sym == YY___BUILTIN_ADD_OVERFLOW || sym == YY___BUILTIN_ADD_OVERFLOW_P || sym == YY___BUILTIN_SADD_OVERFLOW || sym == YY___BUILTIN_SADDL_OVERFLOW || sym == YY___BUILTIN_SADDLL_OVERFLOW || sym == YY___BUILTIN_UADD_OVERFLOW || sym == YY___BUILTIN_UADDL_OVERFLOW || sym == YY___BUILTIN_UADDLL_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW_P || sym == YY___BUILTIN_SSUB_OVERFLOW || sym == YY___BUILTIN_SSUBL_OVERFLOW || sym == YY___BUILTIN_SSUBLL_OVERFLOW || sym == YY___BUILTIN_USUB_OVERFLOW || sym == YY___BUILTIN_USUBL_OVERFLOW || sym == YY___BUILTIN_USUBLL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW_P || sym == YY___BUILTIN_SMUL_OVERFLOW || sym == YY___BUILTIN_SMULL_OVERFLOW || sym == YY___BUILTIN_SMULLL_OVERFLOW || sym == YY___BUILTIN_UMUL_OVERFLOW || sym == YY___BUILTIN_UMULL_OVERFLOW || sym == YY___BUILTIN_UMULLL_OVERFLOW || sym == YY___BUILTIN_SHUFFLE || sym == YY___BUILTIN_SHUFFLEVECTOR || sym == YY___BUILTIN_CONSTANT_P || sym == YY___BUILTIN_VA_ARG || sym == YY___BUILTIN_CONVERTVECTOR) && (!C_IS_ID(sym) || !is_typedef_name(rcc, sym))) { sym = parse_expression(sym, rcc, &val); if (sym != YY__SEMICOLON) { yy_error_sym("';' expected, got", sym); @@ -1691,7 +1691,7 @@ static yy_sym parse_expression_statement(yy_sym sym, rcc_ctx *rcc, c_value *val) } sym = get_sym(); } - while (sym == YY__LBRACE || sym == YY_IF || sym == YY_SWITCH || sym == YY_WHILE || sym == YY_DO || sym == YY_FOR || sym == YY_GOTO || sym == YY_CONTINUE || sym == YY_BREAK || sym == YY_RETURN || sym == YY_ASM || sym == YY___ASM || sym == YY___ASM__ || C_IS_ID(sym) || sym == YY_CASE || sym == YY_DEFAULT || sym == YY__LPAREN || sym == YY_DECIMAL_NUMBER || sym == YY_OCTAL_NUMBER || sym == YY_HEXADECIMAL_NUMBER || sym == YY_BINARY_NUMBER || sym == YY_FLOATING_NUMBER || sym == YY_HEXADECIMAL_FLOATING_NUMBER || sym == YY_CHARACTER || sym == YY_STRING || sym == YY__GENERIC || sym == YY___EXTENSION__ || sym == YY__PLUS_PLUS || sym == YY__MINUS_MINUS || sym == YY__AND || sym == YY__STAR || sym == YY__PLUS || sym == YY__MINUS || sym == YY__TILDE || sym == YY__BANG || sym == YY_SIZEOF || sym == YY__ALIGNOF || sym == YY___ALIGNOF__ || sym == YY___ALIGNOF || sym == YY__AND_AND || sym == YY___BUILTIN_VA_START || sym == YY___BUILTIN_VA_END || sym == YY___BUILTIN_VA_COPY || sym == YY___BUILTIN_ALLOCA || sym == YY___BUILTIN_ABORT || sym == YY___BUILTIN_TRAP || sym == YY___BUILTIN_DEBUGTRAP || sym == YY___BUILTIN_FRAME_ADDRESS || sym == YY___BUILTIN_ABS || sym == YY___BUILTIN_LABS || sym == YY___BUILTIN_LLABS || sym == YY___BUILTIN_FABS || sym == YY___BUILTIN_FABSF || sym == YY___BUILTIN_BSWAP16 || sym == YY___BUILTIN_BSWAP32 || sym == YY___BUILTIN_BSWAP64 || sym == YY___BUILTIN_POPCOUNT || sym == YY___BUILTIN_POPCOUNTL || sym == YY___BUILTIN_POPCOUNTLL || sym == YY___BUILTIN_CLZ || sym == YY___BUILTIN_CLZL || sym == YY___BUILTIN_CLZLL || sym == YY___BUILTIN_CTZ || sym == YY___BUILTIN_CTZL || sym == YY___BUILTIN_CTZLL || sym == YY___BUILTIN_FFS || sym == YY___BUILTIN_FFSL || sym == YY___BUILTIN_FFSLL || sym == YY___BUILTIN_MEMCPY || sym == YY___BUILTIN_MEMSET || sym == YY___BUILTIN_EXPECT || sym == YY___BUILTIN_PREFETCH || sym == YY___BUILTIN_UNREACHABLE || sym == YY___BUILTIN_HUGE_VAL || sym == YY___BUILTIN_HUGE_VALF || sym == YY___BUILTIN_INF || sym == YY___BUILTIN_INFF || sym == YY___BUILTIN_ISUNORDERED || sym == YY___BUILTIN_NAN || sym == YY___BUILTIN_NANF || sym == YY___BUILTIN_ADD_OVERFLOW || sym == YY___BUILTIN_ADD_OVERFLOW_P || sym == YY___BUILTIN_SADD_OVERFLOW || sym == YY___BUILTIN_SADDL_OVERFLOW || sym == YY___BUILTIN_SADDLL_OVERFLOW || sym == YY___BUILTIN_UADD_OVERFLOW || sym == YY___BUILTIN_UADDL_OVERFLOW || sym == YY___BUILTIN_UADDLL_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW_P || sym == YY___BUILTIN_SSUB_OVERFLOW || sym == YY___BUILTIN_SSUBL_OVERFLOW || sym == YY___BUILTIN_SSUBLL_OVERFLOW || sym == YY___BUILTIN_USUB_OVERFLOW || sym == YY___BUILTIN_USUBL_OVERFLOW || sym == YY___BUILTIN_USUBLL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW_P || sym == YY___BUILTIN_SMUL_OVERFLOW || sym == YY___BUILTIN_SMULL_OVERFLOW || sym == YY___BUILTIN_SMULLL_OVERFLOW || sym == YY___BUILTIN_UMUL_OVERFLOW || sym == YY___BUILTIN_UMULL_OVERFLOW || sym == YY___BUILTIN_UMULLL_OVERFLOW || sym == YY___BUILTIN_CONSTANT_P || sym == YY___BUILTIN_VA_ARG || sym == YY__STATIC_ASSERT || sym == YY_TYPEDEF || sym == YY_EXTERN || sym == YY_STATIC || sym == YY_AUTO || sym == YY_REGISTER || sym == YY__THREAD_LOCAL || sym == YY_VOID || sym == YY_CHAR || sym == YY_SHORT || sym == YY_INT || sym == YY_LONG || sym == YY_FLOAT || sym == YY_DOUBLE || sym == YY_SIGNED || sym == YY___SIGNED || sym == YY___SIGNED__ || sym == YY_UNSIGNED || sym == YY__BOOL || sym == YY__COMPLEX || sym == YY___COMPLEX || sym == YY___COMPLEX__ || sym == YY__ATOMIC || sym == YY_TYPEOF || sym == YY___TYPEOF || sym == YY___TYPEOF__ || sym == YY_STRUCT || sym == YY_UNION || sym == YY_ENUM || sym == YY_CONST || sym == YY___CONST || sym == YY___CONST__ || sym == YY_RESTRICT || sym == YY___RESTRICT || sym == YY___RESTRICT__ || sym == YY_VOLATILE || sym == YY___VOLATILE || sym == YY___VOLATILE__ || sym == YY_INLINE || sym == YY___INLINE || sym == YY___INLINE__ || sym == YY__NORETURN || sym == YY___FORCEINLINE || sym == YY__ALIGNAS || sym == YY___ATTRIBUTE || sym == YY___ATTRIBUTE__ || sym == YY___DECLSPEC || sym == YY___CDECL || sym == YY___FASTCALL || sym == YY___UNALIGNED || sym == YY__SEMICOLON) { + while (sym == YY__LBRACE || sym == YY_IF || sym == YY_SWITCH || sym == YY_WHILE || sym == YY_DO || sym == YY_FOR || sym == YY_GOTO || sym == YY_CONTINUE || sym == YY_BREAK || sym == YY_RETURN || sym == YY_ASM || sym == YY___ASM || sym == YY___ASM__ || C_IS_ID(sym) || sym == YY_CASE || sym == YY_DEFAULT || sym == YY__LPAREN || sym == YY_DECIMAL_NUMBER || sym == YY_OCTAL_NUMBER || sym == YY_HEXADECIMAL_NUMBER || sym == YY_BINARY_NUMBER || sym == YY_FLOATING_NUMBER || sym == YY_HEXADECIMAL_FLOATING_NUMBER || sym == YY_CHARACTER || sym == YY_STRING || sym == YY__GENERIC || sym == YY___EXTENSION__ || sym == YY__PLUS_PLUS || sym == YY__MINUS_MINUS || sym == YY__AND || sym == YY__STAR || sym == YY__PLUS || sym == YY__MINUS || sym == YY__TILDE || sym == YY__BANG || sym == YY_SIZEOF || sym == YY__ALIGNOF || sym == YY___ALIGNOF__ || sym == YY___ALIGNOF || sym == YY__AND_AND || sym == YY___BUILTIN_VA_START || sym == YY___BUILTIN_VA_END || sym == YY___BUILTIN_VA_COPY || sym == YY___BUILTIN_ALLOCA || sym == YY___BUILTIN_ABORT || sym == YY___BUILTIN_TRAP || sym == YY___BUILTIN_DEBUGTRAP || sym == YY___BUILTIN_FRAME_ADDRESS || sym == YY___BUILTIN_ABS || sym == YY___BUILTIN_LABS || sym == YY___BUILTIN_LLABS || sym == YY___BUILTIN_FABS || sym == YY___BUILTIN_FABSF || sym == YY___BUILTIN_BSWAP16 || sym == YY___BUILTIN_BSWAP32 || sym == YY___BUILTIN_BSWAP64 || sym == YY___BUILTIN_POPCOUNT || sym == YY___BUILTIN_POPCOUNTL || sym == YY___BUILTIN_POPCOUNTLL || sym == YY___BUILTIN_CLZ || sym == YY___BUILTIN_CLZL || sym == YY___BUILTIN_CLZLL || sym == YY___BUILTIN_CTZ || sym == YY___BUILTIN_CTZL || sym == YY___BUILTIN_CTZLL || sym == YY___BUILTIN_FFS || sym == YY___BUILTIN_FFSL || sym == YY___BUILTIN_FFSLL || sym == YY___BUILTIN_MEMCPY || sym == YY___BUILTIN_MEMSET || sym == YY___BUILTIN_EXPECT || sym == YY___BUILTIN_PREFETCH || sym == YY___BUILTIN_UNREACHABLE || sym == YY___BUILTIN_HUGE_VAL || sym == YY___BUILTIN_HUGE_VALF || sym == YY___BUILTIN_INF || sym == YY___BUILTIN_INFF || sym == YY___BUILTIN_ISUNORDERED || sym == YY___BUILTIN_NAN || sym == YY___BUILTIN_NANF || sym == YY___BUILTIN_ADD_OVERFLOW || sym == YY___BUILTIN_ADD_OVERFLOW_P || sym == YY___BUILTIN_SADD_OVERFLOW || sym == YY___BUILTIN_SADDL_OVERFLOW || sym == YY___BUILTIN_SADDLL_OVERFLOW || sym == YY___BUILTIN_UADD_OVERFLOW || sym == YY___BUILTIN_UADDL_OVERFLOW || sym == YY___BUILTIN_UADDLL_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW_P || sym == YY___BUILTIN_SSUB_OVERFLOW || sym == YY___BUILTIN_SSUBL_OVERFLOW || sym == YY___BUILTIN_SSUBLL_OVERFLOW || sym == YY___BUILTIN_USUB_OVERFLOW || sym == YY___BUILTIN_USUBL_OVERFLOW || sym == YY___BUILTIN_USUBLL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW_P || sym == YY___BUILTIN_SMUL_OVERFLOW || sym == YY___BUILTIN_SMULL_OVERFLOW || sym == YY___BUILTIN_SMULLL_OVERFLOW || sym == YY___BUILTIN_UMUL_OVERFLOW || sym == YY___BUILTIN_UMULL_OVERFLOW || sym == YY___BUILTIN_UMULLL_OVERFLOW || sym == YY___BUILTIN_SHUFFLE || sym == YY___BUILTIN_SHUFFLEVECTOR || sym == YY___BUILTIN_CONSTANT_P || sym == YY___BUILTIN_VA_ARG || sym == YY___BUILTIN_CONVERTVECTOR || sym == YY__STATIC_ASSERT || sym == YY_TYPEDEF || sym == YY_EXTERN || sym == YY_STATIC || sym == YY_AUTO || sym == YY_REGISTER || sym == YY__THREAD_LOCAL || sym == YY_VOID || sym == YY_CHAR || sym == YY_SHORT || sym == YY_INT || sym == YY_LONG || sym == YY_FLOAT || sym == YY_DOUBLE || sym == YY_SIGNED || sym == YY___SIGNED || sym == YY___SIGNED__ || sym == YY_UNSIGNED || sym == YY__BOOL || sym == YY__COMPLEX || sym == YY___COMPLEX || sym == YY___COMPLEX__ || sym == YY__ATOMIC || sym == YY_TYPEOF || sym == YY___TYPEOF || sym == YY___TYPEOF__ || sym == YY_STRUCT || sym == YY_UNION || sym == YY_ENUM || sym == YY_CONST || sym == YY___CONST || sym == YY___CONST__ || sym == YY_RESTRICT || sym == YY___RESTRICT || sym == YY___RESTRICT__ || sym == YY_VOLATILE || sym == YY___VOLATILE || sym == YY___VOLATILE__ || sym == YY_INLINE || sym == YY___INLINE || sym == YY___INLINE__ || sym == YY__NORETURN || sym == YY___FORCEINLINE || sym == YY__ALIGNAS || sym == YY___ATTRIBUTE || sym == YY___ATTRIBUTE__ || sym == YY___DECLSPEC || sym == YY___CDECL || sym == YY___FASTCALL || sym == YY___UNALIGNED || sym == YY__SEMICOLON) { c_value_clear(val); if ((C_IS_ID(sym) || sym == YY_CASE || sym == YY_DEFAULT) && (!C_IS_ID(sym) || is_label(rcc, sym))) { sym = parse_labels(sym, rcc); @@ -1699,7 +1699,7 @@ static yy_sym parse_expression_statement(yy_sym sym, rcc_ctx *rcc, c_value *val) sym = parse_c_statement(sym, rcc); } else { if (sym == YY___EXTENSION__) sym = yy_next(rcc); - if ((sym == YY__LPAREN || C_IS_ID(sym) || sym == YY_DECIMAL_NUMBER || sym == YY_OCTAL_NUMBER || sym == YY_HEXADECIMAL_NUMBER || sym == YY_BINARY_NUMBER || sym == YY_FLOATING_NUMBER || sym == YY_HEXADECIMAL_FLOATING_NUMBER || sym == YY_CHARACTER || sym == YY_STRING || sym == YY__GENERIC || sym == YY___EXTENSION__ || sym == YY__PLUS_PLUS || sym == YY__MINUS_MINUS || sym == YY__AND || sym == YY__STAR || sym == YY__PLUS || sym == YY__MINUS || sym == YY__TILDE || sym == YY__BANG || sym == YY_SIZEOF || sym == YY__ALIGNOF || sym == YY___ALIGNOF__ || sym == YY___ALIGNOF || sym == YY__AND_AND || sym == YY___BUILTIN_VA_START || sym == YY___BUILTIN_VA_END || sym == YY___BUILTIN_VA_COPY || sym == YY___BUILTIN_ALLOCA || sym == YY___BUILTIN_ABORT || sym == YY___BUILTIN_TRAP || sym == YY___BUILTIN_DEBUGTRAP || sym == YY___BUILTIN_FRAME_ADDRESS || sym == YY___BUILTIN_ABS || sym == YY___BUILTIN_LABS || sym == YY___BUILTIN_LLABS || sym == YY___BUILTIN_FABS || sym == YY___BUILTIN_FABSF || sym == YY___BUILTIN_BSWAP16 || sym == YY___BUILTIN_BSWAP32 || sym == YY___BUILTIN_BSWAP64 || sym == YY___BUILTIN_POPCOUNT || sym == YY___BUILTIN_POPCOUNTL || sym == YY___BUILTIN_POPCOUNTLL || sym == YY___BUILTIN_CLZ || sym == YY___BUILTIN_CLZL || sym == YY___BUILTIN_CLZLL || sym == YY___BUILTIN_CTZ || sym == YY___BUILTIN_CTZL || sym == YY___BUILTIN_CTZLL || sym == YY___BUILTIN_FFS || sym == YY___BUILTIN_FFSL || sym == YY___BUILTIN_FFSLL || sym == YY___BUILTIN_MEMCPY || sym == YY___BUILTIN_MEMSET || sym == YY___BUILTIN_EXPECT || sym == YY___BUILTIN_PREFETCH || sym == YY___BUILTIN_UNREACHABLE || sym == YY___BUILTIN_HUGE_VAL || sym == YY___BUILTIN_HUGE_VALF || sym == YY___BUILTIN_INF || sym == YY___BUILTIN_INFF || sym == YY___BUILTIN_ISUNORDERED || sym == YY___BUILTIN_NAN || sym == YY___BUILTIN_NANF || sym == YY___BUILTIN_ADD_OVERFLOW || sym == YY___BUILTIN_ADD_OVERFLOW_P || sym == YY___BUILTIN_SADD_OVERFLOW || sym == YY___BUILTIN_SADDL_OVERFLOW || sym == YY___BUILTIN_SADDLL_OVERFLOW || sym == YY___BUILTIN_UADD_OVERFLOW || sym == YY___BUILTIN_UADDL_OVERFLOW || sym == YY___BUILTIN_UADDLL_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW_P || sym == YY___BUILTIN_SSUB_OVERFLOW || sym == YY___BUILTIN_SSUBL_OVERFLOW || sym == YY___BUILTIN_SSUBLL_OVERFLOW || sym == YY___BUILTIN_USUB_OVERFLOW || sym == YY___BUILTIN_USUBL_OVERFLOW || sym == YY___BUILTIN_USUBLL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW_P || sym == YY___BUILTIN_SMUL_OVERFLOW || sym == YY___BUILTIN_SMULL_OVERFLOW || sym == YY___BUILTIN_SMULLL_OVERFLOW || sym == YY___BUILTIN_UMUL_OVERFLOW || sym == YY___BUILTIN_UMULL_OVERFLOW || sym == YY___BUILTIN_UMULLL_OVERFLOW || sym == YY___BUILTIN_CONSTANT_P || sym == YY___BUILTIN_VA_ARG) && (!C_IS_ID(sym) || !is_typedef_name(rcc, sym))) { + if ((sym == YY__LPAREN || C_IS_ID(sym) || sym == YY_DECIMAL_NUMBER || sym == YY_OCTAL_NUMBER || sym == YY_HEXADECIMAL_NUMBER || sym == YY_BINARY_NUMBER || sym == YY_FLOATING_NUMBER || sym == YY_HEXADECIMAL_FLOATING_NUMBER || sym == YY_CHARACTER || sym == YY_STRING || sym == YY__GENERIC || sym == YY___EXTENSION__ || sym == YY__PLUS_PLUS || sym == YY__MINUS_MINUS || sym == YY__AND || sym == YY__STAR || sym == YY__PLUS || sym == YY__MINUS || sym == YY__TILDE || sym == YY__BANG || sym == YY_SIZEOF || sym == YY__ALIGNOF || sym == YY___ALIGNOF__ || sym == YY___ALIGNOF || sym == YY__AND_AND || sym == YY___BUILTIN_VA_START || sym == YY___BUILTIN_VA_END || sym == YY___BUILTIN_VA_COPY || sym == YY___BUILTIN_ALLOCA || sym == YY___BUILTIN_ABORT || sym == YY___BUILTIN_TRAP || sym == YY___BUILTIN_DEBUGTRAP || sym == YY___BUILTIN_FRAME_ADDRESS || sym == YY___BUILTIN_ABS || sym == YY___BUILTIN_LABS || sym == YY___BUILTIN_LLABS || sym == YY___BUILTIN_FABS || sym == YY___BUILTIN_FABSF || sym == YY___BUILTIN_BSWAP16 || sym == YY___BUILTIN_BSWAP32 || sym == YY___BUILTIN_BSWAP64 || sym == YY___BUILTIN_POPCOUNT || sym == YY___BUILTIN_POPCOUNTL || sym == YY___BUILTIN_POPCOUNTLL || sym == YY___BUILTIN_CLZ || sym == YY___BUILTIN_CLZL || sym == YY___BUILTIN_CLZLL || sym == YY___BUILTIN_CTZ || sym == YY___BUILTIN_CTZL || sym == YY___BUILTIN_CTZLL || sym == YY___BUILTIN_FFS || sym == YY___BUILTIN_FFSL || sym == YY___BUILTIN_FFSLL || sym == YY___BUILTIN_MEMCPY || sym == YY___BUILTIN_MEMSET || sym == YY___BUILTIN_EXPECT || sym == YY___BUILTIN_PREFETCH || sym == YY___BUILTIN_UNREACHABLE || sym == YY___BUILTIN_HUGE_VAL || sym == YY___BUILTIN_HUGE_VALF || sym == YY___BUILTIN_INF || sym == YY___BUILTIN_INFF || sym == YY___BUILTIN_ISUNORDERED || sym == YY___BUILTIN_NAN || sym == YY___BUILTIN_NANF || sym == YY___BUILTIN_ADD_OVERFLOW || sym == YY___BUILTIN_ADD_OVERFLOW_P || sym == YY___BUILTIN_SADD_OVERFLOW || sym == YY___BUILTIN_SADDL_OVERFLOW || sym == YY___BUILTIN_SADDLL_OVERFLOW || sym == YY___BUILTIN_UADD_OVERFLOW || sym == YY___BUILTIN_UADDL_OVERFLOW || sym == YY___BUILTIN_UADDLL_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW_P || sym == YY___BUILTIN_SSUB_OVERFLOW || sym == YY___BUILTIN_SSUBL_OVERFLOW || sym == YY___BUILTIN_SSUBLL_OVERFLOW || sym == YY___BUILTIN_USUB_OVERFLOW || sym == YY___BUILTIN_USUBL_OVERFLOW || sym == YY___BUILTIN_USUBLL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW_P || sym == YY___BUILTIN_SMUL_OVERFLOW || sym == YY___BUILTIN_SMULL_OVERFLOW || sym == YY___BUILTIN_SMULLL_OVERFLOW || sym == YY___BUILTIN_UMUL_OVERFLOW || sym == YY___BUILTIN_UMULL_OVERFLOW || sym == YY___BUILTIN_UMULLL_OVERFLOW || sym == YY___BUILTIN_SHUFFLE || sym == YY___BUILTIN_SHUFFLEVECTOR || sym == YY___BUILTIN_CONSTANT_P || sym == YY___BUILTIN_VA_ARG || sym == YY___BUILTIN_CONVERTVECTOR) && (!C_IS_ID(sym) || !is_typedef_name(rcc, sym))) { sym = parse_expression(sym, rcc, val); if (sym != YY__SEMICOLON) { yy_error_sym("';' expected, got", sym); @@ -1720,7 +1720,7 @@ static yy_sym parse_statement(yy_sym sym, rcc_ctx *rcc) { } if (sym == YY__LBRACE || sym == YY_IF || sym == YY_SWITCH || sym == YY_WHILE || sym == YY_DO || sym == YY_FOR || sym == YY_GOTO || sym == YY_CONTINUE || sym == YY_BREAK || sym == YY_RETURN || sym == YY_ASM || sym == YY___ASM || sym == YY___ASM__) { sym = parse_c_statement(sym, rcc); - } else if (sym == YY__LPAREN || C_IS_ID(sym) || sym == YY_DECIMAL_NUMBER || sym == YY_OCTAL_NUMBER || sym == YY_HEXADECIMAL_NUMBER || sym == YY_BINARY_NUMBER || sym == YY_FLOATING_NUMBER || sym == YY_HEXADECIMAL_FLOATING_NUMBER || sym == YY_CHARACTER || sym == YY_STRING || sym == YY__GENERIC || sym == YY___EXTENSION__ || sym == YY__PLUS_PLUS || sym == YY__MINUS_MINUS || sym == YY__AND || sym == YY__STAR || sym == YY__PLUS || sym == YY__MINUS || sym == YY__TILDE || sym == YY__BANG || sym == YY_SIZEOF || sym == YY__ALIGNOF || sym == YY___ALIGNOF__ || sym == YY___ALIGNOF || sym == YY__AND_AND || sym == YY___BUILTIN_VA_START || sym == YY___BUILTIN_VA_END || sym == YY___BUILTIN_VA_COPY || sym == YY___BUILTIN_ALLOCA || sym == YY___BUILTIN_ABORT || sym == YY___BUILTIN_TRAP || sym == YY___BUILTIN_DEBUGTRAP || sym == YY___BUILTIN_FRAME_ADDRESS || sym == YY___BUILTIN_ABS || sym == YY___BUILTIN_LABS || sym == YY___BUILTIN_LLABS || sym == YY___BUILTIN_FABS || sym == YY___BUILTIN_FABSF || sym == YY___BUILTIN_BSWAP16 || sym == YY___BUILTIN_BSWAP32 || sym == YY___BUILTIN_BSWAP64 || sym == YY___BUILTIN_POPCOUNT || sym == YY___BUILTIN_POPCOUNTL || sym == YY___BUILTIN_POPCOUNTLL || sym == YY___BUILTIN_CLZ || sym == YY___BUILTIN_CLZL || sym == YY___BUILTIN_CLZLL || sym == YY___BUILTIN_CTZ || sym == YY___BUILTIN_CTZL || sym == YY___BUILTIN_CTZLL || sym == YY___BUILTIN_FFS || sym == YY___BUILTIN_FFSL || sym == YY___BUILTIN_FFSLL || sym == YY___BUILTIN_MEMCPY || sym == YY___BUILTIN_MEMSET || sym == YY___BUILTIN_EXPECT || sym == YY___BUILTIN_PREFETCH || sym == YY___BUILTIN_UNREACHABLE || sym == YY___BUILTIN_HUGE_VAL || sym == YY___BUILTIN_HUGE_VALF || sym == YY___BUILTIN_INF || sym == YY___BUILTIN_INFF || sym == YY___BUILTIN_ISUNORDERED || sym == YY___BUILTIN_NAN || sym == YY___BUILTIN_NANF || sym == YY___BUILTIN_ADD_OVERFLOW || sym == YY___BUILTIN_ADD_OVERFLOW_P || sym == YY___BUILTIN_SADD_OVERFLOW || sym == YY___BUILTIN_SADDL_OVERFLOW || sym == YY___BUILTIN_SADDLL_OVERFLOW || sym == YY___BUILTIN_UADD_OVERFLOW || sym == YY___BUILTIN_UADDL_OVERFLOW || sym == YY___BUILTIN_UADDLL_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW_P || sym == YY___BUILTIN_SSUB_OVERFLOW || sym == YY___BUILTIN_SSUBL_OVERFLOW || sym == YY___BUILTIN_SSUBLL_OVERFLOW || sym == YY___BUILTIN_USUB_OVERFLOW || sym == YY___BUILTIN_USUBL_OVERFLOW || sym == YY___BUILTIN_USUBLL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW_P || sym == YY___BUILTIN_SMUL_OVERFLOW || sym == YY___BUILTIN_SMULL_OVERFLOW || sym == YY___BUILTIN_SMULLL_OVERFLOW || sym == YY___BUILTIN_UMUL_OVERFLOW || sym == YY___BUILTIN_UMULL_OVERFLOW || sym == YY___BUILTIN_UMULLL_OVERFLOW || sym == YY___BUILTIN_CONSTANT_P || sym == YY___BUILTIN_VA_ARG) { + } else if (sym == YY__LPAREN || C_IS_ID(sym) || sym == YY_DECIMAL_NUMBER || sym == YY_OCTAL_NUMBER || sym == YY_HEXADECIMAL_NUMBER || sym == YY_BINARY_NUMBER || sym == YY_FLOATING_NUMBER || sym == YY_HEXADECIMAL_FLOATING_NUMBER || sym == YY_CHARACTER || sym == YY_STRING || sym == YY__GENERIC || sym == YY___EXTENSION__ || sym == YY__PLUS_PLUS || sym == YY__MINUS_MINUS || sym == YY__AND || sym == YY__STAR || sym == YY__PLUS || sym == YY__MINUS || sym == YY__TILDE || sym == YY__BANG || sym == YY_SIZEOF || sym == YY__ALIGNOF || sym == YY___ALIGNOF__ || sym == YY___ALIGNOF || sym == YY__AND_AND || sym == YY___BUILTIN_VA_START || sym == YY___BUILTIN_VA_END || sym == YY___BUILTIN_VA_COPY || sym == YY___BUILTIN_ALLOCA || sym == YY___BUILTIN_ABORT || sym == YY___BUILTIN_TRAP || sym == YY___BUILTIN_DEBUGTRAP || sym == YY___BUILTIN_FRAME_ADDRESS || sym == YY___BUILTIN_ABS || sym == YY___BUILTIN_LABS || sym == YY___BUILTIN_LLABS || sym == YY___BUILTIN_FABS || sym == YY___BUILTIN_FABSF || sym == YY___BUILTIN_BSWAP16 || sym == YY___BUILTIN_BSWAP32 || sym == YY___BUILTIN_BSWAP64 || sym == YY___BUILTIN_POPCOUNT || sym == YY___BUILTIN_POPCOUNTL || sym == YY___BUILTIN_POPCOUNTLL || sym == YY___BUILTIN_CLZ || sym == YY___BUILTIN_CLZL || sym == YY___BUILTIN_CLZLL || sym == YY___BUILTIN_CTZ || sym == YY___BUILTIN_CTZL || sym == YY___BUILTIN_CTZLL || sym == YY___BUILTIN_FFS || sym == YY___BUILTIN_FFSL || sym == YY___BUILTIN_FFSLL || sym == YY___BUILTIN_MEMCPY || sym == YY___BUILTIN_MEMSET || sym == YY___BUILTIN_EXPECT || sym == YY___BUILTIN_PREFETCH || sym == YY___BUILTIN_UNREACHABLE || sym == YY___BUILTIN_HUGE_VAL || sym == YY___BUILTIN_HUGE_VALF || sym == YY___BUILTIN_INF || sym == YY___BUILTIN_INFF || sym == YY___BUILTIN_ISUNORDERED || sym == YY___BUILTIN_NAN || sym == YY___BUILTIN_NANF || sym == YY___BUILTIN_ADD_OVERFLOW || sym == YY___BUILTIN_ADD_OVERFLOW_P || sym == YY___BUILTIN_SADD_OVERFLOW || sym == YY___BUILTIN_SADDL_OVERFLOW || sym == YY___BUILTIN_SADDLL_OVERFLOW || sym == YY___BUILTIN_UADD_OVERFLOW || sym == YY___BUILTIN_UADDL_OVERFLOW || sym == YY___BUILTIN_UADDLL_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW_P || sym == YY___BUILTIN_SSUB_OVERFLOW || sym == YY___BUILTIN_SSUBL_OVERFLOW || sym == YY___BUILTIN_SSUBLL_OVERFLOW || sym == YY___BUILTIN_USUB_OVERFLOW || sym == YY___BUILTIN_USUBL_OVERFLOW || sym == YY___BUILTIN_USUBLL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW_P || sym == YY___BUILTIN_SMUL_OVERFLOW || sym == YY___BUILTIN_SMULL_OVERFLOW || sym == YY___BUILTIN_SMULLL_OVERFLOW || sym == YY___BUILTIN_UMUL_OVERFLOW || sym == YY___BUILTIN_UMULL_OVERFLOW || sym == YY___BUILTIN_UMULLL_OVERFLOW || sym == YY___BUILTIN_SHUFFLE || sym == YY___BUILTIN_SHUFFLEVECTOR || sym == YY___BUILTIN_CONSTANT_P || sym == YY___BUILTIN_VA_ARG || sym == YY___BUILTIN_CONVERTVECTOR) { c_value_clear(&val); sym = parse_expression(sym, rcc, &val); if (sym != YY__SEMICOLON) { @@ -1890,8 +1890,8 @@ static yy_sym parse_c_statement(yy_sym sym, rcc_ctx *rcc) { yy_error_sym("'(' expected, got", sym); } sym = get_sym(); - if ((sym == YY__LPAREN || C_IS_ID(sym) || sym == YY_DECIMAL_NUMBER || sym == YY_OCTAL_NUMBER || sym == YY_HEXADECIMAL_NUMBER || sym == YY_BINARY_NUMBER || sym == YY_FLOATING_NUMBER || sym == YY_HEXADECIMAL_FLOATING_NUMBER || sym == YY_CHARACTER || sym == YY_STRING || sym == YY__GENERIC || sym == YY___EXTENSION__ || sym == YY__PLUS_PLUS || sym == YY__MINUS_MINUS || sym == YY__AND || sym == YY__STAR || sym == YY__PLUS || sym == YY__MINUS || sym == YY__TILDE || sym == YY__BANG || sym == YY_SIZEOF || sym == YY__ALIGNOF || sym == YY___ALIGNOF__ || sym == YY___ALIGNOF || sym == YY__AND_AND || sym == YY___BUILTIN_VA_START || sym == YY___BUILTIN_VA_END || sym == YY___BUILTIN_VA_COPY || sym == YY___BUILTIN_ALLOCA || sym == YY___BUILTIN_ABORT || sym == YY___BUILTIN_TRAP || sym == YY___BUILTIN_DEBUGTRAP || sym == YY___BUILTIN_FRAME_ADDRESS || sym == YY___BUILTIN_ABS || sym == YY___BUILTIN_LABS || sym == YY___BUILTIN_LLABS || sym == YY___BUILTIN_FABS || sym == YY___BUILTIN_FABSF || sym == YY___BUILTIN_BSWAP16 || sym == YY___BUILTIN_BSWAP32 || sym == YY___BUILTIN_BSWAP64 || sym == YY___BUILTIN_POPCOUNT || sym == YY___BUILTIN_POPCOUNTL || sym == YY___BUILTIN_POPCOUNTLL || sym == YY___BUILTIN_CLZ || sym == YY___BUILTIN_CLZL || sym == YY___BUILTIN_CLZLL || sym == YY___BUILTIN_CTZ || sym == YY___BUILTIN_CTZL || sym == YY___BUILTIN_CTZLL || sym == YY___BUILTIN_FFS || sym == YY___BUILTIN_FFSL || sym == YY___BUILTIN_FFSLL || sym == YY___BUILTIN_MEMCPY || sym == YY___BUILTIN_MEMSET || sym == YY___BUILTIN_EXPECT || sym == YY___BUILTIN_PREFETCH || sym == YY___BUILTIN_UNREACHABLE || sym == YY___BUILTIN_HUGE_VAL || sym == YY___BUILTIN_HUGE_VALF || sym == YY___BUILTIN_INF || sym == YY___BUILTIN_INFF || sym == YY___BUILTIN_ISUNORDERED || sym == YY___BUILTIN_NAN || sym == YY___BUILTIN_NANF || sym == YY___BUILTIN_ADD_OVERFLOW || sym == YY___BUILTIN_ADD_OVERFLOW_P || sym == YY___BUILTIN_SADD_OVERFLOW || sym == YY___BUILTIN_SADDL_OVERFLOW || sym == YY___BUILTIN_SADDLL_OVERFLOW || sym == YY___BUILTIN_UADD_OVERFLOW || sym == YY___BUILTIN_UADDL_OVERFLOW || sym == YY___BUILTIN_UADDLL_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW_P || sym == YY___BUILTIN_SSUB_OVERFLOW || sym == YY___BUILTIN_SSUBL_OVERFLOW || sym == YY___BUILTIN_SSUBLL_OVERFLOW || sym == YY___BUILTIN_USUB_OVERFLOW || sym == YY___BUILTIN_USUBL_OVERFLOW || sym == YY___BUILTIN_USUBLL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW_P || sym == YY___BUILTIN_SMUL_OVERFLOW || sym == YY___BUILTIN_SMULL_OVERFLOW || sym == YY___BUILTIN_SMULLL_OVERFLOW || sym == YY___BUILTIN_UMUL_OVERFLOW || sym == YY___BUILTIN_UMULL_OVERFLOW || sym == YY___BUILTIN_UMULLL_OVERFLOW || sym == YY___BUILTIN_CONSTANT_P || sym == YY___BUILTIN_VA_ARG || sym == YY__SEMICOLON) && (!C_IS_ID(sym) || !is_typedef_name(rcc, sym))) { - if (sym == YY__LPAREN || C_IS_ID(sym) || sym == YY_DECIMAL_NUMBER || sym == YY_OCTAL_NUMBER || sym == YY_HEXADECIMAL_NUMBER || sym == YY_BINARY_NUMBER || sym == YY_FLOATING_NUMBER || sym == YY_HEXADECIMAL_FLOATING_NUMBER || sym == YY_CHARACTER || sym == YY_STRING || sym == YY__GENERIC || sym == YY___EXTENSION__ || sym == YY__PLUS_PLUS || sym == YY__MINUS_MINUS || sym == YY__AND || sym == YY__STAR || sym == YY__PLUS || sym == YY__MINUS || sym == YY__TILDE || sym == YY__BANG || sym == YY_SIZEOF || sym == YY__ALIGNOF || sym == YY___ALIGNOF__ || sym == YY___ALIGNOF || sym == YY__AND_AND || sym == YY___BUILTIN_VA_START || sym == YY___BUILTIN_VA_END || sym == YY___BUILTIN_VA_COPY || sym == YY___BUILTIN_ALLOCA || sym == YY___BUILTIN_ABORT || sym == YY___BUILTIN_TRAP || sym == YY___BUILTIN_DEBUGTRAP || sym == YY___BUILTIN_FRAME_ADDRESS || sym == YY___BUILTIN_ABS || sym == YY___BUILTIN_LABS || sym == YY___BUILTIN_LLABS || sym == YY___BUILTIN_FABS || sym == YY___BUILTIN_FABSF || sym == YY___BUILTIN_BSWAP16 || sym == YY___BUILTIN_BSWAP32 || sym == YY___BUILTIN_BSWAP64 || sym == YY___BUILTIN_POPCOUNT || sym == YY___BUILTIN_POPCOUNTL || sym == YY___BUILTIN_POPCOUNTLL || sym == YY___BUILTIN_CLZ || sym == YY___BUILTIN_CLZL || sym == YY___BUILTIN_CLZLL || sym == YY___BUILTIN_CTZ || sym == YY___BUILTIN_CTZL || sym == YY___BUILTIN_CTZLL || sym == YY___BUILTIN_FFS || sym == YY___BUILTIN_FFSL || sym == YY___BUILTIN_FFSLL || sym == YY___BUILTIN_MEMCPY || sym == YY___BUILTIN_MEMSET || sym == YY___BUILTIN_EXPECT || sym == YY___BUILTIN_PREFETCH || sym == YY___BUILTIN_UNREACHABLE || sym == YY___BUILTIN_HUGE_VAL || sym == YY___BUILTIN_HUGE_VALF || sym == YY___BUILTIN_INF || sym == YY___BUILTIN_INFF || sym == YY___BUILTIN_ISUNORDERED || sym == YY___BUILTIN_NAN || sym == YY___BUILTIN_NANF || sym == YY___BUILTIN_ADD_OVERFLOW || sym == YY___BUILTIN_ADD_OVERFLOW_P || sym == YY___BUILTIN_SADD_OVERFLOW || sym == YY___BUILTIN_SADDL_OVERFLOW || sym == YY___BUILTIN_SADDLL_OVERFLOW || sym == YY___BUILTIN_UADD_OVERFLOW || sym == YY___BUILTIN_UADDL_OVERFLOW || sym == YY___BUILTIN_UADDLL_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW_P || sym == YY___BUILTIN_SSUB_OVERFLOW || sym == YY___BUILTIN_SSUBL_OVERFLOW || sym == YY___BUILTIN_SSUBLL_OVERFLOW || sym == YY___BUILTIN_USUB_OVERFLOW || sym == YY___BUILTIN_USUBL_OVERFLOW || sym == YY___BUILTIN_USUBLL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW_P || sym == YY___BUILTIN_SMUL_OVERFLOW || sym == YY___BUILTIN_SMULL_OVERFLOW || sym == YY___BUILTIN_SMULLL_OVERFLOW || sym == YY___BUILTIN_UMUL_OVERFLOW || sym == YY___BUILTIN_UMULL_OVERFLOW || sym == YY___BUILTIN_UMULLL_OVERFLOW || sym == YY___BUILTIN_CONSTANT_P || sym == YY___BUILTIN_VA_ARG) { + if ((sym == YY__LPAREN || C_IS_ID(sym) || sym == YY_DECIMAL_NUMBER || sym == YY_OCTAL_NUMBER || sym == YY_HEXADECIMAL_NUMBER || sym == YY_BINARY_NUMBER || sym == YY_FLOATING_NUMBER || sym == YY_HEXADECIMAL_FLOATING_NUMBER || sym == YY_CHARACTER || sym == YY_STRING || sym == YY__GENERIC || sym == YY___EXTENSION__ || sym == YY__PLUS_PLUS || sym == YY__MINUS_MINUS || sym == YY__AND || sym == YY__STAR || sym == YY__PLUS || sym == YY__MINUS || sym == YY__TILDE || sym == YY__BANG || sym == YY_SIZEOF || sym == YY__ALIGNOF || sym == YY___ALIGNOF__ || sym == YY___ALIGNOF || sym == YY__AND_AND || sym == YY___BUILTIN_VA_START || sym == YY___BUILTIN_VA_END || sym == YY___BUILTIN_VA_COPY || sym == YY___BUILTIN_ALLOCA || sym == YY___BUILTIN_ABORT || sym == YY___BUILTIN_TRAP || sym == YY___BUILTIN_DEBUGTRAP || sym == YY___BUILTIN_FRAME_ADDRESS || sym == YY___BUILTIN_ABS || sym == YY___BUILTIN_LABS || sym == YY___BUILTIN_LLABS || sym == YY___BUILTIN_FABS || sym == YY___BUILTIN_FABSF || sym == YY___BUILTIN_BSWAP16 || sym == YY___BUILTIN_BSWAP32 || sym == YY___BUILTIN_BSWAP64 || sym == YY___BUILTIN_POPCOUNT || sym == YY___BUILTIN_POPCOUNTL || sym == YY___BUILTIN_POPCOUNTLL || sym == YY___BUILTIN_CLZ || sym == YY___BUILTIN_CLZL || sym == YY___BUILTIN_CLZLL || sym == YY___BUILTIN_CTZ || sym == YY___BUILTIN_CTZL || sym == YY___BUILTIN_CTZLL || sym == YY___BUILTIN_FFS || sym == YY___BUILTIN_FFSL || sym == YY___BUILTIN_FFSLL || sym == YY___BUILTIN_MEMCPY || sym == YY___BUILTIN_MEMSET || sym == YY___BUILTIN_EXPECT || sym == YY___BUILTIN_PREFETCH || sym == YY___BUILTIN_UNREACHABLE || sym == YY___BUILTIN_HUGE_VAL || sym == YY___BUILTIN_HUGE_VALF || sym == YY___BUILTIN_INF || sym == YY___BUILTIN_INFF || sym == YY___BUILTIN_ISUNORDERED || sym == YY___BUILTIN_NAN || sym == YY___BUILTIN_NANF || sym == YY___BUILTIN_ADD_OVERFLOW || sym == YY___BUILTIN_ADD_OVERFLOW_P || sym == YY___BUILTIN_SADD_OVERFLOW || sym == YY___BUILTIN_SADDL_OVERFLOW || sym == YY___BUILTIN_SADDLL_OVERFLOW || sym == YY___BUILTIN_UADD_OVERFLOW || sym == YY___BUILTIN_UADDL_OVERFLOW || sym == YY___BUILTIN_UADDLL_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW_P || sym == YY___BUILTIN_SSUB_OVERFLOW || sym == YY___BUILTIN_SSUBL_OVERFLOW || sym == YY___BUILTIN_SSUBLL_OVERFLOW || sym == YY___BUILTIN_USUB_OVERFLOW || sym == YY___BUILTIN_USUBL_OVERFLOW || sym == YY___BUILTIN_USUBLL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW_P || sym == YY___BUILTIN_SMUL_OVERFLOW || sym == YY___BUILTIN_SMULL_OVERFLOW || sym == YY___BUILTIN_SMULLL_OVERFLOW || sym == YY___BUILTIN_UMUL_OVERFLOW || sym == YY___BUILTIN_UMULL_OVERFLOW || sym == YY___BUILTIN_UMULLL_OVERFLOW || sym == YY___BUILTIN_SHUFFLE || sym == YY___BUILTIN_SHUFFLEVECTOR || sym == YY___BUILTIN_CONSTANT_P || sym == YY___BUILTIN_VA_ARG || sym == YY___BUILTIN_CONVERTVECTOR || sym == YY__SEMICOLON) && (!C_IS_ID(sym) || !is_typedef_name(rcc, sym))) { + if (sym == YY__LPAREN || C_IS_ID(sym) || sym == YY_DECIMAL_NUMBER || sym == YY_OCTAL_NUMBER || sym == YY_HEXADECIMAL_NUMBER || sym == YY_BINARY_NUMBER || sym == YY_FLOATING_NUMBER || sym == YY_HEXADECIMAL_FLOATING_NUMBER || sym == YY_CHARACTER || sym == YY_STRING || sym == YY__GENERIC || sym == YY___EXTENSION__ || sym == YY__PLUS_PLUS || sym == YY__MINUS_MINUS || sym == YY__AND || sym == YY__STAR || sym == YY__PLUS || sym == YY__MINUS || sym == YY__TILDE || sym == YY__BANG || sym == YY_SIZEOF || sym == YY__ALIGNOF || sym == YY___ALIGNOF__ || sym == YY___ALIGNOF || sym == YY__AND_AND || sym == YY___BUILTIN_VA_START || sym == YY___BUILTIN_VA_END || sym == YY___BUILTIN_VA_COPY || sym == YY___BUILTIN_ALLOCA || sym == YY___BUILTIN_ABORT || sym == YY___BUILTIN_TRAP || sym == YY___BUILTIN_DEBUGTRAP || sym == YY___BUILTIN_FRAME_ADDRESS || sym == YY___BUILTIN_ABS || sym == YY___BUILTIN_LABS || sym == YY___BUILTIN_LLABS || sym == YY___BUILTIN_FABS || sym == YY___BUILTIN_FABSF || sym == YY___BUILTIN_BSWAP16 || sym == YY___BUILTIN_BSWAP32 || sym == YY___BUILTIN_BSWAP64 || sym == YY___BUILTIN_POPCOUNT || sym == YY___BUILTIN_POPCOUNTL || sym == YY___BUILTIN_POPCOUNTLL || sym == YY___BUILTIN_CLZ || sym == YY___BUILTIN_CLZL || sym == YY___BUILTIN_CLZLL || sym == YY___BUILTIN_CTZ || sym == YY___BUILTIN_CTZL || sym == YY___BUILTIN_CTZLL || sym == YY___BUILTIN_FFS || sym == YY___BUILTIN_FFSL || sym == YY___BUILTIN_FFSLL || sym == YY___BUILTIN_MEMCPY || sym == YY___BUILTIN_MEMSET || sym == YY___BUILTIN_EXPECT || sym == YY___BUILTIN_PREFETCH || sym == YY___BUILTIN_UNREACHABLE || sym == YY___BUILTIN_HUGE_VAL || sym == YY___BUILTIN_HUGE_VALF || sym == YY___BUILTIN_INF || sym == YY___BUILTIN_INFF || sym == YY___BUILTIN_ISUNORDERED || sym == YY___BUILTIN_NAN || sym == YY___BUILTIN_NANF || sym == YY___BUILTIN_ADD_OVERFLOW || sym == YY___BUILTIN_ADD_OVERFLOW_P || sym == YY___BUILTIN_SADD_OVERFLOW || sym == YY___BUILTIN_SADDL_OVERFLOW || sym == YY___BUILTIN_SADDLL_OVERFLOW || sym == YY___BUILTIN_UADD_OVERFLOW || sym == YY___BUILTIN_UADDL_OVERFLOW || sym == YY___BUILTIN_UADDLL_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW_P || sym == YY___BUILTIN_SSUB_OVERFLOW || sym == YY___BUILTIN_SSUBL_OVERFLOW || sym == YY___BUILTIN_SSUBLL_OVERFLOW || sym == YY___BUILTIN_USUB_OVERFLOW || sym == YY___BUILTIN_USUBL_OVERFLOW || sym == YY___BUILTIN_USUBLL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW_P || sym == YY___BUILTIN_SMUL_OVERFLOW || sym == YY___BUILTIN_SMULL_OVERFLOW || sym == YY___BUILTIN_SMULLL_OVERFLOW || sym == YY___BUILTIN_UMUL_OVERFLOW || sym == YY___BUILTIN_UMULL_OVERFLOW || sym == YY___BUILTIN_UMULLL_OVERFLOW || sym == YY___BUILTIN_SHUFFLE || sym == YY___BUILTIN_SHUFFLEVECTOR || sym == YY___BUILTIN_CONSTANT_P || sym == YY___BUILTIN_VA_ARG || sym == YY___BUILTIN_CONVERTVECTOR) { sym = parse_expression(sym, rcc, &val); } if (sym != YY__SEMICOLON) { @@ -1904,7 +1904,7 @@ static yy_sym parse_c_statement(yy_sym sym, rcc_ctx *rcc) { yy_error_sym("unexpected", sym); } c_do_loop_start(rcc, &loop); - if (sym == YY__LPAREN || C_IS_ID(sym) || sym == YY_DECIMAL_NUMBER || sym == YY_OCTAL_NUMBER || sym == YY_HEXADECIMAL_NUMBER || sym == YY_BINARY_NUMBER || sym == YY_FLOATING_NUMBER || sym == YY_HEXADECIMAL_FLOATING_NUMBER || sym == YY_CHARACTER || sym == YY_STRING || sym == YY__GENERIC || sym == YY___EXTENSION__ || sym == YY__PLUS_PLUS || sym == YY__MINUS_MINUS || sym == YY__AND || sym == YY__STAR || sym == YY__PLUS || sym == YY__MINUS || sym == YY__TILDE || sym == YY__BANG || sym == YY_SIZEOF || sym == YY__ALIGNOF || sym == YY___ALIGNOF__ || sym == YY___ALIGNOF || sym == YY__AND_AND || sym == YY___BUILTIN_VA_START || sym == YY___BUILTIN_VA_END || sym == YY___BUILTIN_VA_COPY || sym == YY___BUILTIN_ALLOCA || sym == YY___BUILTIN_ABORT || sym == YY___BUILTIN_TRAP || sym == YY___BUILTIN_DEBUGTRAP || sym == YY___BUILTIN_FRAME_ADDRESS || sym == YY___BUILTIN_ABS || sym == YY___BUILTIN_LABS || sym == YY___BUILTIN_LLABS || sym == YY___BUILTIN_FABS || sym == YY___BUILTIN_FABSF || sym == YY___BUILTIN_BSWAP16 || sym == YY___BUILTIN_BSWAP32 || sym == YY___BUILTIN_BSWAP64 || sym == YY___BUILTIN_POPCOUNT || sym == YY___BUILTIN_POPCOUNTL || sym == YY___BUILTIN_POPCOUNTLL || sym == YY___BUILTIN_CLZ || sym == YY___BUILTIN_CLZL || sym == YY___BUILTIN_CLZLL || sym == YY___BUILTIN_CTZ || sym == YY___BUILTIN_CTZL || sym == YY___BUILTIN_CTZLL || sym == YY___BUILTIN_FFS || sym == YY___BUILTIN_FFSL || sym == YY___BUILTIN_FFSLL || sym == YY___BUILTIN_MEMCPY || sym == YY___BUILTIN_MEMSET || sym == YY___BUILTIN_EXPECT || sym == YY___BUILTIN_PREFETCH || sym == YY___BUILTIN_UNREACHABLE || sym == YY___BUILTIN_HUGE_VAL || sym == YY___BUILTIN_HUGE_VALF || sym == YY___BUILTIN_INF || sym == YY___BUILTIN_INFF || sym == YY___BUILTIN_ISUNORDERED || sym == YY___BUILTIN_NAN || sym == YY___BUILTIN_NANF || sym == YY___BUILTIN_ADD_OVERFLOW || sym == YY___BUILTIN_ADD_OVERFLOW_P || sym == YY___BUILTIN_SADD_OVERFLOW || sym == YY___BUILTIN_SADDL_OVERFLOW || sym == YY___BUILTIN_SADDLL_OVERFLOW || sym == YY___BUILTIN_UADD_OVERFLOW || sym == YY___BUILTIN_UADDL_OVERFLOW || sym == YY___BUILTIN_UADDLL_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW_P || sym == YY___BUILTIN_SSUB_OVERFLOW || sym == YY___BUILTIN_SSUBL_OVERFLOW || sym == YY___BUILTIN_SSUBLL_OVERFLOW || sym == YY___BUILTIN_USUB_OVERFLOW || sym == YY___BUILTIN_USUBL_OVERFLOW || sym == YY___BUILTIN_USUBLL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW_P || sym == YY___BUILTIN_SMUL_OVERFLOW || sym == YY___BUILTIN_SMULL_OVERFLOW || sym == YY___BUILTIN_SMULLL_OVERFLOW || sym == YY___BUILTIN_UMUL_OVERFLOW || sym == YY___BUILTIN_UMULL_OVERFLOW || sym == YY___BUILTIN_UMULLL_OVERFLOW || sym == YY___BUILTIN_CONSTANT_P || sym == YY___BUILTIN_VA_ARG) { + if (sym == YY__LPAREN || C_IS_ID(sym) || sym == YY_DECIMAL_NUMBER || sym == YY_OCTAL_NUMBER || sym == YY_HEXADECIMAL_NUMBER || sym == YY_BINARY_NUMBER || sym == YY_FLOATING_NUMBER || sym == YY_HEXADECIMAL_FLOATING_NUMBER || sym == YY_CHARACTER || sym == YY_STRING || sym == YY__GENERIC || sym == YY___EXTENSION__ || sym == YY__PLUS_PLUS || sym == YY__MINUS_MINUS || sym == YY__AND || sym == YY__STAR || sym == YY__PLUS || sym == YY__MINUS || sym == YY__TILDE || sym == YY__BANG || sym == YY_SIZEOF || sym == YY__ALIGNOF || sym == YY___ALIGNOF__ || sym == YY___ALIGNOF || sym == YY__AND_AND || sym == YY___BUILTIN_VA_START || sym == YY___BUILTIN_VA_END || sym == YY___BUILTIN_VA_COPY || sym == YY___BUILTIN_ALLOCA || sym == YY___BUILTIN_ABORT || sym == YY___BUILTIN_TRAP || sym == YY___BUILTIN_DEBUGTRAP || sym == YY___BUILTIN_FRAME_ADDRESS || sym == YY___BUILTIN_ABS || sym == YY___BUILTIN_LABS || sym == YY___BUILTIN_LLABS || sym == YY___BUILTIN_FABS || sym == YY___BUILTIN_FABSF || sym == YY___BUILTIN_BSWAP16 || sym == YY___BUILTIN_BSWAP32 || sym == YY___BUILTIN_BSWAP64 || sym == YY___BUILTIN_POPCOUNT || sym == YY___BUILTIN_POPCOUNTL || sym == YY___BUILTIN_POPCOUNTLL || sym == YY___BUILTIN_CLZ || sym == YY___BUILTIN_CLZL || sym == YY___BUILTIN_CLZLL || sym == YY___BUILTIN_CTZ || sym == YY___BUILTIN_CTZL || sym == YY___BUILTIN_CTZLL || sym == YY___BUILTIN_FFS || sym == YY___BUILTIN_FFSL || sym == YY___BUILTIN_FFSLL || sym == YY___BUILTIN_MEMCPY || sym == YY___BUILTIN_MEMSET || sym == YY___BUILTIN_EXPECT || sym == YY___BUILTIN_PREFETCH || sym == YY___BUILTIN_UNREACHABLE || sym == YY___BUILTIN_HUGE_VAL || sym == YY___BUILTIN_HUGE_VALF || sym == YY___BUILTIN_INF || sym == YY___BUILTIN_INFF || sym == YY___BUILTIN_ISUNORDERED || sym == YY___BUILTIN_NAN || sym == YY___BUILTIN_NANF || sym == YY___BUILTIN_ADD_OVERFLOW || sym == YY___BUILTIN_ADD_OVERFLOW_P || sym == YY___BUILTIN_SADD_OVERFLOW || sym == YY___BUILTIN_SADDL_OVERFLOW || sym == YY___BUILTIN_SADDLL_OVERFLOW || sym == YY___BUILTIN_UADD_OVERFLOW || sym == YY___BUILTIN_UADDL_OVERFLOW || sym == YY___BUILTIN_UADDLL_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW_P || sym == YY___BUILTIN_SSUB_OVERFLOW || sym == YY___BUILTIN_SSUBL_OVERFLOW || sym == YY___BUILTIN_SSUBLL_OVERFLOW || sym == YY___BUILTIN_USUB_OVERFLOW || sym == YY___BUILTIN_USUBL_OVERFLOW || sym == YY___BUILTIN_USUBLL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW_P || sym == YY___BUILTIN_SMUL_OVERFLOW || sym == YY___BUILTIN_SMULL_OVERFLOW || sym == YY___BUILTIN_SMULLL_OVERFLOW || sym == YY___BUILTIN_UMUL_OVERFLOW || sym == YY___BUILTIN_UMULL_OVERFLOW || sym == YY___BUILTIN_UMULLL_OVERFLOW || sym == YY___BUILTIN_SHUFFLE || sym == YY___BUILTIN_SHUFFLEVECTOR || sym == YY___BUILTIN_CONSTANT_P || sym == YY___BUILTIN_VA_ARG || sym == YY___BUILTIN_CONVERTVECTOR) { sym = parse_expression(sym, rcc, &val); c_do_loop_check(rcc, &loop, &val); } @@ -1912,7 +1912,7 @@ static yy_sym parse_c_statement(yy_sym sym, rcc_ctx *rcc) { yy_error_sym("';' expected, got", sym); } sym = get_sym(); - if (sym == YY__LPAREN || C_IS_ID(sym) || sym == YY_DECIMAL_NUMBER || sym == YY_OCTAL_NUMBER || sym == YY_HEXADECIMAL_NUMBER || sym == YY_BINARY_NUMBER || sym == YY_FLOATING_NUMBER || sym == YY_HEXADECIMAL_FLOATING_NUMBER || sym == YY_CHARACTER || sym == YY_STRING || sym == YY__GENERIC || sym == YY___EXTENSION__ || sym == YY__PLUS_PLUS || sym == YY__MINUS_MINUS || sym == YY__AND || sym == YY__STAR || sym == YY__PLUS || sym == YY__MINUS || sym == YY__TILDE || sym == YY__BANG || sym == YY_SIZEOF || sym == YY__ALIGNOF || sym == YY___ALIGNOF__ || sym == YY___ALIGNOF || sym == YY__AND_AND || sym == YY___BUILTIN_VA_START || sym == YY___BUILTIN_VA_END || sym == YY___BUILTIN_VA_COPY || sym == YY___BUILTIN_ALLOCA || sym == YY___BUILTIN_ABORT || sym == YY___BUILTIN_TRAP || sym == YY___BUILTIN_DEBUGTRAP || sym == YY___BUILTIN_FRAME_ADDRESS || sym == YY___BUILTIN_ABS || sym == YY___BUILTIN_LABS || sym == YY___BUILTIN_LLABS || sym == YY___BUILTIN_FABS || sym == YY___BUILTIN_FABSF || sym == YY___BUILTIN_BSWAP16 || sym == YY___BUILTIN_BSWAP32 || sym == YY___BUILTIN_BSWAP64 || sym == YY___BUILTIN_POPCOUNT || sym == YY___BUILTIN_POPCOUNTL || sym == YY___BUILTIN_POPCOUNTLL || sym == YY___BUILTIN_CLZ || sym == YY___BUILTIN_CLZL || sym == YY___BUILTIN_CLZLL || sym == YY___BUILTIN_CTZ || sym == YY___BUILTIN_CTZL || sym == YY___BUILTIN_CTZLL || sym == YY___BUILTIN_FFS || sym == YY___BUILTIN_FFSL || sym == YY___BUILTIN_FFSLL || sym == YY___BUILTIN_MEMCPY || sym == YY___BUILTIN_MEMSET || sym == YY___BUILTIN_EXPECT || sym == YY___BUILTIN_PREFETCH || sym == YY___BUILTIN_UNREACHABLE || sym == YY___BUILTIN_HUGE_VAL || sym == YY___BUILTIN_HUGE_VALF || sym == YY___BUILTIN_INF || sym == YY___BUILTIN_INFF || sym == YY___BUILTIN_ISUNORDERED || sym == YY___BUILTIN_NAN || sym == YY___BUILTIN_NANF || sym == YY___BUILTIN_ADD_OVERFLOW || sym == YY___BUILTIN_ADD_OVERFLOW_P || sym == YY___BUILTIN_SADD_OVERFLOW || sym == YY___BUILTIN_SADDL_OVERFLOW || sym == YY___BUILTIN_SADDLL_OVERFLOW || sym == YY___BUILTIN_UADD_OVERFLOW || sym == YY___BUILTIN_UADDL_OVERFLOW || sym == YY___BUILTIN_UADDLL_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW_P || sym == YY___BUILTIN_SSUB_OVERFLOW || sym == YY___BUILTIN_SSUBL_OVERFLOW || sym == YY___BUILTIN_SSUBLL_OVERFLOW || sym == YY___BUILTIN_USUB_OVERFLOW || sym == YY___BUILTIN_USUBL_OVERFLOW || sym == YY___BUILTIN_USUBLL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW_P || sym == YY___BUILTIN_SMUL_OVERFLOW || sym == YY___BUILTIN_SMULL_OVERFLOW || sym == YY___BUILTIN_SMULLL_OVERFLOW || sym == YY___BUILTIN_UMUL_OVERFLOW || sym == YY___BUILTIN_UMULL_OVERFLOW || sym == YY___BUILTIN_UMULLL_OVERFLOW || sym == YY___BUILTIN_CONSTANT_P || sym == YY___BUILTIN_VA_ARG) { + if (sym == YY__LPAREN || C_IS_ID(sym) || sym == YY_DECIMAL_NUMBER || sym == YY_OCTAL_NUMBER || sym == YY_HEXADECIMAL_NUMBER || sym == YY_BINARY_NUMBER || sym == YY_FLOATING_NUMBER || sym == YY_HEXADECIMAL_FLOATING_NUMBER || sym == YY_CHARACTER || sym == YY_STRING || sym == YY__GENERIC || sym == YY___EXTENSION__ || sym == YY__PLUS_PLUS || sym == YY__MINUS_MINUS || sym == YY__AND || sym == YY__STAR || sym == YY__PLUS || sym == YY__MINUS || sym == YY__TILDE || sym == YY__BANG || sym == YY_SIZEOF || sym == YY__ALIGNOF || sym == YY___ALIGNOF__ || sym == YY___ALIGNOF || sym == YY__AND_AND || sym == YY___BUILTIN_VA_START || sym == YY___BUILTIN_VA_END || sym == YY___BUILTIN_VA_COPY || sym == YY___BUILTIN_ALLOCA || sym == YY___BUILTIN_ABORT || sym == YY___BUILTIN_TRAP || sym == YY___BUILTIN_DEBUGTRAP || sym == YY___BUILTIN_FRAME_ADDRESS || sym == YY___BUILTIN_ABS || sym == YY___BUILTIN_LABS || sym == YY___BUILTIN_LLABS || sym == YY___BUILTIN_FABS || sym == YY___BUILTIN_FABSF || sym == YY___BUILTIN_BSWAP16 || sym == YY___BUILTIN_BSWAP32 || sym == YY___BUILTIN_BSWAP64 || sym == YY___BUILTIN_POPCOUNT || sym == YY___BUILTIN_POPCOUNTL || sym == YY___BUILTIN_POPCOUNTLL || sym == YY___BUILTIN_CLZ || sym == YY___BUILTIN_CLZL || sym == YY___BUILTIN_CLZLL || sym == YY___BUILTIN_CTZ || sym == YY___BUILTIN_CTZL || sym == YY___BUILTIN_CTZLL || sym == YY___BUILTIN_FFS || sym == YY___BUILTIN_FFSL || sym == YY___BUILTIN_FFSLL || sym == YY___BUILTIN_MEMCPY || sym == YY___BUILTIN_MEMSET || sym == YY___BUILTIN_EXPECT || sym == YY___BUILTIN_PREFETCH || sym == YY___BUILTIN_UNREACHABLE || sym == YY___BUILTIN_HUGE_VAL || sym == YY___BUILTIN_HUGE_VALF || sym == YY___BUILTIN_INF || sym == YY___BUILTIN_INFF || sym == YY___BUILTIN_ISUNORDERED || sym == YY___BUILTIN_NAN || sym == YY___BUILTIN_NANF || sym == YY___BUILTIN_ADD_OVERFLOW || sym == YY___BUILTIN_ADD_OVERFLOW_P || sym == YY___BUILTIN_SADD_OVERFLOW || sym == YY___BUILTIN_SADDL_OVERFLOW || sym == YY___BUILTIN_SADDLL_OVERFLOW || sym == YY___BUILTIN_UADD_OVERFLOW || sym == YY___BUILTIN_UADDL_OVERFLOW || sym == YY___BUILTIN_UADDLL_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW_P || sym == YY___BUILTIN_SSUB_OVERFLOW || sym == YY___BUILTIN_SSUBL_OVERFLOW || sym == YY___BUILTIN_SSUBLL_OVERFLOW || sym == YY___BUILTIN_USUB_OVERFLOW || sym == YY___BUILTIN_USUBL_OVERFLOW || sym == YY___BUILTIN_USUBLL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW_P || sym == YY___BUILTIN_SMUL_OVERFLOW || sym == YY___BUILTIN_SMULL_OVERFLOW || sym == YY___BUILTIN_SMULLL_OVERFLOW || sym == YY___BUILTIN_UMUL_OVERFLOW || sym == YY___BUILTIN_UMULL_OVERFLOW || sym == YY___BUILTIN_UMULLL_OVERFLOW || sym == YY___BUILTIN_SHUFFLE || sym == YY___BUILTIN_SHUFFLEVECTOR || sym == YY___BUILTIN_CONSTANT_P || sym == YY___BUILTIN_VA_ARG || sym == YY___BUILTIN_CONVERTVECTOR) { c_do_for_next_start(rcc, &loop); sym = parse_expression(sym, rcc, &val); c_do_for_next_end(rcc, &loop); @@ -1956,7 +1956,7 @@ static yy_sym parse_c_statement(yy_sym sym, rcc_ctx *rcc) { c_do_break(rcc); } else if (sym == YY_RETURN) { sym = get_sym(); - if (sym == YY__LPAREN || C_IS_ID(sym) || sym == YY_DECIMAL_NUMBER || sym == YY_OCTAL_NUMBER || sym == YY_HEXADECIMAL_NUMBER || sym == YY_BINARY_NUMBER || sym == YY_FLOATING_NUMBER || sym == YY_HEXADECIMAL_FLOATING_NUMBER || sym == YY_CHARACTER || sym == YY_STRING || sym == YY__GENERIC || sym == YY___EXTENSION__ || sym == YY__PLUS_PLUS || sym == YY__MINUS_MINUS || sym == YY__AND || sym == YY__STAR || sym == YY__PLUS || sym == YY__MINUS || sym == YY__TILDE || sym == YY__BANG || sym == YY_SIZEOF || sym == YY__ALIGNOF || sym == YY___ALIGNOF__ || sym == YY___ALIGNOF || sym == YY__AND_AND || sym == YY___BUILTIN_VA_START || sym == YY___BUILTIN_VA_END || sym == YY___BUILTIN_VA_COPY || sym == YY___BUILTIN_ALLOCA || sym == YY___BUILTIN_ABORT || sym == YY___BUILTIN_TRAP || sym == YY___BUILTIN_DEBUGTRAP || sym == YY___BUILTIN_FRAME_ADDRESS || sym == YY___BUILTIN_ABS || sym == YY___BUILTIN_LABS || sym == YY___BUILTIN_LLABS || sym == YY___BUILTIN_FABS || sym == YY___BUILTIN_FABSF || sym == YY___BUILTIN_BSWAP16 || sym == YY___BUILTIN_BSWAP32 || sym == YY___BUILTIN_BSWAP64 || sym == YY___BUILTIN_POPCOUNT || sym == YY___BUILTIN_POPCOUNTL || sym == YY___BUILTIN_POPCOUNTLL || sym == YY___BUILTIN_CLZ || sym == YY___BUILTIN_CLZL || sym == YY___BUILTIN_CLZLL || sym == YY___BUILTIN_CTZ || sym == YY___BUILTIN_CTZL || sym == YY___BUILTIN_CTZLL || sym == YY___BUILTIN_FFS || sym == YY___BUILTIN_FFSL || sym == YY___BUILTIN_FFSLL || sym == YY___BUILTIN_MEMCPY || sym == YY___BUILTIN_MEMSET || sym == YY___BUILTIN_EXPECT || sym == YY___BUILTIN_PREFETCH || sym == YY___BUILTIN_UNREACHABLE || sym == YY___BUILTIN_HUGE_VAL || sym == YY___BUILTIN_HUGE_VALF || sym == YY___BUILTIN_INF || sym == YY___BUILTIN_INFF || sym == YY___BUILTIN_ISUNORDERED || sym == YY___BUILTIN_NAN || sym == YY___BUILTIN_NANF || sym == YY___BUILTIN_ADD_OVERFLOW || sym == YY___BUILTIN_ADD_OVERFLOW_P || sym == YY___BUILTIN_SADD_OVERFLOW || sym == YY___BUILTIN_SADDL_OVERFLOW || sym == YY___BUILTIN_SADDLL_OVERFLOW || sym == YY___BUILTIN_UADD_OVERFLOW || sym == YY___BUILTIN_UADDL_OVERFLOW || sym == YY___BUILTIN_UADDLL_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW_P || sym == YY___BUILTIN_SSUB_OVERFLOW || sym == YY___BUILTIN_SSUBL_OVERFLOW || sym == YY___BUILTIN_SSUBLL_OVERFLOW || sym == YY___BUILTIN_USUB_OVERFLOW || sym == YY___BUILTIN_USUBL_OVERFLOW || sym == YY___BUILTIN_USUBLL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW_P || sym == YY___BUILTIN_SMUL_OVERFLOW || sym == YY___BUILTIN_SMULL_OVERFLOW || sym == YY___BUILTIN_SMULLL_OVERFLOW || sym == YY___BUILTIN_UMUL_OVERFLOW || sym == YY___BUILTIN_UMULL_OVERFLOW || sym == YY___BUILTIN_UMULLL_OVERFLOW || sym == YY___BUILTIN_CONSTANT_P || sym == YY___BUILTIN_VA_ARG) { + if (sym == YY__LPAREN || C_IS_ID(sym) || sym == YY_DECIMAL_NUMBER || sym == YY_OCTAL_NUMBER || sym == YY_HEXADECIMAL_NUMBER || sym == YY_BINARY_NUMBER || sym == YY_FLOATING_NUMBER || sym == YY_HEXADECIMAL_FLOATING_NUMBER || sym == YY_CHARACTER || sym == YY_STRING || sym == YY__GENERIC || sym == YY___EXTENSION__ || sym == YY__PLUS_PLUS || sym == YY__MINUS_MINUS || sym == YY__AND || sym == YY__STAR || sym == YY__PLUS || sym == YY__MINUS || sym == YY__TILDE || sym == YY__BANG || sym == YY_SIZEOF || sym == YY__ALIGNOF || sym == YY___ALIGNOF__ || sym == YY___ALIGNOF || sym == YY__AND_AND || sym == YY___BUILTIN_VA_START || sym == YY___BUILTIN_VA_END || sym == YY___BUILTIN_VA_COPY || sym == YY___BUILTIN_ALLOCA || sym == YY___BUILTIN_ABORT || sym == YY___BUILTIN_TRAP || sym == YY___BUILTIN_DEBUGTRAP || sym == YY___BUILTIN_FRAME_ADDRESS || sym == YY___BUILTIN_ABS || sym == YY___BUILTIN_LABS || sym == YY___BUILTIN_LLABS || sym == YY___BUILTIN_FABS || sym == YY___BUILTIN_FABSF || sym == YY___BUILTIN_BSWAP16 || sym == YY___BUILTIN_BSWAP32 || sym == YY___BUILTIN_BSWAP64 || sym == YY___BUILTIN_POPCOUNT || sym == YY___BUILTIN_POPCOUNTL || sym == YY___BUILTIN_POPCOUNTLL || sym == YY___BUILTIN_CLZ || sym == YY___BUILTIN_CLZL || sym == YY___BUILTIN_CLZLL || sym == YY___BUILTIN_CTZ || sym == YY___BUILTIN_CTZL || sym == YY___BUILTIN_CTZLL || sym == YY___BUILTIN_FFS || sym == YY___BUILTIN_FFSL || sym == YY___BUILTIN_FFSLL || sym == YY___BUILTIN_MEMCPY || sym == YY___BUILTIN_MEMSET || sym == YY___BUILTIN_EXPECT || sym == YY___BUILTIN_PREFETCH || sym == YY___BUILTIN_UNREACHABLE || sym == YY___BUILTIN_HUGE_VAL || sym == YY___BUILTIN_HUGE_VALF || sym == YY___BUILTIN_INF || sym == YY___BUILTIN_INFF || sym == YY___BUILTIN_ISUNORDERED || sym == YY___BUILTIN_NAN || sym == YY___BUILTIN_NANF || sym == YY___BUILTIN_ADD_OVERFLOW || sym == YY___BUILTIN_ADD_OVERFLOW_P || sym == YY___BUILTIN_SADD_OVERFLOW || sym == YY___BUILTIN_SADDL_OVERFLOW || sym == YY___BUILTIN_SADDLL_OVERFLOW || sym == YY___BUILTIN_UADD_OVERFLOW || sym == YY___BUILTIN_UADDL_OVERFLOW || sym == YY___BUILTIN_UADDLL_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW_P || sym == YY___BUILTIN_SSUB_OVERFLOW || sym == YY___BUILTIN_SSUBL_OVERFLOW || sym == YY___BUILTIN_SSUBLL_OVERFLOW || sym == YY___BUILTIN_USUB_OVERFLOW || sym == YY___BUILTIN_USUBL_OVERFLOW || sym == YY___BUILTIN_USUBLL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW_P || sym == YY___BUILTIN_SMUL_OVERFLOW || sym == YY___BUILTIN_SMULL_OVERFLOW || sym == YY___BUILTIN_SMULLL_OVERFLOW || sym == YY___BUILTIN_UMUL_OVERFLOW || sym == YY___BUILTIN_UMULL_OVERFLOW || sym == YY___BUILTIN_UMULLL_OVERFLOW || sym == YY___BUILTIN_SHUFFLE || sym == YY___BUILTIN_SHUFFLEVECTOR || sym == YY___BUILTIN_CONSTANT_P || sym == YY___BUILTIN_VA_ARG || sym == YY___BUILTIN_CONVERTVECTOR) { sym = parse_expression(sym, rcc, &val); } if (sym != YY__SEMICOLON) { @@ -2122,7 +2122,7 @@ static yy_sym parse_strings(yy_sym sym, rcc_ctx *rcc, c_value *val) { static yy_sym parse_actual_parameters(yy_sym sym, rcc_ctx *rcc, c_value *func, c_value *res) { int32_t num_args = 0; c_value *args = alloca(sizeof(c_value) * C_ALLOCA_PARAMS); - if (sym == YY__LPAREN || C_IS_ID(sym) || sym == YY_DECIMAL_NUMBER || sym == YY_OCTAL_NUMBER || sym == YY_HEXADECIMAL_NUMBER || sym == YY_BINARY_NUMBER || sym == YY_FLOATING_NUMBER || sym == YY_HEXADECIMAL_FLOATING_NUMBER || sym == YY_CHARACTER || sym == YY_STRING || sym == YY__GENERIC || sym == YY___EXTENSION__ || sym == YY__PLUS_PLUS || sym == YY__MINUS_MINUS || sym == YY__AND || sym == YY__STAR || sym == YY__PLUS || sym == YY__MINUS || sym == YY__TILDE || sym == YY__BANG || sym == YY_SIZEOF || sym == YY__ALIGNOF || sym == YY___ALIGNOF__ || sym == YY___ALIGNOF || sym == YY__AND_AND || sym == YY___BUILTIN_VA_START || sym == YY___BUILTIN_VA_END || sym == YY___BUILTIN_VA_COPY || sym == YY___BUILTIN_ALLOCA || sym == YY___BUILTIN_ABORT || sym == YY___BUILTIN_TRAP || sym == YY___BUILTIN_DEBUGTRAP || sym == YY___BUILTIN_FRAME_ADDRESS || sym == YY___BUILTIN_ABS || sym == YY___BUILTIN_LABS || sym == YY___BUILTIN_LLABS || sym == YY___BUILTIN_FABS || sym == YY___BUILTIN_FABSF || sym == YY___BUILTIN_BSWAP16 || sym == YY___BUILTIN_BSWAP32 || sym == YY___BUILTIN_BSWAP64 || sym == YY___BUILTIN_POPCOUNT || sym == YY___BUILTIN_POPCOUNTL || sym == YY___BUILTIN_POPCOUNTLL || sym == YY___BUILTIN_CLZ || sym == YY___BUILTIN_CLZL || sym == YY___BUILTIN_CLZLL || sym == YY___BUILTIN_CTZ || sym == YY___BUILTIN_CTZL || sym == YY___BUILTIN_CTZLL || sym == YY___BUILTIN_FFS || sym == YY___BUILTIN_FFSL || sym == YY___BUILTIN_FFSLL || sym == YY___BUILTIN_MEMCPY || sym == YY___BUILTIN_MEMSET || sym == YY___BUILTIN_EXPECT || sym == YY___BUILTIN_PREFETCH || sym == YY___BUILTIN_UNREACHABLE || sym == YY___BUILTIN_HUGE_VAL || sym == YY___BUILTIN_HUGE_VALF || sym == YY___BUILTIN_INF || sym == YY___BUILTIN_INFF || sym == YY___BUILTIN_ISUNORDERED || sym == YY___BUILTIN_NAN || sym == YY___BUILTIN_NANF || sym == YY___BUILTIN_ADD_OVERFLOW || sym == YY___BUILTIN_ADD_OVERFLOW_P || sym == YY___BUILTIN_SADD_OVERFLOW || sym == YY___BUILTIN_SADDL_OVERFLOW || sym == YY___BUILTIN_SADDLL_OVERFLOW || sym == YY___BUILTIN_UADD_OVERFLOW || sym == YY___BUILTIN_UADDL_OVERFLOW || sym == YY___BUILTIN_UADDLL_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW_P || sym == YY___BUILTIN_SSUB_OVERFLOW || sym == YY___BUILTIN_SSUBL_OVERFLOW || sym == YY___BUILTIN_SSUBLL_OVERFLOW || sym == YY___BUILTIN_USUB_OVERFLOW || sym == YY___BUILTIN_USUBL_OVERFLOW || sym == YY___BUILTIN_USUBLL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW_P || sym == YY___BUILTIN_SMUL_OVERFLOW || sym == YY___BUILTIN_SMULL_OVERFLOW || sym == YY___BUILTIN_SMULLL_OVERFLOW || sym == YY___BUILTIN_UMUL_OVERFLOW || sym == YY___BUILTIN_UMULL_OVERFLOW || sym == YY___BUILTIN_UMULLL_OVERFLOW || sym == YY___BUILTIN_CONSTANT_P || sym == YY___BUILTIN_VA_ARG) { + if (sym == YY__LPAREN || C_IS_ID(sym) || sym == YY_DECIMAL_NUMBER || sym == YY_OCTAL_NUMBER || sym == YY_HEXADECIMAL_NUMBER || sym == YY_BINARY_NUMBER || sym == YY_FLOATING_NUMBER || sym == YY_HEXADECIMAL_FLOATING_NUMBER || sym == YY_CHARACTER || sym == YY_STRING || sym == YY__GENERIC || sym == YY___EXTENSION__ || sym == YY__PLUS_PLUS || sym == YY__MINUS_MINUS || sym == YY__AND || sym == YY__STAR || sym == YY__PLUS || sym == YY__MINUS || sym == YY__TILDE || sym == YY__BANG || sym == YY_SIZEOF || sym == YY__ALIGNOF || sym == YY___ALIGNOF__ || sym == YY___ALIGNOF || sym == YY__AND_AND || sym == YY___BUILTIN_VA_START || sym == YY___BUILTIN_VA_END || sym == YY___BUILTIN_VA_COPY || sym == YY___BUILTIN_ALLOCA || sym == YY___BUILTIN_ABORT || sym == YY___BUILTIN_TRAP || sym == YY___BUILTIN_DEBUGTRAP || sym == YY___BUILTIN_FRAME_ADDRESS || sym == YY___BUILTIN_ABS || sym == YY___BUILTIN_LABS || sym == YY___BUILTIN_LLABS || sym == YY___BUILTIN_FABS || sym == YY___BUILTIN_FABSF || sym == YY___BUILTIN_BSWAP16 || sym == YY___BUILTIN_BSWAP32 || sym == YY___BUILTIN_BSWAP64 || sym == YY___BUILTIN_POPCOUNT || sym == YY___BUILTIN_POPCOUNTL || sym == YY___BUILTIN_POPCOUNTLL || sym == YY___BUILTIN_CLZ || sym == YY___BUILTIN_CLZL || sym == YY___BUILTIN_CLZLL || sym == YY___BUILTIN_CTZ || sym == YY___BUILTIN_CTZL || sym == YY___BUILTIN_CTZLL || sym == YY___BUILTIN_FFS || sym == YY___BUILTIN_FFSL || sym == YY___BUILTIN_FFSLL || sym == YY___BUILTIN_MEMCPY || sym == YY___BUILTIN_MEMSET || sym == YY___BUILTIN_EXPECT || sym == YY___BUILTIN_PREFETCH || sym == YY___BUILTIN_UNREACHABLE || sym == YY___BUILTIN_HUGE_VAL || sym == YY___BUILTIN_HUGE_VALF || sym == YY___BUILTIN_INF || sym == YY___BUILTIN_INFF || sym == YY___BUILTIN_ISUNORDERED || sym == YY___BUILTIN_NAN || sym == YY___BUILTIN_NANF || sym == YY___BUILTIN_ADD_OVERFLOW || sym == YY___BUILTIN_ADD_OVERFLOW_P || sym == YY___BUILTIN_SADD_OVERFLOW || sym == YY___BUILTIN_SADDL_OVERFLOW || sym == YY___BUILTIN_SADDLL_OVERFLOW || sym == YY___BUILTIN_UADD_OVERFLOW || sym == YY___BUILTIN_UADDL_OVERFLOW || sym == YY___BUILTIN_UADDLL_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW_P || sym == YY___BUILTIN_SSUB_OVERFLOW || sym == YY___BUILTIN_SSUBL_OVERFLOW || sym == YY___BUILTIN_SSUBLL_OVERFLOW || sym == YY___BUILTIN_USUB_OVERFLOW || sym == YY___BUILTIN_USUBL_OVERFLOW || sym == YY___BUILTIN_USUBLL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW_P || sym == YY___BUILTIN_SMUL_OVERFLOW || sym == YY___BUILTIN_SMULL_OVERFLOW || sym == YY___BUILTIN_SMULLL_OVERFLOW || sym == YY___BUILTIN_UMUL_OVERFLOW || sym == YY___BUILTIN_UMULL_OVERFLOW || sym == YY___BUILTIN_UMULLL_OVERFLOW || sym == YY___BUILTIN_SHUFFLE || sym == YY___BUILTIN_SHUFFLEVECTOR || sym == YY___BUILTIN_CONSTANT_P || sym == YY___BUILTIN_VA_ARG || sym == YY___BUILTIN_CONVERTVECTOR) { c_value_clear(&args[num_args]); sym = parse_assignment_expression(sym, rcc, &args[num_args]); num_args++; @@ -2141,7 +2141,7 @@ static yy_sym parse_actual_parameters(yy_sym sym, rcc_ctx *rcc, c_value *func, c static yy_sym parse_builtin_parameters(yy_sym sym, rcc_ctx *rcc, c_value *val, c_name name) { int32_t num_args = 0; c_value *args = alloca(sizeof(c_value) * C_ALLOCA_PARAMS); - if (sym == YY__LPAREN || C_IS_ID(sym) || sym == YY_DECIMAL_NUMBER || sym == YY_OCTAL_NUMBER || sym == YY_HEXADECIMAL_NUMBER || sym == YY_BINARY_NUMBER || sym == YY_FLOATING_NUMBER || sym == YY_HEXADECIMAL_FLOATING_NUMBER || sym == YY_CHARACTER || sym == YY_STRING || sym == YY__GENERIC || sym == YY___EXTENSION__ || sym == YY__PLUS_PLUS || sym == YY__MINUS_MINUS || sym == YY__AND || sym == YY__STAR || sym == YY__PLUS || sym == YY__MINUS || sym == YY__TILDE || sym == YY__BANG || sym == YY_SIZEOF || sym == YY__ALIGNOF || sym == YY___ALIGNOF__ || sym == YY___ALIGNOF || sym == YY__AND_AND || sym == YY___BUILTIN_VA_START || sym == YY___BUILTIN_VA_END || sym == YY___BUILTIN_VA_COPY || sym == YY___BUILTIN_ALLOCA || sym == YY___BUILTIN_ABORT || sym == YY___BUILTIN_TRAP || sym == YY___BUILTIN_DEBUGTRAP || sym == YY___BUILTIN_FRAME_ADDRESS || sym == YY___BUILTIN_ABS || sym == YY___BUILTIN_LABS || sym == YY___BUILTIN_LLABS || sym == YY___BUILTIN_FABS || sym == YY___BUILTIN_FABSF || sym == YY___BUILTIN_BSWAP16 || sym == YY___BUILTIN_BSWAP32 || sym == YY___BUILTIN_BSWAP64 || sym == YY___BUILTIN_POPCOUNT || sym == YY___BUILTIN_POPCOUNTL || sym == YY___BUILTIN_POPCOUNTLL || sym == YY___BUILTIN_CLZ || sym == YY___BUILTIN_CLZL || sym == YY___BUILTIN_CLZLL || sym == YY___BUILTIN_CTZ || sym == YY___BUILTIN_CTZL || sym == YY___BUILTIN_CTZLL || sym == YY___BUILTIN_FFS || sym == YY___BUILTIN_FFSL || sym == YY___BUILTIN_FFSLL || sym == YY___BUILTIN_MEMCPY || sym == YY___BUILTIN_MEMSET || sym == YY___BUILTIN_EXPECT || sym == YY___BUILTIN_PREFETCH || sym == YY___BUILTIN_UNREACHABLE || sym == YY___BUILTIN_HUGE_VAL || sym == YY___BUILTIN_HUGE_VALF || sym == YY___BUILTIN_INF || sym == YY___BUILTIN_INFF || sym == YY___BUILTIN_ISUNORDERED || sym == YY___BUILTIN_NAN || sym == YY___BUILTIN_NANF || sym == YY___BUILTIN_ADD_OVERFLOW || sym == YY___BUILTIN_ADD_OVERFLOW_P || sym == YY___BUILTIN_SADD_OVERFLOW || sym == YY___BUILTIN_SADDL_OVERFLOW || sym == YY___BUILTIN_SADDLL_OVERFLOW || sym == YY___BUILTIN_UADD_OVERFLOW || sym == YY___BUILTIN_UADDL_OVERFLOW || sym == YY___BUILTIN_UADDLL_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW_P || sym == YY___BUILTIN_SSUB_OVERFLOW || sym == YY___BUILTIN_SSUBL_OVERFLOW || sym == YY___BUILTIN_SSUBLL_OVERFLOW || sym == YY___BUILTIN_USUB_OVERFLOW || sym == YY___BUILTIN_USUBL_OVERFLOW || sym == YY___BUILTIN_USUBLL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW_P || sym == YY___BUILTIN_SMUL_OVERFLOW || sym == YY___BUILTIN_SMULL_OVERFLOW || sym == YY___BUILTIN_SMULLL_OVERFLOW || sym == YY___BUILTIN_UMUL_OVERFLOW || sym == YY___BUILTIN_UMULL_OVERFLOW || sym == YY___BUILTIN_UMULLL_OVERFLOW || sym == YY___BUILTIN_CONSTANT_P || sym == YY___BUILTIN_VA_ARG) { + if (sym == YY__LPAREN || C_IS_ID(sym) || sym == YY_DECIMAL_NUMBER || sym == YY_OCTAL_NUMBER || sym == YY_HEXADECIMAL_NUMBER || sym == YY_BINARY_NUMBER || sym == YY_FLOATING_NUMBER || sym == YY_HEXADECIMAL_FLOATING_NUMBER || sym == YY_CHARACTER || sym == YY_STRING || sym == YY__GENERIC || sym == YY___EXTENSION__ || sym == YY__PLUS_PLUS || sym == YY__MINUS_MINUS || sym == YY__AND || sym == YY__STAR || sym == YY__PLUS || sym == YY__MINUS || sym == YY__TILDE || sym == YY__BANG || sym == YY_SIZEOF || sym == YY__ALIGNOF || sym == YY___ALIGNOF__ || sym == YY___ALIGNOF || sym == YY__AND_AND || sym == YY___BUILTIN_VA_START || sym == YY___BUILTIN_VA_END || sym == YY___BUILTIN_VA_COPY || sym == YY___BUILTIN_ALLOCA || sym == YY___BUILTIN_ABORT || sym == YY___BUILTIN_TRAP || sym == YY___BUILTIN_DEBUGTRAP || sym == YY___BUILTIN_FRAME_ADDRESS || sym == YY___BUILTIN_ABS || sym == YY___BUILTIN_LABS || sym == YY___BUILTIN_LLABS || sym == YY___BUILTIN_FABS || sym == YY___BUILTIN_FABSF || sym == YY___BUILTIN_BSWAP16 || sym == YY___BUILTIN_BSWAP32 || sym == YY___BUILTIN_BSWAP64 || sym == YY___BUILTIN_POPCOUNT || sym == YY___BUILTIN_POPCOUNTL || sym == YY___BUILTIN_POPCOUNTLL || sym == YY___BUILTIN_CLZ || sym == YY___BUILTIN_CLZL || sym == YY___BUILTIN_CLZLL || sym == YY___BUILTIN_CTZ || sym == YY___BUILTIN_CTZL || sym == YY___BUILTIN_CTZLL || sym == YY___BUILTIN_FFS || sym == YY___BUILTIN_FFSL || sym == YY___BUILTIN_FFSLL || sym == YY___BUILTIN_MEMCPY || sym == YY___BUILTIN_MEMSET || sym == YY___BUILTIN_EXPECT || sym == YY___BUILTIN_PREFETCH || sym == YY___BUILTIN_UNREACHABLE || sym == YY___BUILTIN_HUGE_VAL || sym == YY___BUILTIN_HUGE_VALF || sym == YY___BUILTIN_INF || sym == YY___BUILTIN_INFF || sym == YY___BUILTIN_ISUNORDERED || sym == YY___BUILTIN_NAN || sym == YY___BUILTIN_NANF || sym == YY___BUILTIN_ADD_OVERFLOW || sym == YY___BUILTIN_ADD_OVERFLOW_P || sym == YY___BUILTIN_SADD_OVERFLOW || sym == YY___BUILTIN_SADDL_OVERFLOW || sym == YY___BUILTIN_SADDLL_OVERFLOW || sym == YY___BUILTIN_UADD_OVERFLOW || sym == YY___BUILTIN_UADDL_OVERFLOW || sym == YY___BUILTIN_UADDLL_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW_P || sym == YY___BUILTIN_SSUB_OVERFLOW || sym == YY___BUILTIN_SSUBL_OVERFLOW || sym == YY___BUILTIN_SSUBLL_OVERFLOW || sym == YY___BUILTIN_USUB_OVERFLOW || sym == YY___BUILTIN_USUBL_OVERFLOW || sym == YY___BUILTIN_USUBLL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW_P || sym == YY___BUILTIN_SMUL_OVERFLOW || sym == YY___BUILTIN_SMULL_OVERFLOW || sym == YY___BUILTIN_SMULLL_OVERFLOW || sym == YY___BUILTIN_UMUL_OVERFLOW || sym == YY___BUILTIN_UMULL_OVERFLOW || sym == YY___BUILTIN_UMULLL_OVERFLOW || sym == YY___BUILTIN_SHUFFLE || sym == YY___BUILTIN_SHUFFLEVECTOR || sym == YY___BUILTIN_CONSTANT_P || sym == YY___BUILTIN_VA_ARG || sym == YY___BUILTIN_CONVERTVECTOR) { sym = parse_assignment_expression(sym, rcc, &args[num_args]); num_args++; while (sym == YY__COMMA) { @@ -2187,14 +2187,14 @@ static yy_sym parse_unary_expression(yy_sym sym, rcc_ctx *rcc, c_value *val) { c_do_init_expr_start(rcc, &obj, t); sym = parse_initializer_contents(sym, rcc, &obj, &size); c_do_init_expr_end(rcc, &v, &obj, size); - } else if (sym == YY__LPAREN || C_IS_ID(sym) || sym == YY_DECIMAL_NUMBER || sym == YY_OCTAL_NUMBER || sym == YY_HEXADECIMAL_NUMBER || sym == YY_BINARY_NUMBER || sym == YY_FLOATING_NUMBER || sym == YY_HEXADECIMAL_FLOATING_NUMBER || sym == YY_CHARACTER || sym == YY_STRING || sym == YY__GENERIC || sym == YY___EXTENSION__ || sym == YY__PLUS_PLUS || sym == YY__MINUS_MINUS || sym == YY__AND || sym == YY__STAR || sym == YY__PLUS || sym == YY__MINUS || sym == YY__TILDE || sym == YY__BANG || sym == YY_SIZEOF || sym == YY__ALIGNOF || sym == YY___ALIGNOF__ || sym == YY___ALIGNOF || sym == YY__AND_AND || sym == YY___BUILTIN_VA_START || sym == YY___BUILTIN_VA_END || sym == YY___BUILTIN_VA_COPY || sym == YY___BUILTIN_ALLOCA || sym == YY___BUILTIN_ABORT || sym == YY___BUILTIN_TRAP || sym == YY___BUILTIN_DEBUGTRAP || sym == YY___BUILTIN_FRAME_ADDRESS || sym == YY___BUILTIN_ABS || sym == YY___BUILTIN_LABS || sym == YY___BUILTIN_LLABS || sym == YY___BUILTIN_FABS || sym == YY___BUILTIN_FABSF || sym == YY___BUILTIN_BSWAP16 || sym == YY___BUILTIN_BSWAP32 || sym == YY___BUILTIN_BSWAP64 || sym == YY___BUILTIN_POPCOUNT || sym == YY___BUILTIN_POPCOUNTL || sym == YY___BUILTIN_POPCOUNTLL || sym == YY___BUILTIN_CLZ || sym == YY___BUILTIN_CLZL || sym == YY___BUILTIN_CLZLL || sym == YY___BUILTIN_CTZ || sym == YY___BUILTIN_CTZL || sym == YY___BUILTIN_CTZLL || sym == YY___BUILTIN_FFS || sym == YY___BUILTIN_FFSL || sym == YY___BUILTIN_FFSLL || sym == YY___BUILTIN_MEMCPY || sym == YY___BUILTIN_MEMSET || sym == YY___BUILTIN_EXPECT || sym == YY___BUILTIN_PREFETCH || sym == YY___BUILTIN_UNREACHABLE || sym == YY___BUILTIN_HUGE_VAL || sym == YY___BUILTIN_HUGE_VALF || sym == YY___BUILTIN_INF || sym == YY___BUILTIN_INFF || sym == YY___BUILTIN_ISUNORDERED || sym == YY___BUILTIN_NAN || sym == YY___BUILTIN_NANF || sym == YY___BUILTIN_ADD_OVERFLOW || sym == YY___BUILTIN_ADD_OVERFLOW_P || sym == YY___BUILTIN_SADD_OVERFLOW || sym == YY___BUILTIN_SADDL_OVERFLOW || sym == YY___BUILTIN_SADDLL_OVERFLOW || sym == YY___BUILTIN_UADD_OVERFLOW || sym == YY___BUILTIN_UADDL_OVERFLOW || sym == YY___BUILTIN_UADDLL_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW_P || sym == YY___BUILTIN_SSUB_OVERFLOW || sym == YY___BUILTIN_SSUBL_OVERFLOW || sym == YY___BUILTIN_SSUBLL_OVERFLOW || sym == YY___BUILTIN_USUB_OVERFLOW || sym == YY___BUILTIN_USUBL_OVERFLOW || sym == YY___BUILTIN_USUBLL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW_P || sym == YY___BUILTIN_SMUL_OVERFLOW || sym == YY___BUILTIN_SMULL_OVERFLOW || sym == YY___BUILTIN_SMULLL_OVERFLOW || sym == YY___BUILTIN_UMUL_OVERFLOW || sym == YY___BUILTIN_UMULL_OVERFLOW || sym == YY___BUILTIN_UMULLL_OVERFLOW || sym == YY___BUILTIN_CONSTANT_P || sym == YY___BUILTIN_VA_ARG) { + } else if (sym == YY__LPAREN || C_IS_ID(sym) || sym == YY_DECIMAL_NUMBER || sym == YY_OCTAL_NUMBER || sym == YY_HEXADECIMAL_NUMBER || sym == YY_BINARY_NUMBER || sym == YY_FLOATING_NUMBER || sym == YY_HEXADECIMAL_FLOATING_NUMBER || sym == YY_CHARACTER || sym == YY_STRING || sym == YY__GENERIC || sym == YY___EXTENSION__ || sym == YY__PLUS_PLUS || sym == YY__MINUS_MINUS || sym == YY__AND || sym == YY__STAR || sym == YY__PLUS || sym == YY__MINUS || sym == YY__TILDE || sym == YY__BANG || sym == YY_SIZEOF || sym == YY__ALIGNOF || sym == YY___ALIGNOF__ || sym == YY___ALIGNOF || sym == YY__AND_AND || sym == YY___BUILTIN_VA_START || sym == YY___BUILTIN_VA_END || sym == YY___BUILTIN_VA_COPY || sym == YY___BUILTIN_ALLOCA || sym == YY___BUILTIN_ABORT || sym == YY___BUILTIN_TRAP || sym == YY___BUILTIN_DEBUGTRAP || sym == YY___BUILTIN_FRAME_ADDRESS || sym == YY___BUILTIN_ABS || sym == YY___BUILTIN_LABS || sym == YY___BUILTIN_LLABS || sym == YY___BUILTIN_FABS || sym == YY___BUILTIN_FABSF || sym == YY___BUILTIN_BSWAP16 || sym == YY___BUILTIN_BSWAP32 || sym == YY___BUILTIN_BSWAP64 || sym == YY___BUILTIN_POPCOUNT || sym == YY___BUILTIN_POPCOUNTL || sym == YY___BUILTIN_POPCOUNTLL || sym == YY___BUILTIN_CLZ || sym == YY___BUILTIN_CLZL || sym == YY___BUILTIN_CLZLL || sym == YY___BUILTIN_CTZ || sym == YY___BUILTIN_CTZL || sym == YY___BUILTIN_CTZLL || sym == YY___BUILTIN_FFS || sym == YY___BUILTIN_FFSL || sym == YY___BUILTIN_FFSLL || sym == YY___BUILTIN_MEMCPY || sym == YY___BUILTIN_MEMSET || sym == YY___BUILTIN_EXPECT || sym == YY___BUILTIN_PREFETCH || sym == YY___BUILTIN_UNREACHABLE || sym == YY___BUILTIN_HUGE_VAL || sym == YY___BUILTIN_HUGE_VALF || sym == YY___BUILTIN_INF || sym == YY___BUILTIN_INFF || sym == YY___BUILTIN_ISUNORDERED || sym == YY___BUILTIN_NAN || sym == YY___BUILTIN_NANF || sym == YY___BUILTIN_ADD_OVERFLOW || sym == YY___BUILTIN_ADD_OVERFLOW_P || sym == YY___BUILTIN_SADD_OVERFLOW || sym == YY___BUILTIN_SADDL_OVERFLOW || sym == YY___BUILTIN_SADDLL_OVERFLOW || sym == YY___BUILTIN_UADD_OVERFLOW || sym == YY___BUILTIN_UADDL_OVERFLOW || sym == YY___BUILTIN_UADDLL_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW_P || sym == YY___BUILTIN_SSUB_OVERFLOW || sym == YY___BUILTIN_SSUBL_OVERFLOW || sym == YY___BUILTIN_SSUBLL_OVERFLOW || sym == YY___BUILTIN_USUB_OVERFLOW || sym == YY___BUILTIN_USUBL_OVERFLOW || sym == YY___BUILTIN_USUBLL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW_P || sym == YY___BUILTIN_SMUL_OVERFLOW || sym == YY___BUILTIN_SMULL_OVERFLOW || sym == YY___BUILTIN_SMULLL_OVERFLOW || sym == YY___BUILTIN_UMUL_OVERFLOW || sym == YY___BUILTIN_UMULL_OVERFLOW || sym == YY___BUILTIN_UMULLL_OVERFLOW || sym == YY___BUILTIN_SHUFFLE || sym == YY___BUILTIN_SHUFFLEVECTOR || sym == YY___BUILTIN_CONSTANT_P || sym == YY___BUILTIN_VA_ARG || sym == YY___BUILTIN_CONVERTVECTOR) { c_value_clear(&v); sym = parse_unary_expression(sym, rcc, &v); c_do_cast(rcc, t, &v); } else { yy_error_sym("unexpected", sym); } - } else if (sym == YY__LPAREN || C_IS_ID(sym) || sym == YY_DECIMAL_NUMBER || sym == YY_OCTAL_NUMBER || sym == YY_HEXADECIMAL_NUMBER || sym == YY_BINARY_NUMBER || sym == YY_FLOATING_NUMBER || sym == YY_HEXADECIMAL_FLOATING_NUMBER || sym == YY_CHARACTER || sym == YY_STRING || sym == YY__GENERIC || sym == YY___EXTENSION__ || sym == YY__PLUS_PLUS || sym == YY__MINUS_MINUS || sym == YY__AND || sym == YY__STAR || sym == YY__PLUS || sym == YY__MINUS || sym == YY__TILDE || sym == YY__BANG || sym == YY_SIZEOF || sym == YY__ALIGNOF || sym == YY___ALIGNOF__ || sym == YY___ALIGNOF || sym == YY__AND_AND || sym == YY___BUILTIN_VA_START || sym == YY___BUILTIN_VA_END || sym == YY___BUILTIN_VA_COPY || sym == YY___BUILTIN_ALLOCA || sym == YY___BUILTIN_ABORT || sym == YY___BUILTIN_TRAP || sym == YY___BUILTIN_DEBUGTRAP || sym == YY___BUILTIN_FRAME_ADDRESS || sym == YY___BUILTIN_ABS || sym == YY___BUILTIN_LABS || sym == YY___BUILTIN_LLABS || sym == YY___BUILTIN_FABS || sym == YY___BUILTIN_FABSF || sym == YY___BUILTIN_BSWAP16 || sym == YY___BUILTIN_BSWAP32 || sym == YY___BUILTIN_BSWAP64 || sym == YY___BUILTIN_POPCOUNT || sym == YY___BUILTIN_POPCOUNTL || sym == YY___BUILTIN_POPCOUNTLL || sym == YY___BUILTIN_CLZ || sym == YY___BUILTIN_CLZL || sym == YY___BUILTIN_CLZLL || sym == YY___BUILTIN_CTZ || sym == YY___BUILTIN_CTZL || sym == YY___BUILTIN_CTZLL || sym == YY___BUILTIN_FFS || sym == YY___BUILTIN_FFSL || sym == YY___BUILTIN_FFSLL || sym == YY___BUILTIN_MEMCPY || sym == YY___BUILTIN_MEMSET || sym == YY___BUILTIN_EXPECT || sym == YY___BUILTIN_PREFETCH || sym == YY___BUILTIN_UNREACHABLE || sym == YY___BUILTIN_HUGE_VAL || sym == YY___BUILTIN_HUGE_VALF || sym == YY___BUILTIN_INF || sym == YY___BUILTIN_INFF || sym == YY___BUILTIN_ISUNORDERED || sym == YY___BUILTIN_NAN || sym == YY___BUILTIN_NANF || sym == YY___BUILTIN_ADD_OVERFLOW || sym == YY___BUILTIN_ADD_OVERFLOW_P || sym == YY___BUILTIN_SADD_OVERFLOW || sym == YY___BUILTIN_SADDL_OVERFLOW || sym == YY___BUILTIN_SADDLL_OVERFLOW || sym == YY___BUILTIN_UADD_OVERFLOW || sym == YY___BUILTIN_UADDL_OVERFLOW || sym == YY___BUILTIN_UADDLL_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW_P || sym == YY___BUILTIN_SSUB_OVERFLOW || sym == YY___BUILTIN_SSUBL_OVERFLOW || sym == YY___BUILTIN_SSUBLL_OVERFLOW || sym == YY___BUILTIN_USUB_OVERFLOW || sym == YY___BUILTIN_USUBL_OVERFLOW || sym == YY___BUILTIN_USUBLL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW_P || sym == YY___BUILTIN_SMUL_OVERFLOW || sym == YY___BUILTIN_SMULL_OVERFLOW || sym == YY___BUILTIN_SMULLL_OVERFLOW || sym == YY___BUILTIN_UMUL_OVERFLOW || sym == YY___BUILTIN_UMULL_OVERFLOW || sym == YY___BUILTIN_UMULLL_OVERFLOW || sym == YY___BUILTIN_CONSTANT_P || sym == YY___BUILTIN_VA_ARG) { + } else if (sym == YY__LPAREN || C_IS_ID(sym) || sym == YY_DECIMAL_NUMBER || sym == YY_OCTAL_NUMBER || sym == YY_HEXADECIMAL_NUMBER || sym == YY_BINARY_NUMBER || sym == YY_FLOATING_NUMBER || sym == YY_HEXADECIMAL_FLOATING_NUMBER || sym == YY_CHARACTER || sym == YY_STRING || sym == YY__GENERIC || sym == YY___EXTENSION__ || sym == YY__PLUS_PLUS || sym == YY__MINUS_MINUS || sym == YY__AND || sym == YY__STAR || sym == YY__PLUS || sym == YY__MINUS || sym == YY__TILDE || sym == YY__BANG || sym == YY_SIZEOF || sym == YY__ALIGNOF || sym == YY___ALIGNOF__ || sym == YY___ALIGNOF || sym == YY__AND_AND || sym == YY___BUILTIN_VA_START || sym == YY___BUILTIN_VA_END || sym == YY___BUILTIN_VA_COPY || sym == YY___BUILTIN_ALLOCA || sym == YY___BUILTIN_ABORT || sym == YY___BUILTIN_TRAP || sym == YY___BUILTIN_DEBUGTRAP || sym == YY___BUILTIN_FRAME_ADDRESS || sym == YY___BUILTIN_ABS || sym == YY___BUILTIN_LABS || sym == YY___BUILTIN_LLABS || sym == YY___BUILTIN_FABS || sym == YY___BUILTIN_FABSF || sym == YY___BUILTIN_BSWAP16 || sym == YY___BUILTIN_BSWAP32 || sym == YY___BUILTIN_BSWAP64 || sym == YY___BUILTIN_POPCOUNT || sym == YY___BUILTIN_POPCOUNTL || sym == YY___BUILTIN_POPCOUNTLL || sym == YY___BUILTIN_CLZ || sym == YY___BUILTIN_CLZL || sym == YY___BUILTIN_CLZLL || sym == YY___BUILTIN_CTZ || sym == YY___BUILTIN_CTZL || sym == YY___BUILTIN_CTZLL || sym == YY___BUILTIN_FFS || sym == YY___BUILTIN_FFSL || sym == YY___BUILTIN_FFSLL || sym == YY___BUILTIN_MEMCPY || sym == YY___BUILTIN_MEMSET || sym == YY___BUILTIN_EXPECT || sym == YY___BUILTIN_PREFETCH || sym == YY___BUILTIN_UNREACHABLE || sym == YY___BUILTIN_HUGE_VAL || sym == YY___BUILTIN_HUGE_VALF || sym == YY___BUILTIN_INF || sym == YY___BUILTIN_INFF || sym == YY___BUILTIN_ISUNORDERED || sym == YY___BUILTIN_NAN || sym == YY___BUILTIN_NANF || sym == YY___BUILTIN_ADD_OVERFLOW || sym == YY___BUILTIN_ADD_OVERFLOW_P || sym == YY___BUILTIN_SADD_OVERFLOW || sym == YY___BUILTIN_SADDL_OVERFLOW || sym == YY___BUILTIN_SADDLL_OVERFLOW || sym == YY___BUILTIN_UADD_OVERFLOW || sym == YY___BUILTIN_UADDL_OVERFLOW || sym == YY___BUILTIN_UADDLL_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW_P || sym == YY___BUILTIN_SSUB_OVERFLOW || sym == YY___BUILTIN_SSUBL_OVERFLOW || sym == YY___BUILTIN_SSUBLL_OVERFLOW || sym == YY___BUILTIN_USUB_OVERFLOW || sym == YY___BUILTIN_USUBL_OVERFLOW || sym == YY___BUILTIN_USUBLL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW_P || sym == YY___BUILTIN_SMUL_OVERFLOW || sym == YY___BUILTIN_SMULL_OVERFLOW || sym == YY___BUILTIN_SMULLL_OVERFLOW || sym == YY___BUILTIN_UMUL_OVERFLOW || sym == YY___BUILTIN_UMULL_OVERFLOW || sym == YY___BUILTIN_UMULLL_OVERFLOW || sym == YY___BUILTIN_SHUFFLE || sym == YY___BUILTIN_SHUFFLEVECTOR || sym == YY___BUILTIN_CONSTANT_P || sym == YY___BUILTIN_VA_ARG || sym == YY___BUILTIN_CONVERTVECTOR) { v.u.optx = val->u.optx; sym = parse_expression(sym, rcc, &v); if (sym != YY__RPAREN) { @@ -2328,7 +2328,7 @@ static yy_sym parse_unary_expression(yy_sym sym, rcc_ctx *rcc, c_value *val) { sym = parse_dummy_value(sym, rcc, t); } c_sizeof_type(rcc, &v, t); - } else if (sym == YY__LPAREN || C_IS_ID(sym) || sym == YY_DECIMAL_NUMBER || sym == YY_OCTAL_NUMBER || sym == YY_HEXADECIMAL_NUMBER || sym == YY_BINARY_NUMBER || sym == YY_FLOATING_NUMBER || sym == YY_HEXADECIMAL_FLOATING_NUMBER || sym == YY_CHARACTER || sym == YY_STRING || sym == YY__GENERIC || sym == YY___EXTENSION__ || sym == YY__PLUS_PLUS || sym == YY__MINUS_MINUS || sym == YY__AND || sym == YY__STAR || sym == YY__PLUS || sym == YY__MINUS || sym == YY__TILDE || sym == YY__BANG || sym == YY_SIZEOF || sym == YY__ALIGNOF || sym == YY___ALIGNOF__ || sym == YY___ALIGNOF || sym == YY__AND_AND || sym == YY___BUILTIN_VA_START || sym == YY___BUILTIN_VA_END || sym == YY___BUILTIN_VA_COPY || sym == YY___BUILTIN_ALLOCA || sym == YY___BUILTIN_ABORT || sym == YY___BUILTIN_TRAP || sym == YY___BUILTIN_DEBUGTRAP || sym == YY___BUILTIN_FRAME_ADDRESS || sym == YY___BUILTIN_ABS || sym == YY___BUILTIN_LABS || sym == YY___BUILTIN_LLABS || sym == YY___BUILTIN_FABS || sym == YY___BUILTIN_FABSF || sym == YY___BUILTIN_BSWAP16 || sym == YY___BUILTIN_BSWAP32 || sym == YY___BUILTIN_BSWAP64 || sym == YY___BUILTIN_POPCOUNT || sym == YY___BUILTIN_POPCOUNTL || sym == YY___BUILTIN_POPCOUNTLL || sym == YY___BUILTIN_CLZ || sym == YY___BUILTIN_CLZL || sym == YY___BUILTIN_CLZLL || sym == YY___BUILTIN_CTZ || sym == YY___BUILTIN_CTZL || sym == YY___BUILTIN_CTZLL || sym == YY___BUILTIN_FFS || sym == YY___BUILTIN_FFSL || sym == YY___BUILTIN_FFSLL || sym == YY___BUILTIN_MEMCPY || sym == YY___BUILTIN_MEMSET || sym == YY___BUILTIN_EXPECT || sym == YY___BUILTIN_PREFETCH || sym == YY___BUILTIN_UNREACHABLE || sym == YY___BUILTIN_HUGE_VAL || sym == YY___BUILTIN_HUGE_VALF || sym == YY___BUILTIN_INF || sym == YY___BUILTIN_INFF || sym == YY___BUILTIN_ISUNORDERED || sym == YY___BUILTIN_NAN || sym == YY___BUILTIN_NANF || sym == YY___BUILTIN_ADD_OVERFLOW || sym == YY___BUILTIN_ADD_OVERFLOW_P || sym == YY___BUILTIN_SADD_OVERFLOW || sym == YY___BUILTIN_SADDL_OVERFLOW || sym == YY___BUILTIN_SADDLL_OVERFLOW || sym == YY___BUILTIN_UADD_OVERFLOW || sym == YY___BUILTIN_UADDL_OVERFLOW || sym == YY___BUILTIN_UADDLL_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW_P || sym == YY___BUILTIN_SSUB_OVERFLOW || sym == YY___BUILTIN_SSUBL_OVERFLOW || sym == YY___BUILTIN_SSUBLL_OVERFLOW || sym == YY___BUILTIN_USUB_OVERFLOW || sym == YY___BUILTIN_USUBL_OVERFLOW || sym == YY___BUILTIN_USUBLL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW_P || sym == YY___BUILTIN_SMUL_OVERFLOW || sym == YY___BUILTIN_SMULL_OVERFLOW || sym == YY___BUILTIN_SMULLL_OVERFLOW || sym == YY___BUILTIN_UMUL_OVERFLOW || sym == YY___BUILTIN_UMULL_OVERFLOW || sym == YY___BUILTIN_UMULLL_OVERFLOW || sym == YY___BUILTIN_CONSTANT_P || sym == YY___BUILTIN_VA_ARG) { + } else if (sym == YY__LPAREN || C_IS_ID(sym) || sym == YY_DECIMAL_NUMBER || sym == YY_OCTAL_NUMBER || sym == YY_HEXADECIMAL_NUMBER || sym == YY_BINARY_NUMBER || sym == YY_FLOATING_NUMBER || sym == YY_HEXADECIMAL_FLOATING_NUMBER || sym == YY_CHARACTER || sym == YY_STRING || sym == YY__GENERIC || sym == YY___EXTENSION__ || sym == YY__PLUS_PLUS || sym == YY__MINUS_MINUS || sym == YY__AND || sym == YY__STAR || sym == YY__PLUS || sym == YY__MINUS || sym == YY__TILDE || sym == YY__BANG || sym == YY_SIZEOF || sym == YY__ALIGNOF || sym == YY___ALIGNOF__ || sym == YY___ALIGNOF || sym == YY__AND_AND || sym == YY___BUILTIN_VA_START || sym == YY___BUILTIN_VA_END || sym == YY___BUILTIN_VA_COPY || sym == YY___BUILTIN_ALLOCA || sym == YY___BUILTIN_ABORT || sym == YY___BUILTIN_TRAP || sym == YY___BUILTIN_DEBUGTRAP || sym == YY___BUILTIN_FRAME_ADDRESS || sym == YY___BUILTIN_ABS || sym == YY___BUILTIN_LABS || sym == YY___BUILTIN_LLABS || sym == YY___BUILTIN_FABS || sym == YY___BUILTIN_FABSF || sym == YY___BUILTIN_BSWAP16 || sym == YY___BUILTIN_BSWAP32 || sym == YY___BUILTIN_BSWAP64 || sym == YY___BUILTIN_POPCOUNT || sym == YY___BUILTIN_POPCOUNTL || sym == YY___BUILTIN_POPCOUNTLL || sym == YY___BUILTIN_CLZ || sym == YY___BUILTIN_CLZL || sym == YY___BUILTIN_CLZLL || sym == YY___BUILTIN_CTZ || sym == YY___BUILTIN_CTZL || sym == YY___BUILTIN_CTZLL || sym == YY___BUILTIN_FFS || sym == YY___BUILTIN_FFSL || sym == YY___BUILTIN_FFSLL || sym == YY___BUILTIN_MEMCPY || sym == YY___BUILTIN_MEMSET || sym == YY___BUILTIN_EXPECT || sym == YY___BUILTIN_PREFETCH || sym == YY___BUILTIN_UNREACHABLE || sym == YY___BUILTIN_HUGE_VAL || sym == YY___BUILTIN_HUGE_VALF || sym == YY___BUILTIN_INF || sym == YY___BUILTIN_INFF || sym == YY___BUILTIN_ISUNORDERED || sym == YY___BUILTIN_NAN || sym == YY___BUILTIN_NANF || sym == YY___BUILTIN_ADD_OVERFLOW || sym == YY___BUILTIN_ADD_OVERFLOW_P || sym == YY___BUILTIN_SADD_OVERFLOW || sym == YY___BUILTIN_SADDL_OVERFLOW || sym == YY___BUILTIN_SADDLL_OVERFLOW || sym == YY___BUILTIN_UADD_OVERFLOW || sym == YY___BUILTIN_UADDL_OVERFLOW || sym == YY___BUILTIN_UADDLL_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW_P || sym == YY___BUILTIN_SSUB_OVERFLOW || sym == YY___BUILTIN_SSUBL_OVERFLOW || sym == YY___BUILTIN_SSUBLL_OVERFLOW || sym == YY___BUILTIN_USUB_OVERFLOW || sym == YY___BUILTIN_USUBL_OVERFLOW || sym == YY___BUILTIN_USUBLL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW_P || sym == YY___BUILTIN_SMUL_OVERFLOW || sym == YY___BUILTIN_SMULL_OVERFLOW || sym == YY___BUILTIN_SMULLL_OVERFLOW || sym == YY___BUILTIN_UMUL_OVERFLOW || sym == YY___BUILTIN_UMULL_OVERFLOW || sym == YY___BUILTIN_UMULLL_OVERFLOW || sym == YY___BUILTIN_SHUFFLE || sym == YY___BUILTIN_SHUFFLEVECTOR || sym == YY___BUILTIN_CONSTANT_P || sym == YY___BUILTIN_VA_ARG || sym == YY___BUILTIN_CONVERTVECTOR) { old_control = c_do_nocode(rcc); c_value_clear(&v); sym = parse_expression(sym, rcc, &v); @@ -2353,7 +2353,7 @@ static yy_sym parse_unary_expression(yy_sym sym, rcc_ctx *rcc, c_value *val) { } else { yy_error_sym("unexpected", sym); } - } else if (sym == YY__LPAREN || C_IS_ID(sym) || sym == YY_DECIMAL_NUMBER || sym == YY_OCTAL_NUMBER || sym == YY_HEXADECIMAL_NUMBER || sym == YY_BINARY_NUMBER || sym == YY_FLOATING_NUMBER || sym == YY_HEXADECIMAL_FLOATING_NUMBER || sym == YY_CHARACTER || sym == YY_STRING || sym == YY__GENERIC || sym == YY___EXTENSION__ || sym == YY__PLUS_PLUS || sym == YY__MINUS_MINUS || sym == YY__AND || sym == YY__STAR || sym == YY__PLUS || sym == YY__MINUS || sym == YY__TILDE || sym == YY__BANG || sym == YY_SIZEOF || sym == YY__ALIGNOF || sym == YY___ALIGNOF__ || sym == YY___ALIGNOF || sym == YY__AND_AND || sym == YY___BUILTIN_VA_START || sym == YY___BUILTIN_VA_END || sym == YY___BUILTIN_VA_COPY || sym == YY___BUILTIN_ALLOCA || sym == YY___BUILTIN_ABORT || sym == YY___BUILTIN_TRAP || sym == YY___BUILTIN_DEBUGTRAP || sym == YY___BUILTIN_FRAME_ADDRESS || sym == YY___BUILTIN_ABS || sym == YY___BUILTIN_LABS || sym == YY___BUILTIN_LLABS || sym == YY___BUILTIN_FABS || sym == YY___BUILTIN_FABSF || sym == YY___BUILTIN_BSWAP16 || sym == YY___BUILTIN_BSWAP32 || sym == YY___BUILTIN_BSWAP64 || sym == YY___BUILTIN_POPCOUNT || sym == YY___BUILTIN_POPCOUNTL || sym == YY___BUILTIN_POPCOUNTLL || sym == YY___BUILTIN_CLZ || sym == YY___BUILTIN_CLZL || sym == YY___BUILTIN_CLZLL || sym == YY___BUILTIN_CTZ || sym == YY___BUILTIN_CTZL || sym == YY___BUILTIN_CTZLL || sym == YY___BUILTIN_FFS || sym == YY___BUILTIN_FFSL || sym == YY___BUILTIN_FFSLL || sym == YY___BUILTIN_MEMCPY || sym == YY___BUILTIN_MEMSET || sym == YY___BUILTIN_EXPECT || sym == YY___BUILTIN_PREFETCH || sym == YY___BUILTIN_UNREACHABLE || sym == YY___BUILTIN_HUGE_VAL || sym == YY___BUILTIN_HUGE_VALF || sym == YY___BUILTIN_INF || sym == YY___BUILTIN_INFF || sym == YY___BUILTIN_ISUNORDERED || sym == YY___BUILTIN_NAN || sym == YY___BUILTIN_NANF || sym == YY___BUILTIN_ADD_OVERFLOW || sym == YY___BUILTIN_ADD_OVERFLOW_P || sym == YY___BUILTIN_SADD_OVERFLOW || sym == YY___BUILTIN_SADDL_OVERFLOW || sym == YY___BUILTIN_SADDLL_OVERFLOW || sym == YY___BUILTIN_UADD_OVERFLOW || sym == YY___BUILTIN_UADDL_OVERFLOW || sym == YY___BUILTIN_UADDLL_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW_P || sym == YY___BUILTIN_SSUB_OVERFLOW || sym == YY___BUILTIN_SSUBL_OVERFLOW || sym == YY___BUILTIN_SSUBLL_OVERFLOW || sym == YY___BUILTIN_USUB_OVERFLOW || sym == YY___BUILTIN_USUBL_OVERFLOW || sym == YY___BUILTIN_USUBLL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW_P || sym == YY___BUILTIN_SMUL_OVERFLOW || sym == YY___BUILTIN_SMULL_OVERFLOW || sym == YY___BUILTIN_SMULLL_OVERFLOW || sym == YY___BUILTIN_UMUL_OVERFLOW || sym == YY___BUILTIN_UMULL_OVERFLOW || sym == YY___BUILTIN_UMULLL_OVERFLOW || sym == YY___BUILTIN_CONSTANT_P || sym == YY___BUILTIN_VA_ARG) { + } else if (sym == YY__LPAREN || C_IS_ID(sym) || sym == YY_DECIMAL_NUMBER || sym == YY_OCTAL_NUMBER || sym == YY_HEXADECIMAL_NUMBER || sym == YY_BINARY_NUMBER || sym == YY_FLOATING_NUMBER || sym == YY_HEXADECIMAL_FLOATING_NUMBER || sym == YY_CHARACTER || sym == YY_STRING || sym == YY__GENERIC || sym == YY___EXTENSION__ || sym == YY__PLUS_PLUS || sym == YY__MINUS_MINUS || sym == YY__AND || sym == YY__STAR || sym == YY__PLUS || sym == YY__MINUS || sym == YY__TILDE || sym == YY__BANG || sym == YY_SIZEOF || sym == YY__ALIGNOF || sym == YY___ALIGNOF__ || sym == YY___ALIGNOF || sym == YY__AND_AND || sym == YY___BUILTIN_VA_START || sym == YY___BUILTIN_VA_END || sym == YY___BUILTIN_VA_COPY || sym == YY___BUILTIN_ALLOCA || sym == YY___BUILTIN_ABORT || sym == YY___BUILTIN_TRAP || sym == YY___BUILTIN_DEBUGTRAP || sym == YY___BUILTIN_FRAME_ADDRESS || sym == YY___BUILTIN_ABS || sym == YY___BUILTIN_LABS || sym == YY___BUILTIN_LLABS || sym == YY___BUILTIN_FABS || sym == YY___BUILTIN_FABSF || sym == YY___BUILTIN_BSWAP16 || sym == YY___BUILTIN_BSWAP32 || sym == YY___BUILTIN_BSWAP64 || sym == YY___BUILTIN_POPCOUNT || sym == YY___BUILTIN_POPCOUNTL || sym == YY___BUILTIN_POPCOUNTLL || sym == YY___BUILTIN_CLZ || sym == YY___BUILTIN_CLZL || sym == YY___BUILTIN_CLZLL || sym == YY___BUILTIN_CTZ || sym == YY___BUILTIN_CTZL || sym == YY___BUILTIN_CTZLL || sym == YY___BUILTIN_FFS || sym == YY___BUILTIN_FFSL || sym == YY___BUILTIN_FFSLL || sym == YY___BUILTIN_MEMCPY || sym == YY___BUILTIN_MEMSET || sym == YY___BUILTIN_EXPECT || sym == YY___BUILTIN_PREFETCH || sym == YY___BUILTIN_UNREACHABLE || sym == YY___BUILTIN_HUGE_VAL || sym == YY___BUILTIN_HUGE_VALF || sym == YY___BUILTIN_INF || sym == YY___BUILTIN_INFF || sym == YY___BUILTIN_ISUNORDERED || sym == YY___BUILTIN_NAN || sym == YY___BUILTIN_NANF || sym == YY___BUILTIN_ADD_OVERFLOW || sym == YY___BUILTIN_ADD_OVERFLOW_P || sym == YY___BUILTIN_SADD_OVERFLOW || sym == YY___BUILTIN_SADDL_OVERFLOW || sym == YY___BUILTIN_SADDLL_OVERFLOW || sym == YY___BUILTIN_UADD_OVERFLOW || sym == YY___BUILTIN_UADDL_OVERFLOW || sym == YY___BUILTIN_UADDLL_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW_P || sym == YY___BUILTIN_SSUB_OVERFLOW || sym == YY___BUILTIN_SSUBL_OVERFLOW || sym == YY___BUILTIN_SSUBLL_OVERFLOW || sym == YY___BUILTIN_USUB_OVERFLOW || sym == YY___BUILTIN_USUBL_OVERFLOW || sym == YY___BUILTIN_USUBLL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW_P || sym == YY___BUILTIN_SMUL_OVERFLOW || sym == YY___BUILTIN_SMULL_OVERFLOW || sym == YY___BUILTIN_SMULLL_OVERFLOW || sym == YY___BUILTIN_UMUL_OVERFLOW || sym == YY___BUILTIN_UMULL_OVERFLOW || sym == YY___BUILTIN_UMULLL_OVERFLOW || sym == YY___BUILTIN_SHUFFLE || sym == YY___BUILTIN_SHUFFLEVECTOR || sym == YY___BUILTIN_CONSTANT_P || sym == YY___BUILTIN_VA_ARG || sym == YY___BUILTIN_CONVERTVECTOR) { ir_ref old = c_do_nocode(rcc); c_value_clear(&v); sym = parse_unary_expression(sym, rcc, &v); @@ -2387,7 +2387,7 @@ static yy_sym parse_unary_expression(yy_sym sym, rcc_ctx *rcc, c_value *val) { sym = parse_dummy_value(sym, rcc, t); } c_alignof_type(rcc, &v, t); - } else if (sym == YY__LPAREN || C_IS_ID(sym) || sym == YY_DECIMAL_NUMBER || sym == YY_OCTAL_NUMBER || sym == YY_HEXADECIMAL_NUMBER || sym == YY_BINARY_NUMBER || sym == YY_FLOATING_NUMBER || sym == YY_HEXADECIMAL_FLOATING_NUMBER || sym == YY_CHARACTER || sym == YY_STRING || sym == YY__GENERIC || sym == YY___EXTENSION__ || sym == YY__PLUS_PLUS || sym == YY__MINUS_MINUS || sym == YY__AND || sym == YY__STAR || sym == YY__PLUS || sym == YY__MINUS || sym == YY__TILDE || sym == YY__BANG || sym == YY_SIZEOF || sym == YY__ALIGNOF || sym == YY___ALIGNOF__ || sym == YY___ALIGNOF || sym == YY__AND_AND || sym == YY___BUILTIN_VA_START || sym == YY___BUILTIN_VA_END || sym == YY___BUILTIN_VA_COPY || sym == YY___BUILTIN_ALLOCA || sym == YY___BUILTIN_ABORT || sym == YY___BUILTIN_TRAP || sym == YY___BUILTIN_DEBUGTRAP || sym == YY___BUILTIN_FRAME_ADDRESS || sym == YY___BUILTIN_ABS || sym == YY___BUILTIN_LABS || sym == YY___BUILTIN_LLABS || sym == YY___BUILTIN_FABS || sym == YY___BUILTIN_FABSF || sym == YY___BUILTIN_BSWAP16 || sym == YY___BUILTIN_BSWAP32 || sym == YY___BUILTIN_BSWAP64 || sym == YY___BUILTIN_POPCOUNT || sym == YY___BUILTIN_POPCOUNTL || sym == YY___BUILTIN_POPCOUNTLL || sym == YY___BUILTIN_CLZ || sym == YY___BUILTIN_CLZL || sym == YY___BUILTIN_CLZLL || sym == YY___BUILTIN_CTZ || sym == YY___BUILTIN_CTZL || sym == YY___BUILTIN_CTZLL || sym == YY___BUILTIN_FFS || sym == YY___BUILTIN_FFSL || sym == YY___BUILTIN_FFSLL || sym == YY___BUILTIN_MEMCPY || sym == YY___BUILTIN_MEMSET || sym == YY___BUILTIN_EXPECT || sym == YY___BUILTIN_PREFETCH || sym == YY___BUILTIN_UNREACHABLE || sym == YY___BUILTIN_HUGE_VAL || sym == YY___BUILTIN_HUGE_VALF || sym == YY___BUILTIN_INF || sym == YY___BUILTIN_INFF || sym == YY___BUILTIN_ISUNORDERED || sym == YY___BUILTIN_NAN || sym == YY___BUILTIN_NANF || sym == YY___BUILTIN_ADD_OVERFLOW || sym == YY___BUILTIN_ADD_OVERFLOW_P || sym == YY___BUILTIN_SADD_OVERFLOW || sym == YY___BUILTIN_SADDL_OVERFLOW || sym == YY___BUILTIN_SADDLL_OVERFLOW || sym == YY___BUILTIN_UADD_OVERFLOW || sym == YY___BUILTIN_UADDL_OVERFLOW || sym == YY___BUILTIN_UADDLL_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW_P || sym == YY___BUILTIN_SSUB_OVERFLOW || sym == YY___BUILTIN_SSUBL_OVERFLOW || sym == YY___BUILTIN_SSUBLL_OVERFLOW || sym == YY___BUILTIN_USUB_OVERFLOW || sym == YY___BUILTIN_USUBL_OVERFLOW || sym == YY___BUILTIN_USUBLL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW_P || sym == YY___BUILTIN_SMUL_OVERFLOW || sym == YY___BUILTIN_SMULL_OVERFLOW || sym == YY___BUILTIN_SMULLL_OVERFLOW || sym == YY___BUILTIN_UMUL_OVERFLOW || sym == YY___BUILTIN_UMULL_OVERFLOW || sym == YY___BUILTIN_UMULLL_OVERFLOW || sym == YY___BUILTIN_CONSTANT_P || sym == YY___BUILTIN_VA_ARG) { + } else if (sym == YY__LPAREN || C_IS_ID(sym) || sym == YY_DECIMAL_NUMBER || sym == YY_OCTAL_NUMBER || sym == YY_HEXADECIMAL_NUMBER || sym == YY_BINARY_NUMBER || sym == YY_FLOATING_NUMBER || sym == YY_HEXADECIMAL_FLOATING_NUMBER || sym == YY_CHARACTER || sym == YY_STRING || sym == YY__GENERIC || sym == YY___EXTENSION__ || sym == YY__PLUS_PLUS || sym == YY__MINUS_MINUS || sym == YY__AND || sym == YY__STAR || sym == YY__PLUS || sym == YY__MINUS || sym == YY__TILDE || sym == YY__BANG || sym == YY_SIZEOF || sym == YY__ALIGNOF || sym == YY___ALIGNOF__ || sym == YY___ALIGNOF || sym == YY__AND_AND || sym == YY___BUILTIN_VA_START || sym == YY___BUILTIN_VA_END || sym == YY___BUILTIN_VA_COPY || sym == YY___BUILTIN_ALLOCA || sym == YY___BUILTIN_ABORT || sym == YY___BUILTIN_TRAP || sym == YY___BUILTIN_DEBUGTRAP || sym == YY___BUILTIN_FRAME_ADDRESS || sym == YY___BUILTIN_ABS || sym == YY___BUILTIN_LABS || sym == YY___BUILTIN_LLABS || sym == YY___BUILTIN_FABS || sym == YY___BUILTIN_FABSF || sym == YY___BUILTIN_BSWAP16 || sym == YY___BUILTIN_BSWAP32 || sym == YY___BUILTIN_BSWAP64 || sym == YY___BUILTIN_POPCOUNT || sym == YY___BUILTIN_POPCOUNTL || sym == YY___BUILTIN_POPCOUNTLL || sym == YY___BUILTIN_CLZ || sym == YY___BUILTIN_CLZL || sym == YY___BUILTIN_CLZLL || sym == YY___BUILTIN_CTZ || sym == YY___BUILTIN_CTZL || sym == YY___BUILTIN_CTZLL || sym == YY___BUILTIN_FFS || sym == YY___BUILTIN_FFSL || sym == YY___BUILTIN_FFSLL || sym == YY___BUILTIN_MEMCPY || sym == YY___BUILTIN_MEMSET || sym == YY___BUILTIN_EXPECT || sym == YY___BUILTIN_PREFETCH || sym == YY___BUILTIN_UNREACHABLE || sym == YY___BUILTIN_HUGE_VAL || sym == YY___BUILTIN_HUGE_VALF || sym == YY___BUILTIN_INF || sym == YY___BUILTIN_INFF || sym == YY___BUILTIN_ISUNORDERED || sym == YY___BUILTIN_NAN || sym == YY___BUILTIN_NANF || sym == YY___BUILTIN_ADD_OVERFLOW || sym == YY___BUILTIN_ADD_OVERFLOW_P || sym == YY___BUILTIN_SADD_OVERFLOW || sym == YY___BUILTIN_SADDL_OVERFLOW || sym == YY___BUILTIN_SADDLL_OVERFLOW || sym == YY___BUILTIN_UADD_OVERFLOW || sym == YY___BUILTIN_UADDL_OVERFLOW || sym == YY___BUILTIN_UADDLL_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW_P || sym == YY___BUILTIN_SSUB_OVERFLOW || sym == YY___BUILTIN_SSUBL_OVERFLOW || sym == YY___BUILTIN_SSUBLL_OVERFLOW || sym == YY___BUILTIN_USUB_OVERFLOW || sym == YY___BUILTIN_USUBL_OVERFLOW || sym == YY___BUILTIN_USUBLL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW_P || sym == YY___BUILTIN_SMUL_OVERFLOW || sym == YY___BUILTIN_SMULL_OVERFLOW || sym == YY___BUILTIN_SMULLL_OVERFLOW || sym == YY___BUILTIN_UMUL_OVERFLOW || sym == YY___BUILTIN_UMULL_OVERFLOW || sym == YY___BUILTIN_UMULLL_OVERFLOW || sym == YY___BUILTIN_SHUFFLE || sym == YY___BUILTIN_SHUFFLEVECTOR || sym == YY___BUILTIN_CONSTANT_P || sym == YY___BUILTIN_VA_ARG || sym == YY___BUILTIN_CONVERTVECTOR) { old_control = c_do_nocode(rcc); c_value_clear(&v); sym = parse_expression(sym, rcc, &v); @@ -2412,7 +2412,7 @@ static yy_sym parse_unary_expression(yy_sym sym, rcc_ctx *rcc, c_value *val) { } else { yy_error_sym("unexpected", sym); } - } else if (sym == YY__LPAREN || C_IS_ID(sym) || sym == YY_DECIMAL_NUMBER || sym == YY_OCTAL_NUMBER || sym == YY_HEXADECIMAL_NUMBER || sym == YY_BINARY_NUMBER || sym == YY_FLOATING_NUMBER || sym == YY_HEXADECIMAL_FLOATING_NUMBER || sym == YY_CHARACTER || sym == YY_STRING || sym == YY__GENERIC || sym == YY___EXTENSION__ || sym == YY__PLUS_PLUS || sym == YY__MINUS_MINUS || sym == YY__AND || sym == YY__STAR || sym == YY__PLUS || sym == YY__MINUS || sym == YY__TILDE || sym == YY__BANG || sym == YY_SIZEOF || sym == YY__ALIGNOF || sym == YY___ALIGNOF__ || sym == YY___ALIGNOF || sym == YY__AND_AND || sym == YY___BUILTIN_VA_START || sym == YY___BUILTIN_VA_END || sym == YY___BUILTIN_VA_COPY || sym == YY___BUILTIN_ALLOCA || sym == YY___BUILTIN_ABORT || sym == YY___BUILTIN_TRAP || sym == YY___BUILTIN_DEBUGTRAP || sym == YY___BUILTIN_FRAME_ADDRESS || sym == YY___BUILTIN_ABS || sym == YY___BUILTIN_LABS || sym == YY___BUILTIN_LLABS || sym == YY___BUILTIN_FABS || sym == YY___BUILTIN_FABSF || sym == YY___BUILTIN_BSWAP16 || sym == YY___BUILTIN_BSWAP32 || sym == YY___BUILTIN_BSWAP64 || sym == YY___BUILTIN_POPCOUNT || sym == YY___BUILTIN_POPCOUNTL || sym == YY___BUILTIN_POPCOUNTLL || sym == YY___BUILTIN_CLZ || sym == YY___BUILTIN_CLZL || sym == YY___BUILTIN_CLZLL || sym == YY___BUILTIN_CTZ || sym == YY___BUILTIN_CTZL || sym == YY___BUILTIN_CTZLL || sym == YY___BUILTIN_FFS || sym == YY___BUILTIN_FFSL || sym == YY___BUILTIN_FFSLL || sym == YY___BUILTIN_MEMCPY || sym == YY___BUILTIN_MEMSET || sym == YY___BUILTIN_EXPECT || sym == YY___BUILTIN_PREFETCH || sym == YY___BUILTIN_UNREACHABLE || sym == YY___BUILTIN_HUGE_VAL || sym == YY___BUILTIN_HUGE_VALF || sym == YY___BUILTIN_INF || sym == YY___BUILTIN_INFF || sym == YY___BUILTIN_ISUNORDERED || sym == YY___BUILTIN_NAN || sym == YY___BUILTIN_NANF || sym == YY___BUILTIN_ADD_OVERFLOW || sym == YY___BUILTIN_ADD_OVERFLOW_P || sym == YY___BUILTIN_SADD_OVERFLOW || sym == YY___BUILTIN_SADDL_OVERFLOW || sym == YY___BUILTIN_SADDLL_OVERFLOW || sym == YY___BUILTIN_UADD_OVERFLOW || sym == YY___BUILTIN_UADDL_OVERFLOW || sym == YY___BUILTIN_UADDLL_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW_P || sym == YY___BUILTIN_SSUB_OVERFLOW || sym == YY___BUILTIN_SSUBL_OVERFLOW || sym == YY___BUILTIN_SSUBLL_OVERFLOW || sym == YY___BUILTIN_USUB_OVERFLOW || sym == YY___BUILTIN_USUBL_OVERFLOW || sym == YY___BUILTIN_USUBLL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW_P || sym == YY___BUILTIN_SMUL_OVERFLOW || sym == YY___BUILTIN_SMULL_OVERFLOW || sym == YY___BUILTIN_SMULLL_OVERFLOW || sym == YY___BUILTIN_UMUL_OVERFLOW || sym == YY___BUILTIN_UMULL_OVERFLOW || sym == YY___BUILTIN_UMULLL_OVERFLOW || sym == YY___BUILTIN_CONSTANT_P || sym == YY___BUILTIN_VA_ARG) { + } else if (sym == YY__LPAREN || C_IS_ID(sym) || sym == YY_DECIMAL_NUMBER || sym == YY_OCTAL_NUMBER || sym == YY_HEXADECIMAL_NUMBER || sym == YY_BINARY_NUMBER || sym == YY_FLOATING_NUMBER || sym == YY_HEXADECIMAL_FLOATING_NUMBER || sym == YY_CHARACTER || sym == YY_STRING || sym == YY__GENERIC || sym == YY___EXTENSION__ || sym == YY__PLUS_PLUS || sym == YY__MINUS_MINUS || sym == YY__AND || sym == YY__STAR || sym == YY__PLUS || sym == YY__MINUS || sym == YY__TILDE || sym == YY__BANG || sym == YY_SIZEOF || sym == YY__ALIGNOF || sym == YY___ALIGNOF__ || sym == YY___ALIGNOF || sym == YY__AND_AND || sym == YY___BUILTIN_VA_START || sym == YY___BUILTIN_VA_END || sym == YY___BUILTIN_VA_COPY || sym == YY___BUILTIN_ALLOCA || sym == YY___BUILTIN_ABORT || sym == YY___BUILTIN_TRAP || sym == YY___BUILTIN_DEBUGTRAP || sym == YY___BUILTIN_FRAME_ADDRESS || sym == YY___BUILTIN_ABS || sym == YY___BUILTIN_LABS || sym == YY___BUILTIN_LLABS || sym == YY___BUILTIN_FABS || sym == YY___BUILTIN_FABSF || sym == YY___BUILTIN_BSWAP16 || sym == YY___BUILTIN_BSWAP32 || sym == YY___BUILTIN_BSWAP64 || sym == YY___BUILTIN_POPCOUNT || sym == YY___BUILTIN_POPCOUNTL || sym == YY___BUILTIN_POPCOUNTLL || sym == YY___BUILTIN_CLZ || sym == YY___BUILTIN_CLZL || sym == YY___BUILTIN_CLZLL || sym == YY___BUILTIN_CTZ || sym == YY___BUILTIN_CTZL || sym == YY___BUILTIN_CTZLL || sym == YY___BUILTIN_FFS || sym == YY___BUILTIN_FFSL || sym == YY___BUILTIN_FFSLL || sym == YY___BUILTIN_MEMCPY || sym == YY___BUILTIN_MEMSET || sym == YY___BUILTIN_EXPECT || sym == YY___BUILTIN_PREFETCH || sym == YY___BUILTIN_UNREACHABLE || sym == YY___BUILTIN_HUGE_VAL || sym == YY___BUILTIN_HUGE_VALF || sym == YY___BUILTIN_INF || sym == YY___BUILTIN_INFF || sym == YY___BUILTIN_ISUNORDERED || sym == YY___BUILTIN_NAN || sym == YY___BUILTIN_NANF || sym == YY___BUILTIN_ADD_OVERFLOW || sym == YY___BUILTIN_ADD_OVERFLOW_P || sym == YY___BUILTIN_SADD_OVERFLOW || sym == YY___BUILTIN_SADDL_OVERFLOW || sym == YY___BUILTIN_SADDLL_OVERFLOW || sym == YY___BUILTIN_UADD_OVERFLOW || sym == YY___BUILTIN_UADDL_OVERFLOW || sym == YY___BUILTIN_UADDLL_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW_P || sym == YY___BUILTIN_SSUB_OVERFLOW || sym == YY___BUILTIN_SSUBL_OVERFLOW || sym == YY___BUILTIN_SSUBLL_OVERFLOW || sym == YY___BUILTIN_USUB_OVERFLOW || sym == YY___BUILTIN_USUBL_OVERFLOW || sym == YY___BUILTIN_USUBLL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW_P || sym == YY___BUILTIN_SMUL_OVERFLOW || sym == YY___BUILTIN_SMULL_OVERFLOW || sym == YY___BUILTIN_SMULLL_OVERFLOW || sym == YY___BUILTIN_UMUL_OVERFLOW || sym == YY___BUILTIN_UMULL_OVERFLOW || sym == YY___BUILTIN_UMULLL_OVERFLOW || sym == YY___BUILTIN_SHUFFLE || sym == YY___BUILTIN_SHUFFLEVECTOR || sym == YY___BUILTIN_CONSTANT_P || sym == YY___BUILTIN_VA_ARG || sym == YY___BUILTIN_CONVERTVECTOR) { ir_ref old = c_do_nocode(rcc); c_value_clear(&v); sym = parse_unary_expression(sym, rcc, &v); @@ -2424,7 +2424,7 @@ static yy_sym parse_unary_expression(yy_sym sym, rcc_ctx *rcc, c_value *val) { sym = get_sym(); sym = parse_ID(sym, rcc, &name); c_do_label_value(rcc, &v, name); - } else if (sym == YY___BUILTIN_VA_START || sym == YY___BUILTIN_VA_END || sym == YY___BUILTIN_VA_COPY || sym == YY___BUILTIN_ALLOCA || sym == YY___BUILTIN_ABORT || sym == YY___BUILTIN_TRAP || sym == YY___BUILTIN_DEBUGTRAP || sym == YY___BUILTIN_FRAME_ADDRESS || sym == YY___BUILTIN_ABS || sym == YY___BUILTIN_LABS || sym == YY___BUILTIN_LLABS || sym == YY___BUILTIN_FABS || sym == YY___BUILTIN_FABSF || sym == YY___BUILTIN_BSWAP16 || sym == YY___BUILTIN_BSWAP32 || sym == YY___BUILTIN_BSWAP64 || sym == YY___BUILTIN_POPCOUNT || sym == YY___BUILTIN_POPCOUNTL || sym == YY___BUILTIN_POPCOUNTLL || sym == YY___BUILTIN_CLZ || sym == YY___BUILTIN_CLZL || sym == YY___BUILTIN_CLZLL || sym == YY___BUILTIN_CTZ || sym == YY___BUILTIN_CTZL || sym == YY___BUILTIN_CTZLL || sym == YY___BUILTIN_FFS || sym == YY___BUILTIN_FFSL || sym == YY___BUILTIN_FFSLL || sym == YY___BUILTIN_MEMCPY || sym == YY___BUILTIN_MEMSET || sym == YY___BUILTIN_EXPECT || sym == YY___BUILTIN_PREFETCH || sym == YY___BUILTIN_UNREACHABLE || sym == YY___BUILTIN_HUGE_VAL || sym == YY___BUILTIN_HUGE_VALF || sym == YY___BUILTIN_INF || sym == YY___BUILTIN_INFF || sym == YY___BUILTIN_ISUNORDERED || sym == YY___BUILTIN_NAN || sym == YY___BUILTIN_NANF || sym == YY___BUILTIN_ADD_OVERFLOW || sym == YY___BUILTIN_ADD_OVERFLOW_P || sym == YY___BUILTIN_SADD_OVERFLOW || sym == YY___BUILTIN_SADDL_OVERFLOW || sym == YY___BUILTIN_SADDLL_OVERFLOW || sym == YY___BUILTIN_UADD_OVERFLOW || sym == YY___BUILTIN_UADDL_OVERFLOW || sym == YY___BUILTIN_UADDLL_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW_P || sym == YY___BUILTIN_SSUB_OVERFLOW || sym == YY___BUILTIN_SSUBL_OVERFLOW || sym == YY___BUILTIN_SSUBLL_OVERFLOW || sym == YY___BUILTIN_USUB_OVERFLOW || sym == YY___BUILTIN_USUBL_OVERFLOW || sym == YY___BUILTIN_USUBLL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW_P || sym == YY___BUILTIN_SMUL_OVERFLOW || sym == YY___BUILTIN_SMULL_OVERFLOW || sym == YY___BUILTIN_SMULLL_OVERFLOW || sym == YY___BUILTIN_UMUL_OVERFLOW || sym == YY___BUILTIN_UMULL_OVERFLOW || sym == YY___BUILTIN_UMULLL_OVERFLOW) { + } else if (sym == YY___BUILTIN_VA_START || sym == YY___BUILTIN_VA_END || sym == YY___BUILTIN_VA_COPY || sym == YY___BUILTIN_ALLOCA || sym == YY___BUILTIN_ABORT || sym == YY___BUILTIN_TRAP || sym == YY___BUILTIN_DEBUGTRAP || sym == YY___BUILTIN_FRAME_ADDRESS || sym == YY___BUILTIN_ABS || sym == YY___BUILTIN_LABS || sym == YY___BUILTIN_LLABS || sym == YY___BUILTIN_FABS || sym == YY___BUILTIN_FABSF || sym == YY___BUILTIN_BSWAP16 || sym == YY___BUILTIN_BSWAP32 || sym == YY___BUILTIN_BSWAP64 || sym == YY___BUILTIN_POPCOUNT || sym == YY___BUILTIN_POPCOUNTL || sym == YY___BUILTIN_POPCOUNTLL || sym == YY___BUILTIN_CLZ || sym == YY___BUILTIN_CLZL || sym == YY___BUILTIN_CLZLL || sym == YY___BUILTIN_CTZ || sym == YY___BUILTIN_CTZL || sym == YY___BUILTIN_CTZLL || sym == YY___BUILTIN_FFS || sym == YY___BUILTIN_FFSL || sym == YY___BUILTIN_FFSLL || sym == YY___BUILTIN_MEMCPY || sym == YY___BUILTIN_MEMSET || sym == YY___BUILTIN_EXPECT || sym == YY___BUILTIN_PREFETCH || sym == YY___BUILTIN_UNREACHABLE || sym == YY___BUILTIN_HUGE_VAL || sym == YY___BUILTIN_HUGE_VALF || sym == YY___BUILTIN_INF || sym == YY___BUILTIN_INFF || sym == YY___BUILTIN_ISUNORDERED || sym == YY___BUILTIN_NAN || sym == YY___BUILTIN_NANF || sym == YY___BUILTIN_ADD_OVERFLOW || sym == YY___BUILTIN_ADD_OVERFLOW_P || sym == YY___BUILTIN_SADD_OVERFLOW || sym == YY___BUILTIN_SADDL_OVERFLOW || sym == YY___BUILTIN_SADDLL_OVERFLOW || sym == YY___BUILTIN_UADD_OVERFLOW || sym == YY___BUILTIN_UADDL_OVERFLOW || sym == YY___BUILTIN_UADDLL_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW_P || sym == YY___BUILTIN_SSUB_OVERFLOW || sym == YY___BUILTIN_SSUBL_OVERFLOW || sym == YY___BUILTIN_SSUBLL_OVERFLOW || sym == YY___BUILTIN_USUB_OVERFLOW || sym == YY___BUILTIN_USUBL_OVERFLOW || sym == YY___BUILTIN_USUBLL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW_P || sym == YY___BUILTIN_SMUL_OVERFLOW || sym == YY___BUILTIN_SMULL_OVERFLOW || sym == YY___BUILTIN_SMULLL_OVERFLOW || sym == YY___BUILTIN_UMUL_OVERFLOW || sym == YY___BUILTIN_UMULL_OVERFLOW || sym == YY___BUILTIN_UMULLL_OVERFLOW || sym == YY___BUILTIN_SHUFFLE || sym == YY___BUILTIN_SHUFFLEVECTOR) { name = sym; sym = get_sym(); if (sym != YY__LPAREN) { @@ -2469,6 +2469,23 @@ static yy_sym parse_unary_expression(yy_sym sym, rcc_ctx *rcc, c_value *val) { yy_error_sym("')' expected, got", sym); } sym = get_sym(); + } else if (sym == YY___BUILTIN_CONVERTVECTOR) { + sym = get_sym(); + if (sym != YY__LPAREN) { + yy_error_sym("'(' expected, got", sym); + } + sym = get_sym(); + sym = parse_assignment_expression(sym, rcc, &v); + if (sym != YY__COMMA) { + yy_error_sym("',' expected, got", sym); + } + sym = get_sym(); + sym = parse_type_name(sym, rcc, &t); + c_do_builtin_convertvector(rcc, &v, t); + if (sym != YY__RPAREN) { + yy_error_sym("')' expected, got", sym); + } + sym = get_sym(); } else { yy_error_sym("unexpected", sym); } @@ -2580,7 +2597,7 @@ static yy_sym parse_conditional_expression(yy_sym sym, rcc_ctx *rcc, c_value *va } sym = get_sym(); check = c_do_if(rcc, val); - if (sym == YY__LPAREN || C_IS_ID(sym) || sym == YY_DECIMAL_NUMBER || sym == YY_OCTAL_NUMBER || sym == YY_HEXADECIMAL_NUMBER || sym == YY_BINARY_NUMBER || sym == YY_FLOATING_NUMBER || sym == YY_HEXADECIMAL_FLOATING_NUMBER || sym == YY_CHARACTER || sym == YY_STRING || sym == YY__GENERIC || sym == YY___EXTENSION__ || sym == YY__PLUS_PLUS || sym == YY__MINUS_MINUS || sym == YY__AND || sym == YY__STAR || sym == YY__PLUS || sym == YY__MINUS || sym == YY__TILDE || sym == YY__BANG || sym == YY_SIZEOF || sym == YY__ALIGNOF || sym == YY___ALIGNOF__ || sym == YY___ALIGNOF || sym == YY__AND_AND || sym == YY___BUILTIN_VA_START || sym == YY___BUILTIN_VA_END || sym == YY___BUILTIN_VA_COPY || sym == YY___BUILTIN_ALLOCA || sym == YY___BUILTIN_ABORT || sym == YY___BUILTIN_TRAP || sym == YY___BUILTIN_DEBUGTRAP || sym == YY___BUILTIN_FRAME_ADDRESS || sym == YY___BUILTIN_ABS || sym == YY___BUILTIN_LABS || sym == YY___BUILTIN_LLABS || sym == YY___BUILTIN_FABS || sym == YY___BUILTIN_FABSF || sym == YY___BUILTIN_BSWAP16 || sym == YY___BUILTIN_BSWAP32 || sym == YY___BUILTIN_BSWAP64 || sym == YY___BUILTIN_POPCOUNT || sym == YY___BUILTIN_POPCOUNTL || sym == YY___BUILTIN_POPCOUNTLL || sym == YY___BUILTIN_CLZ || sym == YY___BUILTIN_CLZL || sym == YY___BUILTIN_CLZLL || sym == YY___BUILTIN_CTZ || sym == YY___BUILTIN_CTZL || sym == YY___BUILTIN_CTZLL || sym == YY___BUILTIN_FFS || sym == YY___BUILTIN_FFSL || sym == YY___BUILTIN_FFSLL || sym == YY___BUILTIN_MEMCPY || sym == YY___BUILTIN_MEMSET || sym == YY___BUILTIN_EXPECT || sym == YY___BUILTIN_PREFETCH || sym == YY___BUILTIN_UNREACHABLE || sym == YY___BUILTIN_HUGE_VAL || sym == YY___BUILTIN_HUGE_VALF || sym == YY___BUILTIN_INF || sym == YY___BUILTIN_INFF || sym == YY___BUILTIN_ISUNORDERED || sym == YY___BUILTIN_NAN || sym == YY___BUILTIN_NANF || sym == YY___BUILTIN_ADD_OVERFLOW || sym == YY___BUILTIN_ADD_OVERFLOW_P || sym == YY___BUILTIN_SADD_OVERFLOW || sym == YY___BUILTIN_SADDL_OVERFLOW || sym == YY___BUILTIN_SADDLL_OVERFLOW || sym == YY___BUILTIN_UADD_OVERFLOW || sym == YY___BUILTIN_UADDL_OVERFLOW || sym == YY___BUILTIN_UADDLL_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW_P || sym == YY___BUILTIN_SSUB_OVERFLOW || sym == YY___BUILTIN_SSUBL_OVERFLOW || sym == YY___BUILTIN_SSUBLL_OVERFLOW || sym == YY___BUILTIN_USUB_OVERFLOW || sym == YY___BUILTIN_USUBL_OVERFLOW || sym == YY___BUILTIN_USUBLL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW_P || sym == YY___BUILTIN_SMUL_OVERFLOW || sym == YY___BUILTIN_SMULL_OVERFLOW || sym == YY___BUILTIN_SMULLL_OVERFLOW || sym == YY___BUILTIN_UMUL_OVERFLOW || sym == YY___BUILTIN_UMULL_OVERFLOW || sym == YY___BUILTIN_UMULLL_OVERFLOW || sym == YY___BUILTIN_CONSTANT_P || sym == YY___BUILTIN_VA_ARG) { + if (sym == YY__LPAREN || C_IS_ID(sym) || sym == YY_DECIMAL_NUMBER || sym == YY_OCTAL_NUMBER || sym == YY_HEXADECIMAL_NUMBER || sym == YY_BINARY_NUMBER || sym == YY_FLOATING_NUMBER || sym == YY_HEXADECIMAL_FLOATING_NUMBER || sym == YY_CHARACTER || sym == YY_STRING || sym == YY__GENERIC || sym == YY___EXTENSION__ || sym == YY__PLUS_PLUS || sym == YY__MINUS_MINUS || sym == YY__AND || sym == YY__STAR || sym == YY__PLUS || sym == YY__MINUS || sym == YY__TILDE || sym == YY__BANG || sym == YY_SIZEOF || sym == YY__ALIGNOF || sym == YY___ALIGNOF__ || sym == YY___ALIGNOF || sym == YY__AND_AND || sym == YY___BUILTIN_VA_START || sym == YY___BUILTIN_VA_END || sym == YY___BUILTIN_VA_COPY || sym == YY___BUILTIN_ALLOCA || sym == YY___BUILTIN_ABORT || sym == YY___BUILTIN_TRAP || sym == YY___BUILTIN_DEBUGTRAP || sym == YY___BUILTIN_FRAME_ADDRESS || sym == YY___BUILTIN_ABS || sym == YY___BUILTIN_LABS || sym == YY___BUILTIN_LLABS || sym == YY___BUILTIN_FABS || sym == YY___BUILTIN_FABSF || sym == YY___BUILTIN_BSWAP16 || sym == YY___BUILTIN_BSWAP32 || sym == YY___BUILTIN_BSWAP64 || sym == YY___BUILTIN_POPCOUNT || sym == YY___BUILTIN_POPCOUNTL || sym == YY___BUILTIN_POPCOUNTLL || sym == YY___BUILTIN_CLZ || sym == YY___BUILTIN_CLZL || sym == YY___BUILTIN_CLZLL || sym == YY___BUILTIN_CTZ || sym == YY___BUILTIN_CTZL || sym == YY___BUILTIN_CTZLL || sym == YY___BUILTIN_FFS || sym == YY___BUILTIN_FFSL || sym == YY___BUILTIN_FFSLL || sym == YY___BUILTIN_MEMCPY || sym == YY___BUILTIN_MEMSET || sym == YY___BUILTIN_EXPECT || sym == YY___BUILTIN_PREFETCH || sym == YY___BUILTIN_UNREACHABLE || sym == YY___BUILTIN_HUGE_VAL || sym == YY___BUILTIN_HUGE_VALF || sym == YY___BUILTIN_INF || sym == YY___BUILTIN_INFF || sym == YY___BUILTIN_ISUNORDERED || sym == YY___BUILTIN_NAN || sym == YY___BUILTIN_NANF || sym == YY___BUILTIN_ADD_OVERFLOW || sym == YY___BUILTIN_ADD_OVERFLOW_P || sym == YY___BUILTIN_SADD_OVERFLOW || sym == YY___BUILTIN_SADDL_OVERFLOW || sym == YY___BUILTIN_SADDLL_OVERFLOW || sym == YY___BUILTIN_UADD_OVERFLOW || sym == YY___BUILTIN_UADDL_OVERFLOW || sym == YY___BUILTIN_UADDLL_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW || sym == YY___BUILTIN_SUB_OVERFLOW_P || sym == YY___BUILTIN_SSUB_OVERFLOW || sym == YY___BUILTIN_SSUBL_OVERFLOW || sym == YY___BUILTIN_SSUBLL_OVERFLOW || sym == YY___BUILTIN_USUB_OVERFLOW || sym == YY___BUILTIN_USUBL_OVERFLOW || sym == YY___BUILTIN_USUBLL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW || sym == YY___BUILTIN_MUL_OVERFLOW_P || sym == YY___BUILTIN_SMUL_OVERFLOW || sym == YY___BUILTIN_SMULL_OVERFLOW || sym == YY___BUILTIN_SMULLL_OVERFLOW || sym == YY___BUILTIN_UMUL_OVERFLOW || sym == YY___BUILTIN_UMULL_OVERFLOW || sym == YY___BUILTIN_UMULLL_OVERFLOW || sym == YY___BUILTIN_SHUFFLE || sym == YY___BUILTIN_SHUFFLEVECTOR || sym == YY___BUILTIN_CONSTANT_P || sym == YY___BUILTIN_VA_ARG || sym == YY___BUILTIN_CONVERTVECTOR) { sym = parse_expression(sym, rcc, &op2); c_value_rval(rcc, &op2); } diff --git a/rcc_semantic.c b/rcc_semantic.c index 8ca40a4..f6486ea 100644 --- a/rcc_semantic.c +++ b/rcc_semantic.c @@ -5203,6 +5203,10 @@ void c_do_builtin(rcc_ctx *rcc, c_value *val, c_name name, int32_t num_args, c_v if (!C_IS_TYPE_FP(args[0].type) || !C_IS_TYPE_FP(args[1].type)) yy_error_fmt("wrong arguments in %s() call", yy_sym2str(rcc, name)); ref = ir_fold2(rcc->active_ctx, IR_OPT(IR_UNORDERED, IR_BOOL), c_value_ref(rcc, &args[0]), c_value_ref(rcc, &args[1])); c_value_set_rval(val, &c_type_bool, IR_BOOL, ref); + } else if (name == YY___BUILTIN_SHUFFLE) { + IR_ASSERT(0 && "__builtin_shuffle() NIY ???"); + } else if (name == YY___BUILTIN_SHUFFLEVECTOR) { + IR_ASSERT(0 && "__builtin_shufflevector() NIY ???"); } else { IR_ASSERT(0); } @@ -5266,6 +5270,55 @@ void c_do_builtin_va_arg(rcc_ctx *rcc, c_value *val, const c_type *type) } } +void c_do_builtin_convertvector(rcc_ctx *rcc, c_value *val, const c_type *type) +{ + ir_type t; + ir_op op = IR_NOP; + + if (val->type->kind != C_TYPE_VECTOR) { + yy_error("\"__builtin_convertvector\" first argument must be a vector"); + } else if (type->kind != C_TYPE_VECTOR) { + yy_error("\"__builtin_convertvector\" second argument must be a vector type"); + } else if (val->type->vec.length != type->vec.length) { + yy_error("\"__builtin_convertvector\" vector and type have different number of elements"); + } else if (val->type->vec.type->kind == type->vec.type->kind) { + /* convert to the same type */ + return; + } + + if (C_IS_TYPE_INT(type->vec.type)) { + if (C_IS_TYPE_INT(val->type->vec.type)) { + if (type->vec.type->size < val->type->vec.type->size) { + op = IR_TRUNC; + } else if (type->vec.type->size == val->type->vec.type->size) { + op = IR_BITCAST; + } else if (C_IS_TYPE_SIGNED(val->type->vec.type)) { + op = IR_SEXT; + } else { + op = IR_ZEXT; + } + } else if (C_IS_TYPE_FP(val->type->vec.type)) { + op = IR_FP2INT; + } else { + IR_ASSERT(0); + } + } else if (C_IS_TYPE_FP(type->vec.type)) { + if (C_IS_TYPE_INT(val->type->vec.type)) { + op = IR_INT2FP; + } else if (C_IS_TYPE_FP(val->type->vec.type)) { + op = IR_FP2FP; + } else { + IR_ASSERT(0); + } + } else { + IR_ASSERT(0); + } + + IR_ASSERT(op != IR_NOP); + t = c_type2ir(rcc, type); + c_value_set_rval(val, type, t, ir_fold1(rcc->active_ctx, IR_OPT(op, t), c_value_ref(rcc, val))); +} + static bool c_do_convert_builtin(rcc_ctx *rcc, c_value *func, int32_t num_args, ir_ref *arg_refs) { if (c_value_is_ref(func)) { From 77be7cf70979780687d4695e3f69981c8370f8f0 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Tue, 7 Jul 2026 16:42:59 +0300 Subject: [PATCH 07/31] Support for __builtin_shufflevector() --- rcc_semantic.c | 58 ++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 52 insertions(+), 6 deletions(-) diff --git a/rcc_semantic.c b/rcc_semantic.c index f6486ea..ef22fb3 100644 --- a/rcc_semantic.c +++ b/rcc_semantic.c @@ -822,7 +822,6 @@ static void c_finalize_type(rcc_ctx *rcc, c_dcl *d) type = ir_arena_alloc(&rcc->c_arena, sizeof(c_type)); type->size = d->vector_size; - type->kind = C_TYPE_ARRAY; type->kind = C_TYPE_VECTOR; type->flags = rcc->active_scope ? 0 : C_TYPE_GLOBAL; type->attr = c_align2attr(IR_MIN(d->vector_size, 16)); /* 16 byte allgnment */ @@ -5206,7 +5205,47 @@ void c_do_builtin(rcc_ctx *rcc, c_value *val, c_name name, int32_t num_args, c_v } else if (name == YY___BUILTIN_SHUFFLE) { IR_ASSERT(0 && "__builtin_shuffle() NIY ???"); } else if (name == YY___BUILTIN_SHUFFLEVECTOR) { - IR_ASSERT(0 && "__builtin_shufflevector() NIY ???"); + ir_ref ref; + ir_type t; + uint32_t len1, len2, len, i; + int8_t *ptr; + c_type *type; + + if (num_args < 3) yy_error_fmt("wrong number of arguments in %s() call", yy_sym2str(rcc, name)); + if (args[0].type->kind != C_TYPE_VECTOR) yy_error("first argument of __builtin_shufflevector() must a vector"); + if (args[1].type->kind != C_TYPE_VECTOR) yy_error("second argument of __builtin_shufflevector() must a vector"); + if (args[0].type->vec.type->kind != args[1].type->vec.type->kind) yy_error("first and second arguments of __builtin_shufflevector() are vectors of different types"); + len = num_args - 2; + if (len > 64 || (len & (len - 1)) != 0) yy_error("unsupported numver of vector elments in __builtin_shufflevector()"); + + len1 = args[0].type->vec.length; + len2 = args[1].type->vec.length; + t = IR_MAKE_VECTOR_TYPE(IR_I8, len); + ref = ir_const_vector(rcc->active_ctx, t); + ptr = ir_long_const_ptr(rcc->active_ctx, ref); + for (i = 0; i < len; i++) { + if (!C_IS_TYPE_INT(args[i + 2].type) + || !c_value_is_const(&args[i + 2]) + || (args[i + 2].u.val.u64 > len1 + len2 + && (!C_IS_TYPE_SIGNED(args[i + 2].type) + || args[i + 2].u.val.i64 == -1))) { + yy_error_fmt("%d-th argument of __builtin_shufflevector() is an invalid vector index", i + 3); + } + *ptr = (int8_t)args[i + 2].u.val.i8; + ptr++; + } + + t = IR_MAKE_VECTOR_TYPE(c_type2ir(rcc, args[0].type->vec.type), len); + type = ir_arena_alloc(&rcc->c_arena, sizeof(c_type)); + type->size = IR_VECTOR_SIZE(t); + type->kind = C_TYPE_VECTOR; + type->flags = rcc->active_scope ? 0 : C_TYPE_GLOBAL; + type->attr = c_align2attr(IR_MIN(type->size, 16)); /* 16 byte allgnment */ + type->vec.type = args[0].type->vec.type; + type->vec.length = len; + + c_value_set_rval(val, type, t, + ir_SHUFFLE(t, c_value_ref(rcc, &args[0]), c_value_ref(rcc, &args[1]), ref)); } else { IR_ASSERT(0); } @@ -5276,11 +5315,11 @@ void c_do_builtin_convertvector(rcc_ctx *rcc, c_value *val, const c_type *type) ir_op op = IR_NOP; if (val->type->kind != C_TYPE_VECTOR) { - yy_error("\"__builtin_convertvector\" first argument must be a vector"); + yy_error("first argument of __builtin_convertvector() must be a vector"); } else if (type->kind != C_TYPE_VECTOR) { - yy_error("\"__builtin_convertvector\" second argument must be a vector type"); + yy_error("second argument of __builtin_convertvector() must be a vector type"); } else if (val->type->vec.length != type->vec.length) { - yy_error("\"__builtin_convertvector\" vector and type have different number of elements"); + yy_error("vector and type arguments of __builtin_convertvector() have different number of elements"); } else if (val->type->vec.type->kind == type->vec.type->kind) { /* convert to the same type */ return; @@ -5418,7 +5457,14 @@ static ir_ref ir_inline_call(rcc_ctx *rcc, ir_ctx *ctx, ir_ctx *func_ctx, uint32 optx = IR_OPTX(op, IR_OPT_TYPE(optx), proto); } } - xlat[i] = ir_const_ex(ctx, val, IR_OPT_TYPE(optx), optx); + if (op == IR_LONG_CONST) { + xlat[i] = ir_long_const(ctx, insn->type, insn->long_const_size); + memcpy(ir_long_const_ptr(ctx, xlat[i]), insn + 1, insn->long_const_size); + i += IR_ALIGNED_SIZE(insn->long_const_size, sizeof(ir_insn)) / sizeof(ir_insn); + insn += IR_ALIGNED_SIZE(insn->long_const_size, sizeof(ir_insn)) / sizeof(ir_insn); + } else { + xlat[i] = ir_const_ex(ctx, val, IR_OPT_TYPE(optx), optx); + } } xlat[IR_TRUE] = IR_TRUE; xlat[IR_FALSE] = IR_FALSE; From 7c9056d60bae4cdf61f67938b70cb34b7af35d61 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Tue, 7 Jul 2026 18:27:47 +0300 Subject: [PATCH 08/31] Support for __builtin_shuffle() --- rcc_semantic.c | 63 ++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 53 insertions(+), 10 deletions(-) diff --git a/rcc_semantic.c b/rcc_semantic.c index ef22fb3..29b2fef 100644 --- a/rcc_semantic.c +++ b/rcc_semantic.c @@ -5203,7 +5203,46 @@ void c_do_builtin(rcc_ctx *rcc, c_value *val, c_name name, int32_t num_args, c_v ref = ir_fold2(rcc->active_ctx, IR_OPT(IR_UNORDERED, IR_BOOL), c_value_ref(rcc, &args[0]), c_value_ref(rcc, &args[1])); c_value_set_rval(val, &c_type_bool, IR_BOOL, ref); } else if (name == YY___BUILTIN_SHUFFLE) { - IR_ASSERT(0 && "__builtin_shuffle() NIY ???"); + uint32_t len; + ir_ref op1, op2, op3; + ir_type t; + c_type *type; + + if (num_args != 2 && num_args != 3) yy_error_fmt("wrong number of arguments in %s() call", yy_sym2str(rcc, name)); + if (args[0].type->kind != C_TYPE_VECTOR) yy_error("first argument of __builtin_shuffle() must be a vector"); + if (num_args == 2) { + if (args[1].type->kind != C_TYPE_VECTOR || !C_IS_TYPE_INT(args[1].type->vec.type)) { + yy_error("second argument of __builtin_shuffle() must be an integer vector"); + } + len = args[1].type->vec.length; + op1 = op2 = c_value_ref(rcc, &args[0]); + op3 = c_value_ref(rcc, &args[1]); + } else { + if (args[1].type->kind != C_TYPE_VECTOR) yy_error("second argument of __builtin_shuffle() must be a vector"); + if (args[0].type->vec.type->kind != args[1].type->vec.type->kind) yy_error("first and second arguments of __builtin_shuffle() are vectors of different types"); + if (args[2].type->kind != C_TYPE_VECTOR || !C_IS_TYPE_INT(args[2].type->vec.type)) { + yy_error("third argument of __builtin_shuffle() must be an integer vector"); + } + len = args[2].type->vec.length; + op1 = c_value_ref(rcc, &args[0]); + op2 = c_value_ref(rcc, &args[1]); + op3 = c_value_ref(rcc, &args[2]); + } + + t = IR_MAKE_VECTOR_TYPE(c_type2ir(rcc, args[0].type->vec.type), len); + if ((uint32_t)args[0].type->vec.length == len) { + type = (c_type*)args[0].type; + } else { + type = ir_arena_alloc(&rcc->c_arena, sizeof(c_type)); + type->size = IR_VECTOR_SIZE(t); + type->kind = C_TYPE_VECTOR; + type->flags = rcc->active_scope ? 0 : C_TYPE_GLOBAL; + type->attr = c_align2attr(IR_MIN(type->size, 16)); /* 16 byte allgnment */ + type->vec.type = args[0].type->vec.type; + type->vec.length = len; + } + + c_value_set_rval(val, type, t, ir_SHUFFLE(t, op1, op2, op3)); } else if (name == YY___BUILTIN_SHUFFLEVECTOR) { ir_ref ref; ir_type t; @@ -5212,8 +5251,8 @@ void c_do_builtin(rcc_ctx *rcc, c_value *val, c_name name, int32_t num_args, c_v c_type *type; if (num_args < 3) yy_error_fmt("wrong number of arguments in %s() call", yy_sym2str(rcc, name)); - if (args[0].type->kind != C_TYPE_VECTOR) yy_error("first argument of __builtin_shufflevector() must a vector"); - if (args[1].type->kind != C_TYPE_VECTOR) yy_error("second argument of __builtin_shufflevector() must a vector"); + if (args[0].type->kind != C_TYPE_VECTOR) yy_error("first argument of __builtin_shufflevector() must be a vector"); + if (args[1].type->kind != C_TYPE_VECTOR) yy_error("second argument of __builtin_shufflevector() must be a vector"); if (args[0].type->vec.type->kind != args[1].type->vec.type->kind) yy_error("first and second arguments of __builtin_shufflevector() are vectors of different types"); len = num_args - 2; if (len > 64 || (len & (len - 1)) != 0) yy_error("unsupported numver of vector elments in __builtin_shufflevector()"); @@ -5236,13 +5275,17 @@ void c_do_builtin(rcc_ctx *rcc, c_value *val, c_name name, int32_t num_args, c_v } t = IR_MAKE_VECTOR_TYPE(c_type2ir(rcc, args[0].type->vec.type), len); - type = ir_arena_alloc(&rcc->c_arena, sizeof(c_type)); - type->size = IR_VECTOR_SIZE(t); - type->kind = C_TYPE_VECTOR; - type->flags = rcc->active_scope ? 0 : C_TYPE_GLOBAL; - type->attr = c_align2attr(IR_MIN(type->size, 16)); /* 16 byte allgnment */ - type->vec.type = args[0].type->vec.type; - type->vec.length = len; + if ((uint32_t)args[0].type->vec.length == len) { + type = (c_type*)args[0].type; + } else { + type = ir_arena_alloc(&rcc->c_arena, sizeof(c_type)); + type->size = IR_VECTOR_SIZE(t); + type->kind = C_TYPE_VECTOR; + type->flags = rcc->active_scope ? 0 : C_TYPE_GLOBAL; + type->attr = c_align2attr(IR_MIN(type->size, 16)); /* 16 byte allgnment */ + type->vec.type = args[0].type->vec.type; + type->vec.length = len; + } c_value_set_rval(val, type, t, ir_SHUFFLE(t, c_value_ref(rcc, &args[0]), c_value_ref(rcc, &args[1]), ref)); From fd6080b62fb4ffa41d68e48d4912e38d148e636d Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Tue, 7 Jul 2026 18:47:58 +0300 Subject: [PATCH 09/31] Add "--emit-c" options (just for verification) --- rcc.c | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/rcc.c b/rcc.c index 883270f..30bf539 100644 --- a/rcc.c +++ b/rcc.c @@ -73,6 +73,8 @@ #define C_DUMP_LIVE_RANGES (1<<25) +#define C_DUMP_C (1<<26) + #define C_SINGLE_FILE (1<<29) #define C_DO_LINK_INTERNAL (1<<30) #define C_DO_LINK_EXTERNAL (1U<<31) @@ -1502,6 +1504,74 @@ static void rcc_emit_llvm(rcc_ctx *rcc, FILE *f) } } +static void rcc_emit_c_proto(rcc_ctx *rcc, const char *name, c_sym *func, FILE *f) +{ + const c_type *t = func->value.type; + uint32_t flags; + ir_type ret_type; + uint32_t params_count; + uint8_t *param_types; + + IR_ASSERT(t->kind == C_TYPE_FUNC); + param_types = alloca(t->func.num_params + 16); + c_type2proto_ex(rcc, t, &flags, &ret_type, ¶ms_count, param_types); + if (func->linkage == C_LINK_INTERNAL) { + flags |= IR_STATIC; + } else if (func->linkage == C_LINK_BUILTIN) { + flags |= IR_CC_BUILTIN; + } + ir_emit_c_func_decl(name, flags, ret_type, params_count, param_types, f); +} + +static void rcc_emit_c(rcc_ctx *rcc, FILE *f) +{ + uint32_t i; + yy_hash_bucket *p; + + for (i = YY_LAST_KEYWORD + 1, p = rcc->yy_hash.data + i; i < rcc->yy_hash.count; p++, i++) { + if (p->sym && p->sym->kind == C_SYM_FUNC && !p->sym->ctx) { + if ((p->sym->is_external || !p->sym->ctx) && p->sym->alias) continue; + rcc_emit_c_proto(rcc, p->str, p->sym, f); + } + } + + for (i = YY_LAST_KEYWORD + 1, p = rcc->yy_hash.data + i; i < rcc->yy_hash.count; p++, i++) { + if (p->sym && p->sym->kind == C_SYM_VAR) { + uint32_t flags = 0; + const char *str; + + if (p->sym->linkage == C_LINK_INTERNAL) { + flags |= IR_STATIC; + } else if (p->sym->is_external || !c_value_is_set(&p->sym->value)) { + flags |= IR_EXTERN; + } + if (c_is_type_const(p->sym->value.type)) { + flags |= IR_CONST; + } + if (p->sym->alias) { + str = rcc->yy_hash.data[p->sym->alias].str; + } else { + str = p->str; + } + //TODO: type ??? + ir_emit_c_sym_decl(str, flags, f); + //TODO: initializer ??? + } + } + + for (i = YY_LAST_KEYWORD + 1, p = rcc->yy_hash.data + i; i < rcc->yy_hash.count; p++, i++) { + if (p->sym && p->sym->kind == C_SYM_FUNC && p->sym->ctx) { + ir_ctx *ctx = p->sym->ctx; + + if (!ctx->vregs) { + ir_assign_virtual_registers(ctx); + ir_compute_dessa_moves(ctx); + } + ir_emit_c(ctx, p->str, f); + } + } +} + static int rcc_preprocess(rcc_ctx *rcc, const char *file_name, FILE *f) { if (!rcc_read(rcc, file_name)) { @@ -1529,6 +1599,9 @@ static int rcc_compile(rcc_ctx *rcc, const char *file_name) if (rcc->c_flags & C_DUMP_LLVM) { rcc_emit_llvm(rcc, rcc->output); } + if (rcc->c_flags & C_DUMP_C) { + rcc_emit_c(rcc, rcc->output); + } if (ir_list_capasity(&rcc->codegen_queue)) { do { c_name name = ir_list_pop(&rcc->codegen_queue); @@ -2325,6 +2398,8 @@ int main(int argc, const char **argv) rcc->c_flags |= C_DUMP_IR; } else if (strcmp(argv[i], "--emit-llvm") == 0) { rcc->c_flags |= C_DUMP_LLVM; + } else if (strcmp(argv[i], "--emit-c") == 0) { + rcc->c_flags |= C_DUMP_C; } else if (strcmp(argv[i], "-S") == 0) { rcc->c_flags |= C_DUMP_ASM; } else if (strcmp(argv[i], "--dump-size") == 0) { From da55f6a7a24354e78100f74dc133759cda8b7b20 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Tue, 7 Jul 2026 22:28:04 +0300 Subject: [PATCH 10/31] Fix memory leaks --- rcc.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/rcc.c b/rcc.c index 30bf539..3e0749e 100644 --- a/rcc.c +++ b/rcc.c @@ -1562,12 +1562,18 @@ static void rcc_emit_c(rcc_ctx *rcc, FILE *f) for (i = YY_LAST_KEYWORD + 1, p = rcc->yy_hash.data + i; i < rcc->yy_hash.count; p++, i++) { if (p->sym && p->sym->kind == C_SYM_FUNC && p->sym->ctx) { ir_ctx *ctx = p->sym->ctx; + bool cleanup = 0; if (!ctx->vregs) { ir_assign_virtual_registers(ctx); ir_compute_dessa_moves(ctx); + cleanup = 1; } ir_emit_c(ctx, p->str, f); + if (cleanup) { + ir_mem_free(ctx->vregs); + ctx->vregs = NULL; + } } } } From 247016368ce51eb19930af7ee47e62f01b607054 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Tue, 7 Jul 2026 23:13:33 +0300 Subject: [PATCH 11/31] Vectors can't be used as boolean condition with "if", "&&", "||", "!" --- rcc_semantic.c | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/rcc_semantic.c b/rcc_semantic.c index 29b2fef..a5ffae0 100644 --- a/rcc_semantic.c +++ b/rcc_semantic.c @@ -4575,7 +4575,10 @@ void c_do_bool_not(rcc_ctx *rcc, c_value *v) ir_val val; c_value_rval(rcc, v); - if (v->type->kind == C_TYPE_VOID || v->type->kind == C_TYPE_STRUCT || v->type->kind == C_TYPE_UNION) { + if (v->type->kind == C_TYPE_VOID + || v->type->kind == C_TYPE_STRUCT + || v->type->kind == C_TYPE_UNION + || v->type->kind == C_TYPE_VECTOR) { yy_error("invalid type argument of unary \"!\""); } if (c_value_is_ref(v)) { @@ -7132,7 +7135,10 @@ static void c_ir_IF_FALSE(rcc_ctx *rcc, ir_ref ref) ir_ref c_do_bool_and_start(rcc_ctx *rcc, c_value *op1) { - if (op1->type->kind == C_TYPE_VOID || op1->type->kind == C_TYPE_STRUCT || op1->type->kind == C_TYPE_UNION) { + if (op1->type->kind == C_TYPE_VOID + || op1->type->kind == C_TYPE_STRUCT + || op1->type->kind == C_TYPE_UNION + || op1->type->kind == C_TYPE_VECTOR) { yy_error("scalar is required"); } if (c_value_is_const(op1)) { @@ -7149,7 +7155,10 @@ void c_do_bool_and_end(rcc_ctx *rcc, c_value *op1, c_value *op2, ir_ref if_ref) { ir_val val; - if (op2->type->kind == C_TYPE_VOID || op2->type->kind == C_TYPE_STRUCT || op2->type->kind == C_TYPE_UNION) { + if (op2->type->kind == C_TYPE_VOID + || op2->type->kind == C_TYPE_STRUCT + || op2->type->kind == C_TYPE_UNION + || op2->type->kind == C_TYPE_VECTOR) { yy_error("scalar is required"); } if (if_ref) { @@ -7176,7 +7185,10 @@ void c_do_bool_and_end(rcc_ctx *rcc, c_value *op1, c_value *op2, ir_ref if_ref) ir_ref c_do_bool_or_start(rcc_ctx *rcc, c_value *op1) { - if (op1->type->kind == C_TYPE_VOID || op1->type->kind == C_TYPE_STRUCT || op1->type->kind == C_TYPE_UNION) { + if (op1->type->kind == C_TYPE_VOID + || op1->type->kind == C_TYPE_STRUCT + || op1->type->kind == C_TYPE_UNION + || op1->type->kind == C_TYPE_VECTOR) { yy_error("scalar is required"); } if (c_value_is_const(op1)) { @@ -7193,7 +7205,10 @@ void c_do_bool_or_end(rcc_ctx *rcc, c_value *op1, c_value *op2, ir_ref if_ref) { ir_val val; - if (op2->type->kind == C_TYPE_VOID || op2->type->kind == C_TYPE_STRUCT || op2->type->kind == C_TYPE_UNION) { + if (op2->type->kind == C_TYPE_VOID + || op2->type->kind == C_TYPE_STRUCT + || op2->type->kind == C_TYPE_UNION + || op2->type->kind == C_TYPE_VECTOR) { yy_error("scalar is required"); } if (if_ref) { @@ -7317,7 +7332,10 @@ ir_ref c_do_if(rcc_ctx *rcc, c_value *cond) { ir_ref ref; - if (cond->type->kind == C_TYPE_VOID || cond->type->kind == C_TYPE_STRUCT || cond->type->kind == C_TYPE_UNION) { + if (cond->type->kind == C_TYPE_VOID + || cond->type->kind == C_TYPE_STRUCT + || cond->type->kind == C_TYPE_UNION + || cond->type->kind == C_TYPE_VECTOR) { yy_error("scalar is required"); } else if (C_IS_TYPE_FP(cond->type)) { ir_val val; @@ -7730,7 +7748,10 @@ void c_do_loop_check(rcc_ctx *rcc, c_loop *loop, c_value *cond) { ir_ref ref; - if (cond->type->kind == C_TYPE_VOID || cond->type->kind == C_TYPE_STRUCT || cond->type->kind == C_TYPE_UNION) { + if (cond->type->kind == C_TYPE_VOID + || cond->type->kind == C_TYPE_STRUCT + || cond->type->kind == C_TYPE_UNION + || cond->type->kind == C_TYPE_VECTOR) { yy_error("scalar is required"); } else if (C_IS_TYPE_FP(cond->type)) { ir_val val; From a42f52dd9062d2f49806882c694b49f72ffe3683 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Wed, 8 Jul 2026 08:37:19 +0300 Subject: [PATCH 12/31] Don't emit symbols for global register variables --- rcc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/rcc.c b/rcc.c index 3e0749e..bb5e20b 100644 --- a/rcc.c +++ b/rcc.c @@ -1400,7 +1400,9 @@ static void rcc_emit_ir(rcc_ctx *rcc, FILE *f) if (p->sym && p->sym->kind == C_SYM_VAR) { size_t size; - if (p->sym->linkage == C_LINK_INTERNAL) { + if (p->sym->linkage == C_LINK_NONE) { + continue; + } else if (p->sym->linkage == C_LINK_INTERNAL) { fprintf(f, "static "); } else if (p->sym->is_external || !c_value_is_set(&p->sym->value)) { if (p->sym->alias) continue; From 68aace9167493399206d8a09697a5152b772ea20 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Wed, 8 Jul 2026 15:56:45 +0300 Subject: [PATCH 13/31] Fix vectors handling --- rcc_semantic.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/rcc_semantic.c b/rcc_semantic.c index a5ffae0..ec985f1 100644 --- a/rcc_semantic.c +++ b/rcc_semantic.c @@ -4510,7 +4510,7 @@ void c_do_unary_plus(rcc_ctx *rcc, c_value *v) if (t->size < 4) { c_do_cvt(rcc, &c_type_i32, IR_I32, v); } - } else if (!C_IS_TYPE_FP(t)) { + } else if (!C_IS_TYPE_FP(t) && t->kind != C_TYPE_VECTOR) { yy_error("invalid type argument of unary \"+\""); } } @@ -6741,7 +6741,13 @@ static void c_do_shr(rcc_ctx *rcc, const c_type *type, c_value *op1, c_value *op } else { ir_type t = c_type2ir(rcc, type); - if (C_IS_TYPE_SIGNED(type)) { + if (type->kind == C_TYPE_VECTOR) { + if (C_IS_TYPE_SIGNED(type->vec.type)) { + c_value_set_rval(op1, type, t, ir_SAR(t, c_value_ref(rcc, op1), c_value_ref(rcc, op2))); + } else { + c_value_set_rval(op1, type, t, ir_SHR(t, c_value_ref(rcc, op1), c_value_ref(rcc, op2))); + } + } else if (C_IS_TYPE_SIGNED(type)) { c_value_set_rval(op1, type, t, ir_SAR(t, c_value_ref(rcc, op1), c_value_ref(rcc, op2))); } else { c_value_set_rval(op1, type, t, ir_SHR(t, c_value_ref(rcc, op1), c_value_ref(rcc, op2))); From 809e8d54dd97da4766b8623c3d5cebfccc7588d4 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Thu, 9 Jul 2026 11:56:09 +0300 Subject: [PATCH 14/31] Disallow "%", "|", "&", "^", "<<", ">>" for floating point vectors --- rcc_semantic.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/rcc_semantic.c b/rcc_semantic.c index ec985f1..6bbeafa 100644 --- a/rcc_semantic.c +++ b/rcc_semantic.c @@ -6232,6 +6232,12 @@ static const c_type *c_common_type(rcc_ctx *rcc, yy_sym sym, c_value *op1, c_val } return NULL; } else if (t1 == C_TYPE_VECTOR) { + if (C_IS_TYPE_FP(op1->type->vec.type)) { + if (sym == YY__PERCENT || sym == YY__AND || sym == YY__UPARROW || sym == YY__BAR + || sym == YY__LESS_LESS || sym == YY__GREATER_GREATER) { + return NULL; + } + } if (t2 == C_TYPE_VECTOR) { if (op1->type->size == op2->type->size) { if (op1->type->vec.type == op2->type->vec.type) { @@ -6244,6 +6250,12 @@ static const c_type *c_common_type(rcc_ctx *rcc, yy_sym sym, c_value *op1, c_val } } } else if (t2 == C_TYPE_VECTOR && C_IS_TYPE_KIND_SCALAR(t1)) { + if (C_IS_TYPE_FP(op2->type->vec.type)) { + if (sym == YY__PERCENT || sym == YY__AND || sym == YY__UPARROW || sym == YY__BAR + || sym == YY__LESS_LESS || sym == YY__GREATER_GREATER) { + return NULL; + } + } if (c_do_splat(rcc, op2->type, op1)) { return op2->type; } From 0c03019474309a8e437fd818fd030fb10f1e42ff Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Thu, 9 Jul 2026 20:59:43 +0300 Subject: [PATCH 15/31] Add "-m[no-]avx2" option --- rcc.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/rcc.c b/rcc.c index bb5e20b..c90e7b2 100644 --- a/rcc.c +++ b/rcc.c @@ -1942,6 +1942,7 @@ static void rcc_help(const char *cmd) " -m[no-]sse4 - enable/disable SSE4 instruction set\n" " -m[no-]sse4.1 - enable/disable SSE4.1 instruction set\n" " -m[no-]sse4.2 - enable/disable SSE4.2 instruction set\n" + " -m[no-]avx2 - enable/disable AVX2 instruction set\n" #endif " -muse-fp - use base frame pointer register\n" #if defined(IR_TARGET_X86) @@ -2181,6 +2182,12 @@ static int rcc_parse_option(rcc_ctx *rcc, const char *opt, const char *arg, bool } else if (strcmp(opt, "-mno-sse4.2") == 0) { rcc->ir_mflags &= ~IR_X86_SSE42; rcc->ir_mflags_disabled |= IR_X86_SSE42; + } else if (strcmp(opt, "-mavx2") == 0) { + rcc->ir_mflags |= IR_X86_AVX2; + rcc->ir_mflags_disabled &= ~IR_X86_AVX2; + } else if (strcmp(opt, "-mno-avx2") == 0) { + rcc->ir_mflags &= ~IR_X86_AVX2; + rcc->ir_mflags_disabled |= IR_X86_AVX2; #endif } else if (strcmp(opt, "-muse-fp") == 0) { rcc->ir_flags |= IR_USE_FRAME_POINTER; @@ -2571,7 +2578,7 @@ int main(int argc, const char **argv) return 1; } } - rcc->ir_mflags |= (cpuinfo & (IR_X86_SSE3|IR_X86_SSSE3|IR_X86_SSE41|IR_X86_SSE42|IR_X86_BMI1)) & ~rcc->ir_mflags_disabled; + rcc->ir_mflags |= (cpuinfo & (IR_X86_SSE3|IR_X86_SSSE3|IR_X86_SSE41|IR_X86_SSE42|IR_X86_AVX2|IR_X86_BMI1)) & ~rcc->ir_mflags_disabled; #endif } From e81dbbcf2e6a61fca77ffee5dac1cee8366a4113 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Fri, 10 Jul 2026 10:58:02 +0300 Subject: [PATCH 16/31] Fix empty vector initialzation "t v = {};" --- rcc_semantic.c | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/rcc_semantic.c b/rcc_semantic.c index 6bbeafa..30d42e2 100644 --- a/rcc_semantic.c +++ b/rcc_semantic.c @@ -8699,6 +8699,22 @@ void c_do_init_start(rcc_ctx *rcc, c_sym *obj, c_init *init) init->stack[0].type = type; init->stack[0].pos = 0; init->stack[0].last = 0; + + if (type->kind == C_TYPE_VECTOR + && !c_value_is_const(&obj->value) && !(c_value_is_ref(&obj->value) && IR_IS_CONST_REF(obj->value.u.ref))) { + ir_val v; + ir_ref ref; + + v.u64 = 0; + ref = ir_SPLAT(c_type2ir(rcc, type), ir_const(rcc->active_ctx, v, c_type2ir(rcc, type->vec.type))); + + if (rcc->active_ctx->ir_base[obj->value.u.ref].op == IR_VAR) { + ir_VSTORE(obj->value.u.ref, ref); + } else { + IR_ASSERT(rcc->active_ctx->ir_base[obj->value.u.ref].op == IR_ALLOCA); + ir_STORE(obj->value.u.ref, ref); + } + } } void c_do_init_dim(rcc_ctx *rcc, c_sym *obj, c_init *init, c_value *dim) @@ -9120,13 +9136,7 @@ void c_do_init_set(rcc_ctx *rcc, c_sym *obj, c_init *init, c_value *val) offset -= t->vec.type->size * init->stack[init->level].pos; IR_ASSERT(offset == 0); - if (init->stack[init->level].pos == 0) { - ir_val v; - v.u64 = 0; - ref = ir_SPLAT(vt, ir_const(rcc->active_ctx, v, c_type2ir(rcc, t->vec.type))); - } else { - ref = ir_VLOAD(vt, obj->value.u.ref); - } + ref = ir_VLOAD(vt, obj->value.u.ref); ref = ir_REPLACE(vt, ref, ir_const_u8(rcc->active_ctx, init->stack[init->level].pos), c_value_ref(rcc, val)); ir_VSTORE(obj->value.u.ref, ref); @@ -9145,13 +9155,7 @@ void c_do_init_set(rcc_ctx *rcc, c_sym *obj, c_init *init, c_value *val) ir_ref ref; offset -= t->vec.type->size * init->stack[init->level].pos; - if (init->stack[init->level].pos == 0) { - ir_val v; - v.u64 = 0; - ref = ir_SPLAT(vt, ir_const(rcc->active_ctx, v, c_type2ir(rcc, t->vec.type))); - } else { - ref = ir_LOAD(vt, ir_ADD_A(obj->value.u.ref, ir_const_size_t(rcc->active_ctx, offset))); - } + ref = ir_LOAD(vt, ir_ADD_A(obj->value.u.ref, ir_const_size_t(rcc->active_ctx, offset))); ref = ir_REPLACE(vt, ref, ir_const_u8(rcc->active_ctx, init->stack[init->level].pos), c_value_ref(rcc, val)); ir_STORE( From ec51e5d157a65126d07c346ad76277650f12d6ad Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Fri, 10 Jul 2026 12:39:43 +0300 Subject: [PATCH 17/31] Add tests for x86 SIMD vector instructions --- tests/vector/add-001.test | 167 ++++++++++++++++++++++++++++++++++ tests/vector/add-002.test | 167 ++++++++++++++++++++++++++++++++++ tests/vector/add-003.test | 167 ++++++++++++++++++++++++++++++++++ tests/vector/add-004.test | 167 ++++++++++++++++++++++++++++++++++ tests/vector/add-005.test | 167 ++++++++++++++++++++++++++++++++++ tests/vector/add-006.test | 167 ++++++++++++++++++++++++++++++++++ tests/vector/add-007.test | 167 ++++++++++++++++++++++++++++++++++ tests/vector/add-008.test | 167 ++++++++++++++++++++++++++++++++++ tests/vector/add-009.test | 167 ++++++++++++++++++++++++++++++++++ tests/vector/add-010.test | 167 ++++++++++++++++++++++++++++++++++ tests/vector/neg-001.test | 167 ++++++++++++++++++++++++++++++++++ tests/vector/neg-002.test | 167 ++++++++++++++++++++++++++++++++++ tests/vector/neg-003.test | 167 ++++++++++++++++++++++++++++++++++ tests/vector/neg-004.test | 167 ++++++++++++++++++++++++++++++++++ tests/vector/neg-005.test | 167 ++++++++++++++++++++++++++++++++++ tests/vector/neg-006.test | 167 ++++++++++++++++++++++++++++++++++ tests/vector/not-001.test | 139 ++++++++++++++++++++++++++++ tests/vector/not-002.test | 139 ++++++++++++++++++++++++++++ tests/vector/not-003.test | 139 ++++++++++++++++++++++++++++ tests/vector/not-004.test | 139 ++++++++++++++++++++++++++++ tests/vector/not-005.test | 139 ++++++++++++++++++++++++++++ tests/vector/not-006.test | 139 ++++++++++++++++++++++++++++ tests/vector/or-001.test | 139 ++++++++++++++++++++++++++++ tests/vector/or-002.test | 139 ++++++++++++++++++++++++++++ tests/vector/or-003.test | 139 ++++++++++++++++++++++++++++ tests/vector/or-004.test | 139 ++++++++++++++++++++++++++++ tests/vector/or-005.test | 139 ++++++++++++++++++++++++++++ tests/vector/or-006.test | 139 ++++++++++++++++++++++++++++ tests/vector/replace-001.test | 167 ++++++++++++++++++++++++++++++++++ tests/vector/replace-002.test | 167 ++++++++++++++++++++++++++++++++++ tests/vector/replace-003.test | 167 ++++++++++++++++++++++++++++++++++ tests/vector/replace-004.test | 167 ++++++++++++++++++++++++++++++++++ tests/vector/replace-005.test | 167 ++++++++++++++++++++++++++++++++++ tests/vector/replace-006.test | 167 ++++++++++++++++++++++++++++++++++ tests/vector/replace-007.test | 167 ++++++++++++++++++++++++++++++++++ tests/vector/replace-008.test | 167 ++++++++++++++++++++++++++++++++++ tests/vector/replace-009.test | 167 ++++++++++++++++++++++++++++++++++ tests/vector/replace-010.test | 167 ++++++++++++++++++++++++++++++++++ tests/vector/replace-011.test | 166 +++++++++++++++++++++++++++++++++ tests/vector/replace-012.test | 166 +++++++++++++++++++++++++++++++++ 40 files changed, 6342 insertions(+) create mode 100644 tests/vector/add-001.test create mode 100644 tests/vector/add-002.test create mode 100644 tests/vector/add-003.test create mode 100644 tests/vector/add-004.test create mode 100644 tests/vector/add-005.test create mode 100644 tests/vector/add-006.test create mode 100644 tests/vector/add-007.test create mode 100644 tests/vector/add-008.test create mode 100644 tests/vector/add-009.test create mode 100644 tests/vector/add-010.test create mode 100644 tests/vector/neg-001.test create mode 100644 tests/vector/neg-002.test create mode 100644 tests/vector/neg-003.test create mode 100644 tests/vector/neg-004.test create mode 100644 tests/vector/neg-005.test create mode 100644 tests/vector/neg-006.test create mode 100644 tests/vector/not-001.test create mode 100644 tests/vector/not-002.test create mode 100644 tests/vector/not-003.test create mode 100644 tests/vector/not-004.test create mode 100644 tests/vector/not-005.test create mode 100644 tests/vector/not-006.test create mode 100644 tests/vector/or-001.test create mode 100644 tests/vector/or-002.test create mode 100644 tests/vector/or-003.test create mode 100644 tests/vector/or-004.test create mode 100644 tests/vector/or-005.test create mode 100644 tests/vector/or-006.test create mode 100644 tests/vector/replace-001.test create mode 100644 tests/vector/replace-002.test create mode 100644 tests/vector/replace-003.test create mode 100644 tests/vector/replace-004.test create mode 100644 tests/vector/replace-005.test create mode 100644 tests/vector/replace-006.test create mode 100644 tests/vector/replace-007.test create mode 100644 tests/vector/replace-008.test create mode 100644 tests/vector/replace-009.test create mode 100644 tests/vector/replace-010.test create mode 100644 tests/vector/replace-011.test create mode 100644 tests/vector/replace-012.test diff --git a/tests/vector/add-001.test b/tests/vector/add-001.test new file mode 100644 index 0000000..ed1cb4e --- /dev/null +++ b/tests/vector/add-001.test @@ -0,0 +1,167 @@ +--TEST-- +ADD.001: 128-bit vectors SSE2 +--TARGET-- +!aarch64 +--ARGS-- +-mno-sse4 -mno-avx2 --run +--CODE-- +#define N 16 +#define I 1 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef double __attribute__((__vector_size__(N))) v_d; +typedef float __attribute__((__vector_size__(N))) v_f; +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_d __attribute__((noinline)) test_v_d(v_d v, double x) +{ + v += x; + return v; +} + +v_f __attribute__((noinline)) test_v_f(v_f v, float x) +{ + v += x; + return v; +} + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x) +{ + v += x; + return v; +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x) +{ + v += x; + return v; +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x) +{ + v += x; + return v; +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x) +{ + v += x; + return v; +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x) +{ + v += x; + return v; +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x) +{ + v += x; + return v; +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x) +{ + v += x; + return v; +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x) +{ + v += x; + return v; +} + +int main() +{ + { + v_d x = {}; + x = test_v_d(x, 42.42); + printf("%g\n", x[I]); + } + + { + v_f x = {}; + x = test_v_f(x, 42.42); + printf("%g\n", x[I]); + } + + { + v_i64 x = {}; + x = test_v_i64(x, 42); + printf("%lld\n", x[I]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42); + printf("%lld\n", x[I]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42); + printf("%d\n", x[I]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42); + printf("%d\n", x[I]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42); + printf("%d\n", x[I]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42); + printf("%d\n", x[I]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42); + printf("%d\n", x[I]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42); + printf("%d\n", x[I]); + } + + return 0; +} +--EXPECT-- +42.42 +42.42 +42 +42 +42 +42 +42 +42 +42 +42 diff --git a/tests/vector/add-002.test b/tests/vector/add-002.test new file mode 100644 index 0000000..6a995b2 --- /dev/null +++ b/tests/vector/add-002.test @@ -0,0 +1,167 @@ +--TEST-- +ADD.002: 128-bit vectors SSE2+SSE4 +--TARGET-- +!aarch64 +--ARGS-- +-mno-avx2 --run +--CODE-- +#define N 16 +#define I 1 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef double __attribute__((__vector_size__(N))) v_d; +typedef float __attribute__((__vector_size__(N))) v_f; +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_d __attribute__((noinline)) test_v_d(v_d v, double x) +{ + v += x; + return v; +} + +v_f __attribute__((noinline)) test_v_f(v_f v, float x) +{ + v += x; + return v; +} + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x) +{ + v += x; + return v; +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x) +{ + v += x; + return v; +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x) +{ + v += x; + return v; +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x) +{ + v += x; + return v; +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x) +{ + v += x; + return v; +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x) +{ + v += x; + return v; +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x) +{ + v += x; + return v; +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x) +{ + v += x; + return v; +} + +int main() +{ + { + v_d x = {}; + x = test_v_d(x, 42.42); + printf("%g\n", x[I]); + } + + { + v_f x = {}; + x = test_v_f(x, 42.42); + printf("%g\n", x[I]); + } + + { + v_i64 x = {}; + x = test_v_i64(x, 42); + printf("%lld\n", x[I]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42); + printf("%lld\n", x[I]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42); + printf("%d\n", x[I]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42); + printf("%d\n", x[I]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42); + printf("%d\n", x[I]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42); + printf("%d\n", x[I]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42); + printf("%d\n", x[I]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42); + printf("%d\n", x[I]); + } + + return 0; +} +--EXPECT-- +42.42 +42.42 +42 +42 +42 +42 +42 +42 +42 +42 diff --git a/tests/vector/add-003.test b/tests/vector/add-003.test new file mode 100644 index 0000000..8c1bc33 --- /dev/null +++ b/tests/vector/add-003.test @@ -0,0 +1,167 @@ +--TEST-- +ADD.003: 128-bit vectors AVX +--TARGET-- +!aarch64 +--ARGS-- +-mavx -mno-avx2 --run +--CODE-- +#define N 16 +#define I 1 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef double __attribute__((__vector_size__(N))) v_d; +typedef float __attribute__((__vector_size__(N))) v_f; +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_d __attribute__((noinline)) test_v_d(v_d v, double x) +{ + v += x; + return v; +} + +v_f __attribute__((noinline)) test_v_f(v_f v, float x) +{ + v += x; + return v; +} + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x) +{ + v += x; + return v; +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x) +{ + v += x; + return v; +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x) +{ + v += x; + return v; +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x) +{ + v += x; + return v; +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x) +{ + v += x; + return v; +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x) +{ + v += x; + return v; +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x) +{ + v += x; + return v; +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x) +{ + v += x; + return v; +} + +int main() +{ + { + v_d x = {}; + x = test_v_d(x, 42.42); + printf("%g\n", x[I]); + } + + { + v_f x = {}; + x = test_v_f(x, 42.42); + printf("%g\n", x[I]); + } + + { + v_i64 x = {}; + x = test_v_i64(x, 42); + printf("%lld\n", x[I]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42); + printf("%lld\n", x[I]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42); + printf("%d\n", x[I]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42); + printf("%d\n", x[I]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42); + printf("%d\n", x[I]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42); + printf("%d\n", x[I]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42); + printf("%d\n", x[I]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42); + printf("%d\n", x[I]); + } + + return 0; +} +--EXPECT-- +42.42 +42.42 +42 +42 +42 +42 +42 +42 +42 +42 diff --git a/tests/vector/add-004.test b/tests/vector/add-004.test new file mode 100644 index 0000000..97468ec --- /dev/null +++ b/tests/vector/add-004.test @@ -0,0 +1,167 @@ +--TEST-- +ADD.004: 128-bit vectors AVX+AVX2 +--TARGET-- +!aarch64 +--ARGS-- +-mavx --run +--CODE-- +#define N 16 +#define I 1 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef double __attribute__((__vector_size__(N))) v_d; +typedef float __attribute__((__vector_size__(N))) v_f; +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_d __attribute__((noinline)) test_v_d(v_d v, double x) +{ + v += x; + return v; +} + +v_f __attribute__((noinline)) test_v_f(v_f v, float x) +{ + v += x; + return v; +} + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x) +{ + v += x; + return v; +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x) +{ + v += x; + return v; +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x) +{ + v += x; + return v; +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x) +{ + v += x; + return v; +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x) +{ + v += x; + return v; +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x) +{ + v += x; + return v; +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x) +{ + v += x; + return v; +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x) +{ + v += x; + return v; +} + +int main() +{ + { + v_d x = {}; + x = test_v_d(x, 42.42); + printf("%g\n", x[I]); + } + + { + v_f x = {}; + x = test_v_f(x, 42.42); + printf("%g\n", x[I]); + } + + { + v_i64 x = {}; + x = test_v_i64(x, 42); + printf("%lld\n", x[I]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42); + printf("%lld\n", x[I]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42); + printf("%d\n", x[I]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42); + printf("%d\n", x[I]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42); + printf("%d\n", x[I]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42); + printf("%d\n", x[I]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42); + printf("%d\n", x[I]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42); + printf("%d\n", x[I]); + } + + return 0; +} +--EXPECT-- +42.42 +42.42 +42 +42 +42 +42 +42 +42 +42 +42 diff --git a/tests/vector/add-005.test b/tests/vector/add-005.test new file mode 100644 index 0000000..e7fe1d1 --- /dev/null +++ b/tests/vector/add-005.test @@ -0,0 +1,167 @@ +--TEST-- +ADD.005: 64-bit vectors SSE2 +--TARGET-- +!aarch64 +--ARGS-- +-mno-sse4 -mno-avx2 --run +--CODE-- +#define N 8 +#define I 0 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef double __attribute__((__vector_size__(N))) v_d; +typedef float __attribute__((__vector_size__(N))) v_f; +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_d __attribute__((noinline)) test_v_d(v_d v, double x) +{ + v += x; + return v; +} + +v_f __attribute__((noinline)) test_v_f(v_f v, float x) +{ + v += x; + return v; +} + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x) +{ + v += x; + return v; +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x) +{ + v += x; + return v; +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x) +{ + v += x; + return v; +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x) +{ + v += x; + return v; +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x) +{ + v += x; + return v; +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x) +{ + v += x; + return v; +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x) +{ + v += x; + return v; +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x) +{ + v += x; + return v; +} + +int main() +{ + { + v_d x = {}; + x = test_v_d(x, 42.42); + printf("%g\n", x[I]); + } + + { + v_f x = {}; + x = test_v_f(x, 42.42); + printf("%g\n", x[I]); + } + + { + v_i64 x = {}; + x = test_v_i64(x, 42); + printf("%lld\n", x[I]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42); + printf("%lld\n", x[I]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42); + printf("%d\n", x[I]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42); + printf("%d\n", x[I]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42); + printf("%d\n", x[I]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42); + printf("%d\n", x[I]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42); + printf("%d\n", x[I]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42); + printf("%d\n", x[I]); + } + + return 0; +} +--EXPECT-- +42.42 +42.42 +42 +42 +42 +42 +42 +42 +42 +42 diff --git a/tests/vector/add-006.test b/tests/vector/add-006.test new file mode 100644 index 0000000..c138b37 --- /dev/null +++ b/tests/vector/add-006.test @@ -0,0 +1,167 @@ +--TEST-- +ADD.006: 64-bit vectors SSE2+SSE4 +--TARGET-- +!aarch64 +--ARGS-- +-mno-avx2 --run +--CODE-- +#define N 8 +#define I 0 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef double __attribute__((__vector_size__(N))) v_d; +typedef float __attribute__((__vector_size__(N))) v_f; +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_d __attribute__((noinline)) test_v_d(v_d v, double x) +{ + v += x; + return v; +} + +v_f __attribute__((noinline)) test_v_f(v_f v, float x) +{ + v += x; + return v; +} + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x) +{ + v += x; + return v; +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x) +{ + v += x; + return v; +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x) +{ + v += x; + return v; +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x) +{ + v += x; + return v; +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x) +{ + v += x; + return v; +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x) +{ + v += x; + return v; +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x) +{ + v += x; + return v; +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x) +{ + v += x; + return v; +} + +int main() +{ + { + v_d x = {}; + x = test_v_d(x, 42.42); + printf("%g\n", x[I]); + } + + { + v_f x = {}; + x = test_v_f(x, 42.42); + printf("%g\n", x[I]); + } + + { + v_i64 x = {}; + x = test_v_i64(x, 42); + printf("%lld\n", x[I]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42); + printf("%lld\n", x[I]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42); + printf("%d\n", x[I]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42); + printf("%d\n", x[I]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42); + printf("%d\n", x[I]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42); + printf("%d\n", x[I]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42); + printf("%d\n", x[I]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42); + printf("%d\n", x[I]); + } + + return 0; +} +--EXPECT-- +42.42 +42.42 +42 +42 +42 +42 +42 +42 +42 +42 diff --git a/tests/vector/add-007.test b/tests/vector/add-007.test new file mode 100644 index 0000000..000cca0 --- /dev/null +++ b/tests/vector/add-007.test @@ -0,0 +1,167 @@ +--TEST-- +ADD.007: 64-bit vectors AVX +--TARGET-- +!aarch64 +--ARGS-- +-mavx -mno-avx2 --run +--CODE-- +#define N 8 +#define I 0 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef double __attribute__((__vector_size__(N))) v_d; +typedef float __attribute__((__vector_size__(N))) v_f; +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_d __attribute__((noinline)) test_v_d(v_d v, double x) +{ + v += x; + return v; +} + +v_f __attribute__((noinline)) test_v_f(v_f v, float x) +{ + v += x; + return v; +} + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x) +{ + v += x; + return v; +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x) +{ + v += x; + return v; +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x) +{ + v += x; + return v; +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x) +{ + v += x; + return v; +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x) +{ + v += x; + return v; +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x) +{ + v += x; + return v; +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x) +{ + v += x; + return v; +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x) +{ + v += x; + return v; +} + +int main() +{ + { + v_d x = {}; + x = test_v_d(x, 42.42); + printf("%g\n", x[I]); + } + + { + v_f x = {}; + x = test_v_f(x, 42.42); + printf("%g\n", x[I]); + } + + { + v_i64 x = {}; + x = test_v_i64(x, 42); + printf("%lld\n", x[I]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42); + printf("%lld\n", x[I]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42); + printf("%d\n", x[I]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42); + printf("%d\n", x[I]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42); + printf("%d\n", x[I]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42); + printf("%d\n", x[I]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42); + printf("%d\n", x[I]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42); + printf("%d\n", x[I]); + } + + return 0; +} +--EXPECT-- +42.42 +42.42 +42 +42 +42 +42 +42 +42 +42 +42 diff --git a/tests/vector/add-008.test b/tests/vector/add-008.test new file mode 100644 index 0000000..7334708 --- /dev/null +++ b/tests/vector/add-008.test @@ -0,0 +1,167 @@ +--TEST-- +ADD.008: 64-bit vectors AVX+AVX2 +--TARGET-- +!aarch64 +--ARGS-- +-mavx --run +--CODE-- +#define N 8 +#define I 0 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef double __attribute__((__vector_size__(N))) v_d; +typedef float __attribute__((__vector_size__(N))) v_f; +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_d __attribute__((noinline)) test_v_d(v_d v, double x) +{ + v += x; + return v; +} + +v_f __attribute__((noinline)) test_v_f(v_f v, float x) +{ + v += x; + return v; +} + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x) +{ + v += x; + return v; +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x) +{ + v += x; + return v; +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x) +{ + v += x; + return v; +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x) +{ + v += x; + return v; +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x) +{ + v += x; + return v; +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x) +{ + v += x; + return v; +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x) +{ + v += x; + return v; +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x) +{ + v += x; + return v; +} + +int main() +{ + { + v_d x = {}; + x = test_v_d(x, 42.42); + printf("%g\n", x[I]); + } + + { + v_f x = {}; + x = test_v_f(x, 42.42); + printf("%g\n", x[I]); + } + + { + v_i64 x = {}; + x = test_v_i64(x, 42); + printf("%lld\n", x[I]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42); + printf("%lld\n", x[I]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42); + printf("%d\n", x[I]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42); + printf("%d\n", x[I]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42); + printf("%d\n", x[I]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42); + printf("%d\n", x[I]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42); + printf("%d\n", x[I]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42); + printf("%d\n", x[I]); + } + + return 0; +} +--EXPECT-- +42.42 +42.42 +42 +42 +42 +42 +42 +42 +42 +42 diff --git a/tests/vector/add-009.test b/tests/vector/add-009.test new file mode 100644 index 0000000..9583329 --- /dev/null +++ b/tests/vector/add-009.test @@ -0,0 +1,167 @@ +--TEST-- +ADD.009: 256-bit vectors AVX +--TARGET-- +!aarch64 +--ARGS-- +-mavx -mno-avx2 --run +--CODE-- +#define N 32 +#define I 3 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef double __attribute__((__vector_size__(N))) v_d; +typedef float __attribute__((__vector_size__(N))) v_f; +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_d __attribute__((noinline)) test_v_d(v_d v, double x) +{ + v += x; + return v; +} + +v_f __attribute__((noinline)) test_v_f(v_f v, float x) +{ + v += x; + return v; +} + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x) +{ + v += x; + return v; +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x) +{ + v += x; + return v; +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x) +{ + v += x; + return v; +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x) +{ + v += x; + return v; +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x) +{ + v += x; + return v; +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x) +{ + v += x; + return v; +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x) +{ + v += x; + return v; +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x) +{ + v += x; + return v; +} + +int main() +{ + { + v_d x = {}; + x = test_v_d(x, 42.42); + printf("%g\n", x[I]); + } + + { + v_f x = {}; + x = test_v_f(x, 42.42); + printf("%g\n", x[I]); + } + + { + v_i64 x = {}; + x = test_v_i64(x, 42); + printf("%lld\n", x[I]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42); + printf("%lld\n", x[I]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42); + printf("%d\n", x[I]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42); + printf("%d\n", x[I]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42); + printf("%d\n", x[I]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42); + printf("%d\n", x[I]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42); + printf("%d\n", x[I]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42); + printf("%d\n", x[I]); + } + + return 0; +} +--EXPECT-- +42.42 +42.42 +42 +42 +42 +42 +42 +42 +42 +42 diff --git a/tests/vector/add-010.test b/tests/vector/add-010.test new file mode 100644 index 0000000..8e6d574 --- /dev/null +++ b/tests/vector/add-010.test @@ -0,0 +1,167 @@ +--TEST-- +ADD.010: 256-bit vectors AVX+AVX2 +--TARGET-- +!aarch64 +--ARGS-- +-mavx --run +--CODE-- +#define N 32 +#define I 3 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef double __attribute__((__vector_size__(N))) v_d; +typedef float __attribute__((__vector_size__(N))) v_f; +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_d __attribute__((noinline)) test_v_d(v_d v, double x) +{ + v += x; + return v; +} + +v_f __attribute__((noinline)) test_v_f(v_f v, float x) +{ + v += x; + return v; +} + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x) +{ + v += x; + return v; +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x) +{ + v += x; + return v; +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x) +{ + v += x; + return v; +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x) +{ + v += x; + return v; +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x) +{ + v += x; + return v; +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x) +{ + v += x; + return v; +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x) +{ + v += x; + return v; +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x) +{ + v += x; + return v; +} + +int main() +{ + { + v_d x = {}; + x = test_v_d(x, 42.42); + printf("%g\n", x[I]); + } + + { + v_f x = {}; + x = test_v_f(x, 42.42); + printf("%g\n", x[I]); + } + + { + v_i64 x = {}; + x = test_v_i64(x, 42); + printf("%lld\n", x[I]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42); + printf("%lld\n", x[I]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42); + printf("%d\n", x[I]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42); + printf("%d\n", x[I]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42); + printf("%d\n", x[I]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42); + printf("%d\n", x[I]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42); + printf("%d\n", x[I]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42); + printf("%d\n", x[I]); + } + + return 0; +} +--EXPECT-- +42.42 +42.42 +42 +42 +42 +42 +42 +42 +42 +42 diff --git a/tests/vector/neg-001.test b/tests/vector/neg-001.test new file mode 100644 index 0000000..e1b594e --- /dev/null +++ b/tests/vector/neg-001.test @@ -0,0 +1,167 @@ +--TEST-- +NEG.001: 128-bit vectors SSE2 +--TARGET-- +!aarch64 +--ARGS-- +-mno-sse4 -mno-avx2 --run +--CODE-- +#define N 16 +#define I 1 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef double __attribute__((__vector_size__(N))) v_d; +typedef float __attribute__((__vector_size__(N))) v_f; +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_d __attribute__((noinline)) test_v_d(v_d v, double x) +{ + v[I] = x; + return -v; +} + +v_f __attribute__((noinline)) test_v_f(v_f v, float x) +{ + v[I] = x; + return -v; +} + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x) +{ + v[I] = x; + return -v; +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x) +{ + v[I] = x; + return -v; +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x) +{ + v[I] = x; + return -v; +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x) +{ + v[I] = x; + return -v; +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x) +{ + v[I] = x; + return -v; +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x) +{ + v[I] = x; + return -v; +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x) +{ + v[I] = x; + return -v; +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x) +{ + v[I] = x; + return -v; +} + +int main() +{ + { + v_d x = {}; + x = test_v_d(x, 42.42); + printf("%g\n", -x[I]); + } + + { + v_f x = {}; + x = test_v_f(x, 42.42); + printf("%g\n", -x[I]); + } + + { + v_i64 x = {}; + x = test_v_i64(x, 42); + printf("%lld\n", -x[I]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42); + printf("%lld\n", -x[I]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42); + printf("%d\n", -x[I]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42); + printf("%d\n", -x[I]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42); + printf("%d\n", -x[I]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42); + printf("%d\n", -(i16)x[I]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42); + printf("%d\n", -x[I]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42); + printf("%d\n", -(i8)x[I]); + } + + return 0; +} +--EXPECT-- +42.42 +42.42 +42 +42 +42 +42 +42 +42 +42 +42 diff --git a/tests/vector/neg-002.test b/tests/vector/neg-002.test new file mode 100644 index 0000000..1a9baac --- /dev/null +++ b/tests/vector/neg-002.test @@ -0,0 +1,167 @@ +--TEST-- +NEG.002: 128-bit vectors SSE2+SSE4 +--TARGET-- +!aarch64 +--ARGS-- +-mno-avx2 --run +--CODE-- +#define N 16 +#define I 1 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef double __attribute__((__vector_size__(N))) v_d; +typedef float __attribute__((__vector_size__(N))) v_f; +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_d __attribute__((noinline)) test_v_d(v_d v, double x) +{ + v[I] = x; + return -v; +} + +v_f __attribute__((noinline)) test_v_f(v_f v, float x) +{ + v[I] = x; + return -v; +} + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x) +{ + v[I] = x; + return -v; +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x) +{ + v[I] = x; + return -v; +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x) +{ + v[I] = x; + return -v; +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x) +{ + v[I] = x; + return -v; +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x) +{ + v[I] = x; + return -v; +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x) +{ + v[I] = x; + return -v; +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x) +{ + v[I] = x; + return -v; +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x) +{ + v[I] = x; + return -v; +} + +int main() +{ + { + v_d x = {}; + x = test_v_d(x, 42.42); + printf("%g\n", -x[I]); + } + + { + v_f x = {}; + x = test_v_f(x, 42.42); + printf("%g\n", -x[I]); + } + + { + v_i64 x = {}; + x = test_v_i64(x, 42); + printf("%lld\n", -x[I]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42); + printf("%lld\n", -x[I]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42); + printf("%d\n", -x[I]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42); + printf("%d\n", -x[I]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42); + printf("%d\n", -x[I]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42); + printf("%d\n", -(i16)x[I]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42); + printf("%d\n", -x[I]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42); + printf("%d\n", -(i8)x[I]); + } + + return 0; +} +--EXPECT-- +42.42 +42.42 +42 +42 +42 +42 +42 +42 +42 +42 diff --git a/tests/vector/neg-003.test b/tests/vector/neg-003.test new file mode 100644 index 0000000..98520cd --- /dev/null +++ b/tests/vector/neg-003.test @@ -0,0 +1,167 @@ +--TEST-- +NEG.003: 128-bit vectors AVX +--TARGET-- +!aarch64 +--ARGS-- +-mavx -mno-avx2 --run +--CODE-- +#define N 16 +#define I 1 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef double __attribute__((__vector_size__(N))) v_d; +typedef float __attribute__((__vector_size__(N))) v_f; +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_d __attribute__((noinline)) test_v_d(v_d v, double x) +{ + v[I] = x; + return -v; +} + +v_f __attribute__((noinline)) test_v_f(v_f v, float x) +{ + v[I] = x; + return -v; +} + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x) +{ + v[I] = x; + return -v; +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x) +{ + v[I] = x; + return -v; +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x) +{ + v[I] = x; + return -v; +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x) +{ + v[I] = x; + return -v; +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x) +{ + v[I] = x; + return -v; +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x) +{ + v[I] = x; + return -v; +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x) +{ + v[I] = x; + return -v; +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x) +{ + v[I] = x; + return -v; +} + +int main() +{ + { + v_d x = {}; + x = test_v_d(x, 42.42); + printf("%g\n", -x[I]); + } + + { + v_f x = {}; + x = test_v_f(x, 42.42); + printf("%g\n", -x[I]); + } + + { + v_i64 x = {}; + x = test_v_i64(x, 42); + printf("%lld\n", -x[I]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42); + printf("%lld\n", -x[I]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42); + printf("%d\n", -x[I]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42); + printf("%d\n", -x[I]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42); + printf("%d\n", -x[I]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42); + printf("%d\n", -(i16)x[I]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42); + printf("%d\n", -x[I]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42); + printf("%d\n", -(i8)x[I]); + } + + return 0; +} +--EXPECT-- +42.42 +42.42 +42 +42 +42 +42 +42 +42 +42 +42 diff --git a/tests/vector/neg-004.test b/tests/vector/neg-004.test new file mode 100644 index 0000000..cdaf0a0 --- /dev/null +++ b/tests/vector/neg-004.test @@ -0,0 +1,167 @@ +--TEST-- +NEG.004: 128-bit vectors AVX+AVX2 +--TARGET-- +!aarch64 +--ARGS-- +-mavx -mno-avx2 --run +--CODE-- +#define N 16 +#define I 1 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef double __attribute__((__vector_size__(N))) v_d; +typedef float __attribute__((__vector_size__(N))) v_f; +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_d __attribute__((noinline)) test_v_d(v_d v, double x) +{ + v[I] = x; + return -v; +} + +v_f __attribute__((noinline)) test_v_f(v_f v, float x) +{ + v[I] = x; + return -v; +} + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x) +{ + v[I] = x; + return -v; +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x) +{ + v[I] = x; + return -v; +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x) +{ + v[I] = x; + return -v; +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x) +{ + v[I] = x; + return -v; +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x) +{ + v[I] = x; + return -v; +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x) +{ + v[I] = x; + return -v; +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x) +{ + v[I] = x; + return -v; +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x) +{ + v[I] = x; + return -v; +} + +int main() +{ + { + v_d x = {}; + x = test_v_d(x, 42.42); + printf("%g\n", -x[I]); + } + + { + v_f x = {}; + x = test_v_f(x, 42.42); + printf("%g\n", -x[I]); + } + + { + v_i64 x = {}; + x = test_v_i64(x, 42); + printf("%lld\n", -x[I]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42); + printf("%lld\n", -x[I]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42); + printf("%d\n", -x[I]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42); + printf("%d\n", -x[I]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42); + printf("%d\n", -x[I]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42); + printf("%d\n", -(i16)x[I]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42); + printf("%d\n", -x[I]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42); + printf("%d\n", -(i8)x[I]); + } + + return 0; +} +--EXPECT-- +42.42 +42.42 +42 +42 +42 +42 +42 +42 +42 +42 diff --git a/tests/vector/neg-005.test b/tests/vector/neg-005.test new file mode 100644 index 0000000..19d761a --- /dev/null +++ b/tests/vector/neg-005.test @@ -0,0 +1,167 @@ +--TEST-- +NEG.005: 64-bit vectors SSE2 +--TARGET-- +!aarch64 +--ARGS-- +-mno-sse4 -mno-avx2 --run +--CODE-- +#define N 8 +#define I 0 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef double __attribute__((__vector_size__(N))) v_d; +typedef float __attribute__((__vector_size__(N))) v_f; +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_d __attribute__((noinline)) test_v_d(v_d v, double x) +{ + v[I] = x; + return -v; +} + +v_f __attribute__((noinline)) test_v_f(v_f v, float x) +{ + v[I] = x; + return -v; +} + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x) +{ + v[I] = x; + return -v; +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x) +{ + v[I] = x; + return -v; +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x) +{ + v[I] = x; + return -v; +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x) +{ + v[I] = x; + return -v; +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x) +{ + v[I] = x; + return -v; +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x) +{ + v[I] = x; + return -v; +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x) +{ + v[I] = x; + return -v; +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x) +{ + v[I] = x; + return -v; +} + +int main() +{ + { + v_d x = {}; + x = test_v_d(x, 42.42); + printf("%g\n", -x[I]); + } + + { + v_f x = {}; + x = test_v_f(x, 42.42); + printf("%g\n", -x[I]); + } + + { + v_i64 x = {}; + x = test_v_i64(x, 42); + printf("%lld\n", -x[I]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42); + printf("%lld\n", -x[I]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42); + printf("%d\n", -x[I]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42); + printf("%d\n", -x[I]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42); + printf("%d\n", -x[I]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42); + printf("%d\n", -(i16)x[I]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42); + printf("%d\n", -x[I]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42); + printf("%d\n", -(i8)x[I]); + } + + return 0; +} +--EXPECT-- +42.42 +42.42 +42 +42 +42 +42 +42 +42 +42 +42 diff --git a/tests/vector/neg-006.test b/tests/vector/neg-006.test new file mode 100644 index 0000000..938c157 --- /dev/null +++ b/tests/vector/neg-006.test @@ -0,0 +1,167 @@ +--TEST-- +NEG.006: 256-bit vectors AVX +--TARGET-- +!aarch64 +--ARGS-- +-mavx -mno-avx2 --run +--CODE-- +#define N 32 +#define I 3 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef double __attribute__((__vector_size__(N))) v_d; +typedef float __attribute__((__vector_size__(N))) v_f; +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_d __attribute__((noinline)) test_v_d(v_d v, double x) +{ + v[I] = x; + return -v; +} + +v_f __attribute__((noinline)) test_v_f(v_f v, float x) +{ + v[I] = x; + return -v; +} + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x) +{ + v[I] = x; + return -v; +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x) +{ + v[I] = x; + return -v; +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x) +{ + v[I] = x; + return -v; +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x) +{ + v[I] = x; + return -v; +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x) +{ + v[I] = x; + return -v; +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x) +{ + v[I] = x; + return -v; +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x) +{ + v[I] = x; + return -v; +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x) +{ + v[I] = x; + return -v; +} + +int main() +{ + { + v_d x = {}; + x = test_v_d(x, 42.42); + printf("%g\n", -x[I]); + } + + { + v_f x = {}; + x = test_v_f(x, 42.42); + printf("%g\n", -x[I]); + } + + { + v_i64 x = {}; + x = test_v_i64(x, 42); + printf("%lld\n", -x[I]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42); + printf("%lld\n", -x[I]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42); + printf("%d\n", -x[I]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42); + printf("%d\n", -x[I]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42); + printf("%d\n", -x[I]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42); + printf("%d\n", -(i16)x[I]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42); + printf("%d\n", -x[I]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42); + printf("%d\n", -(i8)x[I]); + } + + return 0; +} +--EXPECT-- +42.42 +42.42 +42 +42 +42 +42 +42 +42 +42 +42 diff --git a/tests/vector/not-001.test b/tests/vector/not-001.test new file mode 100644 index 0000000..1f54cef --- /dev/null +++ b/tests/vector/not-001.test @@ -0,0 +1,139 @@ +--TEST-- +NOT.001: 128-bit vectors SSE2 +--TARGET-- +!aarch64 +--ARGS-- +-mno-sse4 -mno-avx2 --run +--CODE-- +#define N 16 +#define I 1 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x) +{ + v[I] = x; + return ~v; +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x) +{ + v[I] = x; + return ~v; +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x) +{ + v[I] = x; + return ~v; +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x) +{ + v[I] = x; + return ~v; +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x) +{ + v[I] = x; + return ~v; +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x) +{ + v[I] = x; + return ~v; +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x) +{ + v[I] = x; + return ~v; +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x) +{ + v[I] = x; + return ~v; +} + +int main() +{ + { + v_i64 x = {}; + x = test_v_i64(x, 42); + printf("%lld\n", ~x[I]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42); + printf("%lld\n", ~x[I]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42); + printf("%d\n", ~x[I]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42); + printf("%d\n", ~x[I]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42); + printf("%d\n", ~x[I]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42); + printf("%d\n", ~(i16)x[I]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42); + printf("%d\n", ~x[I]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42); + printf("%d\n", ~(i8)x[I]); + } + + return 0; +} +--EXPECT-- +42 +42 +42 +42 +42 +42 +42 +42 diff --git a/tests/vector/not-002.test b/tests/vector/not-002.test new file mode 100644 index 0000000..300f01d --- /dev/null +++ b/tests/vector/not-002.test @@ -0,0 +1,139 @@ +--TEST-- +NOT.002: 128-bit vectors SSE2+SSE4 +--TARGET-- +!aarch64 +--ARGS-- +-mno-avx2 --run +--CODE-- +#define N 16 +#define I 1 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x) +{ + v[I] = x; + return ~v; +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x) +{ + v[I] = x; + return ~v; +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x) +{ + v[I] = x; + return ~v; +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x) +{ + v[I] = x; + return ~v; +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x) +{ + v[I] = x; + return ~v; +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x) +{ + v[I] = x; + return ~v; +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x) +{ + v[I] = x; + return ~v; +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x) +{ + v[I] = x; + return ~v; +} + +int main() +{ + { + v_i64 x = {}; + x = test_v_i64(x, 42); + printf("%lld\n", ~x[I]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42); + printf("%lld\n", ~x[I]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42); + printf("%d\n", ~x[I]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42); + printf("%d\n", ~x[I]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42); + printf("%d\n", ~x[I]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42); + printf("%d\n", ~(i16)x[I]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42); + printf("%d\n", ~x[I]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42); + printf("%d\n", ~(i8)x[I]); + } + + return 0; +} +--EXPECT-- +42 +42 +42 +42 +42 +42 +42 +42 diff --git a/tests/vector/not-003.test b/tests/vector/not-003.test new file mode 100644 index 0000000..6662949 --- /dev/null +++ b/tests/vector/not-003.test @@ -0,0 +1,139 @@ +--TEST-- +NOT.003: 128-bit vectors AVX +--TARGET-- +!aarch64 +--ARGS-- +-mavx -mno-avx2 --run +--CODE-- +#define N 16 +#define I 1 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x) +{ + v[I] = x; + return ~v; +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x) +{ + v[I] = x; + return ~v; +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x) +{ + v[I] = x; + return ~v; +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x) +{ + v[I] = x; + return ~v; +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x) +{ + v[I] = x; + return ~v; +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x) +{ + v[I] = x; + return ~v; +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x) +{ + v[I] = x; + return ~v; +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x) +{ + v[I] = x; + return ~v; +} + +int main() +{ + { + v_i64 x = {}; + x = test_v_i64(x, 42); + printf("%lld\n", ~x[I]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42); + printf("%lld\n", ~x[I]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42); + printf("%d\n", ~x[I]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42); + printf("%d\n", ~x[I]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42); + printf("%d\n", ~x[I]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42); + printf("%d\n", ~(i16)x[I]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42); + printf("%d\n", ~x[I]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42); + printf("%d\n", ~(i8)x[I]); + } + + return 0; +} +--EXPECT-- +42 +42 +42 +42 +42 +42 +42 +42 diff --git a/tests/vector/not-004.test b/tests/vector/not-004.test new file mode 100644 index 0000000..502c174 --- /dev/null +++ b/tests/vector/not-004.test @@ -0,0 +1,139 @@ +--TEST-- +NOT.004: 128-bit vectors AVX+AVX2 +--TARGET-- +!aarch64 +--ARGS-- +-mavx --run +--CODE-- +#define N 16 +#define I 1 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x) +{ + v[I] = x; + return ~v; +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x) +{ + v[I] = x; + return ~v; +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x) +{ + v[I] = x; + return ~v; +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x) +{ + v[I] = x; + return ~v; +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x) +{ + v[I] = x; + return ~v; +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x) +{ + v[I] = x; + return ~v; +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x) +{ + v[I] = x; + return ~v; +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x) +{ + v[I] = x; + return ~v; +} + +int main() +{ + { + v_i64 x = {}; + x = test_v_i64(x, 42); + printf("%lld\n", ~x[I]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42); + printf("%lld\n", ~x[I]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42); + printf("%d\n", ~x[I]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42); + printf("%d\n", ~x[I]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42); + printf("%d\n", ~x[I]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42); + printf("%d\n", ~(i16)x[I]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42); + printf("%d\n", ~x[I]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42); + printf("%d\n", ~(i8)x[I]); + } + + return 0; +} +--EXPECT-- +42 +42 +42 +42 +42 +42 +42 +42 diff --git a/tests/vector/not-005.test b/tests/vector/not-005.test new file mode 100644 index 0000000..25b6a7c --- /dev/null +++ b/tests/vector/not-005.test @@ -0,0 +1,139 @@ +--TEST-- +NOT.005: 64-bit vectors SSE2 +--TARGET-- +!aarch64 +--ARGS-- +-mno-sse4 -mno-avx2 --run +--CODE-- +#define N 8 +#define I 0 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x) +{ + v[I] = x; + return ~v; +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x) +{ + v[I] = x; + return ~v; +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x) +{ + v[I] = x; + return ~v; +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x) +{ + v[I] = x; + return ~v; +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x) +{ + v[I] = x; + return ~v; +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x) +{ + v[I] = x; + return ~v; +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x) +{ + v[I] = x; + return ~v; +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x) +{ + v[I] = x; + return ~v; +} + +int main() +{ + { + v_i64 x = {}; + x = test_v_i64(x, 42); + printf("%lld\n", ~x[I]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42); + printf("%lld\n", ~x[I]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42); + printf("%d\n", ~x[I]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42); + printf("%d\n", ~x[I]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42); + printf("%d\n", ~x[I]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42); + printf("%d\n", ~(i16)x[I]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42); + printf("%d\n", ~x[I]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42); + printf("%d\n", ~(i8)x[I]); + } + + return 0; +} +--EXPECT-- +42 +42 +42 +42 +42 +42 +42 +42 diff --git a/tests/vector/not-006.test b/tests/vector/not-006.test new file mode 100644 index 0000000..2239fdb --- /dev/null +++ b/tests/vector/not-006.test @@ -0,0 +1,139 @@ +--TEST-- +NOT.006: 256-bit vectors AVX +--TARGET-- +!aarch64 +--ARGS-- +-mavx -mno-avx2 --run +--CODE-- +#define N 32 +#define I 3 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x) +{ + v[I] = x; + return ~v; +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x) +{ + v[I] = x; + return ~v; +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x) +{ + v[I] = x; + return ~v; +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x) +{ + v[I] = x; + return ~v; +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x) +{ + v[I] = x; + return ~v; +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x) +{ + v[I] = x; + return ~v; +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x) +{ + v[I] = x; + return ~v; +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x) +{ + v[I] = x; + return ~v; +} + +int main() +{ + { + v_i64 x = {}; + x = test_v_i64(x, 42); + printf("%lld\n", ~x[I]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42); + printf("%lld\n", ~x[I]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42); + printf("%d\n", ~x[I]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42); + printf("%d\n", ~x[I]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42); + printf("%d\n", ~x[I]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42); + printf("%d\n", ~(i16)x[I]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42); + printf("%d\n", ~x[I]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42); + printf("%d\n", ~(i8)x[I]); + } + + return 0; +} +--EXPECT-- +42 +42 +42 +42 +42 +42 +42 +42 diff --git a/tests/vector/or-001.test b/tests/vector/or-001.test new file mode 100644 index 0000000..9793ba4 --- /dev/null +++ b/tests/vector/or-001.test @@ -0,0 +1,139 @@ +--TEST-- +OR.001: 128-bit vectors SSE2 +--TARGET-- +!aarch64 +--ARGS-- +-mno-sse4 -mno-avx2 --run +--CODE-- +#define N 16 +#define I 1 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x) +{ + v |= x; + return v; +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x) +{ + v |= x; + return v; +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x) +{ + v |= x; + return v; +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x) +{ + v |= x; + return v; +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x) +{ + v |= x; + return v; +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x) +{ + v |= x; + return v; +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x) +{ + v |= x; + return v; +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x) +{ + v |= x; + return v; +} + +int main() +{ + { + v_i64 x = {}; + x = test_v_i64(x, 42); + printf("%lld\n", x[I]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42); + printf("%lld\n", x[I]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42); + printf("%d\n", x[I]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42); + printf("%d\n", x[I]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42); + printf("%d\n", x[I]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42); + printf("%d\n", x[I]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42); + printf("%d\n", x[I]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42); + printf("%d\n", x[I]); + } + + return 0; +} +--EXPECT-- +42 +42 +42 +42 +42 +42 +42 +42 diff --git a/tests/vector/or-002.test b/tests/vector/or-002.test new file mode 100644 index 0000000..aef7bd5 --- /dev/null +++ b/tests/vector/or-002.test @@ -0,0 +1,139 @@ +--TEST-- +OR.002: 128-bit vectors SSE2+SSE4 +--TARGET-- +!aarch64 +--ARGS-- +-mno-avx2 --run +--CODE-- +#define N 16 +#define I 1 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x) +{ + v |= x; + return v; +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x) +{ + v |= x; + return v; +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x) +{ + v |= x; + return v; +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x) +{ + v |= x; + return v; +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x) +{ + v |= x; + return v; +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x) +{ + v |= x; + return v; +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x) +{ + v |= x; + return v; +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x) +{ + v |= x; + return v; +} + +int main() +{ + { + v_i64 x = {}; + x = test_v_i64(x, 42); + printf("%lld\n", x[I]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42); + printf("%lld\n", x[I]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42); + printf("%d\n", x[I]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42); + printf("%d\n", x[I]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42); + printf("%d\n", x[I]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42); + printf("%d\n", x[I]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42); + printf("%d\n", x[I]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42); + printf("%d\n", x[I]); + } + + return 0; +} +--EXPECT-- +42 +42 +42 +42 +42 +42 +42 +42 diff --git a/tests/vector/or-003.test b/tests/vector/or-003.test new file mode 100644 index 0000000..7d42fe6 --- /dev/null +++ b/tests/vector/or-003.test @@ -0,0 +1,139 @@ +--TEST-- +OR.003: 128-bit vectors AVX +--TARGET-- +!aarch64 +--ARGS-- +-mavx -mno-avx2 --run +--CODE-- +#define N 16 +#define I 1 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x) +{ + v |= x; + return v; +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x) +{ + v |= x; + return v; +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x) +{ + v |= x; + return v; +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x) +{ + v |= x; + return v; +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x) +{ + v |= x; + return v; +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x) +{ + v |= x; + return v; +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x) +{ + v |= x; + return v; +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x) +{ + v |= x; + return v; +} + +int main() +{ + { + v_i64 x = {}; + x = test_v_i64(x, 42); + printf("%lld\n", x[I]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42); + printf("%lld\n", x[I]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42); + printf("%d\n", x[I]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42); + printf("%d\n", x[I]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42); + printf("%d\n", x[I]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42); + printf("%d\n", x[I]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42); + printf("%d\n", x[I]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42); + printf("%d\n", x[I]); + } + + return 0; +} +--EXPECT-- +42 +42 +42 +42 +42 +42 +42 +42 diff --git a/tests/vector/or-004.test b/tests/vector/or-004.test new file mode 100644 index 0000000..e5c27f1 --- /dev/null +++ b/tests/vector/or-004.test @@ -0,0 +1,139 @@ +--TEST-- +OR.004: 128-bit vectors AVX+AVX2 +--TARGET-- +!aarch64 +--ARGS-- +-mavx --run +--CODE-- +#define N 16 +#define I 1 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x) +{ + v |= x; + return v; +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x) +{ + v |= x; + return v; +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x) +{ + v |= x; + return v; +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x) +{ + v |= x; + return v; +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x) +{ + v |= x; + return v; +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x) +{ + v |= x; + return v; +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x) +{ + v |= x; + return v; +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x) +{ + v |= x; + return v; +} + +int main() +{ + { + v_i64 x = {}; + x = test_v_i64(x, 42); + printf("%lld\n", x[I]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42); + printf("%lld\n", x[I]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42); + printf("%d\n", x[I]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42); + printf("%d\n", x[I]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42); + printf("%d\n", x[I]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42); + printf("%d\n", x[I]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42); + printf("%d\n", x[I]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42); + printf("%d\n", x[I]); + } + + return 0; +} +--EXPECT-- +42 +42 +42 +42 +42 +42 +42 +42 diff --git a/tests/vector/or-005.test b/tests/vector/or-005.test new file mode 100644 index 0000000..54f294d --- /dev/null +++ b/tests/vector/or-005.test @@ -0,0 +1,139 @@ +--TEST-- +OR.005: 64-bit vectors SSE2 +--TARGET-- +!aarch64 +--ARGS-- +-mno-sse4 -mno-avx2 --run +--CODE-- +#define N 16 +#define I 1 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x) +{ + v |= x; + return v; +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x) +{ + v |= x; + return v; +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x) +{ + v |= x; + return v; +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x) +{ + v |= x; + return v; +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x) +{ + v |= x; + return v; +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x) +{ + v |= x; + return v; +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x) +{ + v |= x; + return v; +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x) +{ + v |= x; + return v; +} + +int main() +{ + { + v_i64 x = {}; + x = test_v_i64(x, 42); + printf("%lld\n", x[I]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42); + printf("%lld\n", x[I]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42); + printf("%d\n", x[I]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42); + printf("%d\n", x[I]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42); + printf("%d\n", x[I]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42); + printf("%d\n", x[I]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42); + printf("%d\n", x[I]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42); + printf("%d\n", x[I]); + } + + return 0; +} +--EXPECT-- +42 +42 +42 +42 +42 +42 +42 +42 diff --git a/tests/vector/or-006.test b/tests/vector/or-006.test new file mode 100644 index 0000000..77cba19 --- /dev/null +++ b/tests/vector/or-006.test @@ -0,0 +1,139 @@ +--TEST-- +OR.006: 256-bit vectors AVX +--TARGET-- +!aarch64 +--ARGS-- +-mavx -mno-avx2 --run +--CODE-- +#define N 16 +#define I 1 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x) +{ + v |= x; + return v; +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x) +{ + v |= x; + return v; +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x) +{ + v |= x; + return v; +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x) +{ + v |= x; + return v; +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x) +{ + v |= x; + return v; +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x) +{ + v |= x; + return v; +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x) +{ + v |= x; + return v; +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x) +{ + v |= x; + return v; +} + +int main() +{ + { + v_i64 x = {}; + x = test_v_i64(x, 42); + printf("%lld\n", x[I]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42); + printf("%lld\n", x[I]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42); + printf("%d\n", x[I]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42); + printf("%d\n", x[I]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42); + printf("%d\n", x[I]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42); + printf("%d\n", x[I]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42); + printf("%d\n", x[I]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42); + printf("%d\n", x[I]); + } + + return 0; +} +--EXPECT-- +42 +42 +42 +42 +42 +42 +42 +42 diff --git a/tests/vector/replace-001.test b/tests/vector/replace-001.test new file mode 100644 index 0000000..f8aecf6 --- /dev/null +++ b/tests/vector/replace-001.test @@ -0,0 +1,167 @@ +--TEST-- +REPLACE.001: 128-bit vectors SSE2 +--TARGET-- +!aarch64 +--ARGS-- +-mno-sse4 -mno-avx2 --run +--CODE-- +#define N 16 +#define I 1 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef double __attribute__((__vector_size__(N))) v_d; +typedef float __attribute__((__vector_size__(N))) v_f; +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_d __attribute__((noinline)) test_v_d(v_d v, double x) +{ + v[I] = x; + return v; +} + +v_f __attribute__((noinline)) test_v_f(v_f v, float x) +{ + v[I] = x; + return v; +} + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x) +{ + v[I] = x; + return v; +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x) +{ + v[I] = x; + return v; +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x) +{ + v[I] = x; + return v; +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x) +{ + v[I] = x; + return v; +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x) +{ + v[I] = x; + return v; +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x) +{ + v[I] = x; + return v; +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x) +{ + v[I] = x; + return v; +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x) +{ + v[I] = x; + return v; +} + +int main() +{ + { + v_d x = {}; + x = test_v_d(x, 42.42); + printf("%g\n", x[I]); + } + + { + v_f x = {}; + x = test_v_f(x, 42.42); + printf("%g\n", x[I]); + } + + { + v_i64 x = {}; + x = test_v_i64(x, 42); + printf("%lld\n", x[I]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42); + printf("%lld\n", x[I]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42); + printf("%d\n", x[I]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42); + printf("%d\n", x[I]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42); + printf("%d\n", x[I]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42); + printf("%d\n", x[I]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42); + printf("%d\n", x[I]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42); + printf("%d\n", x[I]); + } + + return 0; +} +--EXPECT-- +42.42 +42.42 +42 +42 +42 +42 +42 +42 +42 +42 diff --git a/tests/vector/replace-002.test b/tests/vector/replace-002.test new file mode 100644 index 0000000..adaf299 --- /dev/null +++ b/tests/vector/replace-002.test @@ -0,0 +1,167 @@ +--TEST-- +REPLACE.002: 128-bit vectors SSE2+SSE4 +--TARGET-- +!aarch64 +--ARGS-- +-mno-avx2 --run +--CODE-- +#define N 16 +#define I 1 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef double __attribute__((__vector_size__(N))) v_d; +typedef float __attribute__((__vector_size__(N))) v_f; +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_d __attribute__((noinline)) test_v_d(v_d v, double x) +{ + v[I] = x; + return v; +} + +v_f __attribute__((noinline)) test_v_f(v_f v, float x) +{ + v[I] = x; + return v; +} + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x) +{ + v[I] = x; + return v; +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x) +{ + v[I] = x; + return v; +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x) +{ + v[I] = x; + return v; +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x) +{ + v[I] = x; + return v; +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x) +{ + v[I] = x; + return v; +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x) +{ + v[I] = x; + return v; +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x) +{ + v[I] = x; + return v; +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x) +{ + v[I] = x; + return v; +} + +int main() +{ + { + v_d x = {}; + x = test_v_d(x, 42.42); + printf("%g\n", x[I]); + } + + { + v_f x = {}; + x = test_v_f(x, 42.42); + printf("%g\n", x[I]); + } + + { + v_i64 x = {}; + x = test_v_i64(x, 42); + printf("%lld\n", x[I]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42); + printf("%lld\n", x[I]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42); + printf("%d\n", x[I]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42); + printf("%d\n", x[I]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42); + printf("%d\n", x[I]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42); + printf("%d\n", x[I]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42); + printf("%d\n", x[I]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42); + printf("%d\n", x[I]); + } + + return 0; +} +--EXPECT-- +42.42 +42.42 +42 +42 +42 +42 +42 +42 +42 +42 diff --git a/tests/vector/replace-003.test b/tests/vector/replace-003.test new file mode 100644 index 0000000..41aea09 --- /dev/null +++ b/tests/vector/replace-003.test @@ -0,0 +1,167 @@ +--TEST-- +REPLACE.003: 128-bit vectors AVX +--TARGET-- +!aarch64 +--ARGS-- +-mavx -mno-avx2 --run +--CODE-- +#define N 16 +#define I 1 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef double __attribute__((__vector_size__(N))) v_d; +typedef float __attribute__((__vector_size__(N))) v_f; +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_d __attribute__((noinline)) test_v_d(v_d v, double x) +{ + v[I] = x; + return v; +} + +v_f __attribute__((noinline)) test_v_f(v_f v, float x) +{ + v[I] = x; + return v; +} + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x) +{ + v[I] = x; + return v; +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x) +{ + v[I] = x; + return v; +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x) +{ + v[I] = x; + return v; +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x) +{ + v[I] = x; + return v; +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x) +{ + v[I] = x; + return v; +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x) +{ + v[I] = x; + return v; +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x) +{ + v[I] = x; + return v; +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x) +{ + v[I] = x; + return v; +} + +int main() +{ + { + v_d x = {}; + x = test_v_d(x, 42.42); + printf("%g\n", x[I]); + } + + { + v_f x = {}; + x = test_v_f(x, 42.42); + printf("%g\n", x[I]); + } + + { + v_i64 x = {}; + x = test_v_i64(x, 42); + printf("%lld\n", x[I]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42); + printf("%lld\n", x[I]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42); + printf("%d\n", x[I]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42); + printf("%d\n", x[I]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42); + printf("%d\n", x[I]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42); + printf("%d\n", x[I]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42); + printf("%d\n", x[I]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42); + printf("%d\n", x[I]); + } + + return 0; +} +--EXPECT-- +42.42 +42.42 +42 +42 +42 +42 +42 +42 +42 +42 diff --git a/tests/vector/replace-004.test b/tests/vector/replace-004.test new file mode 100644 index 0000000..ce056c6 --- /dev/null +++ b/tests/vector/replace-004.test @@ -0,0 +1,167 @@ +--TEST-- +REPLACE.004: 128-bit vectors AVX+AVX2 +--TARGET-- +!aarch64 +--ARGS-- +-mavx --run +--CODE-- +#define N 16 +#define I 1 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef double __attribute__((__vector_size__(N))) v_d; +typedef float __attribute__((__vector_size__(N))) v_f; +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_d __attribute__((noinline)) test_v_d(v_d v, double x) +{ + v[I] = x; + return v; +} + +v_f __attribute__((noinline)) test_v_f(v_f v, float x) +{ + v[I] = x; + return v; +} + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x) +{ + v[I] = x; + return v; +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x) +{ + v[I] = x; + return v; +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x) +{ + v[I] = x; + return v; +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x) +{ + v[I] = x; + return v; +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x) +{ + v[I] = x; + return v; +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x) +{ + v[I] = x; + return v; +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x) +{ + v[I] = x; + return v; +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x) +{ + v[I] = x; + return v; +} + +int main() +{ + { + v_d x = {}; + x = test_v_d(x, 42.42); + printf("%g\n", x[I]); + } + + { + v_f x = {}; + x = test_v_f(x, 42.42); + printf("%g\n", x[I]); + } + + { + v_i64 x = {}; + x = test_v_i64(x, 42); + printf("%lld\n", x[I]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42); + printf("%lld\n", x[I]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42); + printf("%d\n", x[I]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42); + printf("%d\n", x[I]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42); + printf("%d\n", x[I]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42); + printf("%d\n", x[I]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42); + printf("%d\n", x[I]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42); + printf("%d\n", x[I]); + } + + return 0; +} +--EXPECT-- +42.42 +42.42 +42 +42 +42 +42 +42 +42 +42 +42 diff --git a/tests/vector/replace-005.test b/tests/vector/replace-005.test new file mode 100644 index 0000000..3a03349 --- /dev/null +++ b/tests/vector/replace-005.test @@ -0,0 +1,167 @@ +--TEST-- +REPLACE.005: 64-bit vectors SSE2 +--TARGET-- +!aarch64 +--ARGS-- +-mno-sse4 -mno-avx2 --run +--CODE-- +#define N 8 +#define I 0 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef double __attribute__((__vector_size__(N))) v_d; +typedef float __attribute__((__vector_size__(N))) v_f; +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_d __attribute__((noinline)) test_v_d(v_d v, double x) +{ + v[I] = x; + return v; +} + +v_f __attribute__((noinline)) test_v_f(v_f v, float x) +{ + v[I] = x; + return v; +} + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x) +{ + v[I] = x; + return v; +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x) +{ + v[I] = x; + return v; +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x) +{ + v[I] = x; + return v; +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x) +{ + v[I] = x; + return v; +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x) +{ + v[I] = x; + return v; +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x) +{ + v[I] = x; + return v; +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x) +{ + v[I] = x; + return v; +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x) +{ + v[I] = x; + return v; +} + +int main() +{ + { + v_d x = {}; + x = test_v_d(x, 42.42); + printf("%g\n", x[I]); + } + + { + v_f x = {}; + x = test_v_f(x, 42.42); + printf("%g\n", x[I]); + } + + { + v_i64 x = {}; + x = test_v_i64(x, 42); + printf("%lld\n", x[I]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42); + printf("%lld\n", x[I]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42); + printf("%d\n", x[I]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42); + printf("%d\n", x[I]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42); + printf("%d\n", x[I]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42); + printf("%d\n", x[I]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42); + printf("%d\n", x[I]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42); + printf("%d\n", x[I]); + } + + return 0; +} +--EXPECT-- +42.42 +42.42 +42 +42 +42 +42 +42 +42 +42 +42 diff --git a/tests/vector/replace-006.test b/tests/vector/replace-006.test new file mode 100644 index 0000000..074819a --- /dev/null +++ b/tests/vector/replace-006.test @@ -0,0 +1,167 @@ +--TEST-- +REPLACE.006: 64-bit vectors SSE2+SSE4 +--TARGET-- +!aarch64 +--ARGS-- +-mno-avx2 --run +--CODE-- +#define N 8 +#define I 0 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef double __attribute__((__vector_size__(N))) v_d; +typedef float __attribute__((__vector_size__(N))) v_f; +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_d __attribute__((noinline)) test_v_d(v_d v, double x) +{ + v[I] = x; + return v; +} + +v_f __attribute__((noinline)) test_v_f(v_f v, float x) +{ + v[I] = x; + return v; +} + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x) +{ + v[I] = x; + return v; +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x) +{ + v[I] = x; + return v; +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x) +{ + v[I] = x; + return v; +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x) +{ + v[I] = x; + return v; +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x) +{ + v[I] = x; + return v; +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x) +{ + v[I] = x; + return v; +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x) +{ + v[I] = x; + return v; +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x) +{ + v[I] = x; + return v; +} + +int main() +{ + { + v_d x = {}; + x = test_v_d(x, 42.42); + printf("%g\n", x[I]); + } + + { + v_f x = {}; + x = test_v_f(x, 42.42); + printf("%g\n", x[I]); + } + + { + v_i64 x = {}; + x = test_v_i64(x, 42); + printf("%lld\n", x[I]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42); + printf("%lld\n", x[I]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42); + printf("%d\n", x[I]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42); + printf("%d\n", x[I]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42); + printf("%d\n", x[I]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42); + printf("%d\n", x[I]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42); + printf("%d\n", x[I]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42); + printf("%d\n", x[I]); + } + + return 0; +} +--EXPECT-- +42.42 +42.42 +42 +42 +42 +42 +42 +42 +42 +42 diff --git a/tests/vector/replace-007.test b/tests/vector/replace-007.test new file mode 100644 index 0000000..45fd7be --- /dev/null +++ b/tests/vector/replace-007.test @@ -0,0 +1,167 @@ +--TEST-- +REPLACE.007: 64-bit vectors AVX +--TARGET-- +!aarch64 +--ARGS-- +-mavx -mno-avx2 --run +--CODE-- +#define N 8 +#define I 0 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef double __attribute__((__vector_size__(N))) v_d; +typedef float __attribute__((__vector_size__(N))) v_f; +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_d __attribute__((noinline)) test_v_d(v_d v, double x) +{ + v[I] = x; + return v; +} + +v_f __attribute__((noinline)) test_v_f(v_f v, float x) +{ + v[I] = x; + return v; +} + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x) +{ + v[I] = x; + return v; +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x) +{ + v[I] = x; + return v; +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x) +{ + v[I] = x; + return v; +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x) +{ + v[I] = x; + return v; +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x) +{ + v[I] = x; + return v; +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x) +{ + v[I] = x; + return v; +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x) +{ + v[I] = x; + return v; +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x) +{ + v[I] = x; + return v; +} + +int main() +{ + { + v_d x = {}; + x = test_v_d(x, 42.42); + printf("%g\n", x[I]); + } + + { + v_f x = {}; + x = test_v_f(x, 42.42); + printf("%g\n", x[I]); + } + + { + v_i64 x = {}; + x = test_v_i64(x, 42); + printf("%lld\n", x[I]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42); + printf("%lld\n", x[I]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42); + printf("%d\n", x[I]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42); + printf("%d\n", x[I]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42); + printf("%d\n", x[I]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42); + printf("%d\n", x[I]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42); + printf("%d\n", x[I]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42); + printf("%d\n", x[I]); + } + + return 0; +} +--EXPECT-- +42.42 +42.42 +42 +42 +42 +42 +42 +42 +42 +42 diff --git a/tests/vector/replace-008.test b/tests/vector/replace-008.test new file mode 100644 index 0000000..581dab8 --- /dev/null +++ b/tests/vector/replace-008.test @@ -0,0 +1,167 @@ +--TEST-- +REPLACE.008: 64-bit vectors AVX+AVX2 +--TARGET-- +!aarch64 +--ARGS-- +-mavx --run +--CODE-- +#define N 8 +#define I 0 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef double __attribute__((__vector_size__(N))) v_d; +typedef float __attribute__((__vector_size__(N))) v_f; +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_d __attribute__((noinline)) test_v_d(v_d v, double x) +{ + v[I] = x; + return v; +} + +v_f __attribute__((noinline)) test_v_f(v_f v, float x) +{ + v[I] = x; + return v; +} + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x) +{ + v[I] = x; + return v; +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x) +{ + v[I] = x; + return v; +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x) +{ + v[I] = x; + return v; +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x) +{ + v[I] = x; + return v; +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x) +{ + v[I] = x; + return v; +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x) +{ + v[I] = x; + return v; +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x) +{ + v[I] = x; + return v; +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x) +{ + v[I] = x; + return v; +} + +int main() +{ + { + v_d x = {}; + x = test_v_d(x, 42.42); + printf("%g\n", x[I]); + } + + { + v_f x = {}; + x = test_v_f(x, 42.42); + printf("%g\n", x[I]); + } + + { + v_i64 x = {}; + x = test_v_i64(x, 42); + printf("%lld\n", x[I]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42); + printf("%lld\n", x[I]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42); + printf("%d\n", x[I]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42); + printf("%d\n", x[I]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42); + printf("%d\n", x[I]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42); + printf("%d\n", x[I]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42); + printf("%d\n", x[I]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42); + printf("%d\n", x[I]); + } + + return 0; +} +--EXPECT-- +42.42 +42.42 +42 +42 +42 +42 +42 +42 +42 +42 diff --git a/tests/vector/replace-009.test b/tests/vector/replace-009.test new file mode 100644 index 0000000..c603a81 --- /dev/null +++ b/tests/vector/replace-009.test @@ -0,0 +1,167 @@ +--TEST-- +REPLACE.009: 256-bit vectors AVX (low) +--TARGET-- +!aarch64 +--ARGS-- +-mavx -mno-avx2 --run +--CODE-- +#define N 32 +#define I 1 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef double __attribute__((__vector_size__(N))) v_d; +typedef float __attribute__((__vector_size__(N))) v_f; +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_d __attribute__((noinline)) test_v_d(v_d v, double x) +{ + v[I] = x; + return v; +} + +v_f __attribute__((noinline)) test_v_f(v_f v, float x) +{ + v[I] = x; + return v; +} + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x) +{ + v[I] = x; + return v; +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x) +{ + v[I] = x; + return v; +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x) +{ + v[I] = x; + return v; +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x) +{ + v[I] = x; + return v; +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x) +{ + v[I] = x; + return v; +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x) +{ + v[I] = x; + return v; +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x) +{ + v[I] = x; + return v; +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x) +{ + v[I] = x; + return v; +} + +int main() +{ + { + v_d x = {}; + x = test_v_d(x, 42.42); + printf("%g\n", x[I]); + } + + { + v_f x = {}; + x = test_v_f(x, 42.42); + printf("%g\n", x[I]); + } + + { + v_i64 x = {}; + x = test_v_i64(x, 42); + printf("%lld\n", x[I]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42); + printf("%lld\n", x[I]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42); + printf("%d\n", x[I]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42); + printf("%d\n", x[I]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42); + printf("%d\n", x[I]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42); + printf("%d\n", x[I]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42); + printf("%d\n", x[I]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42); + printf("%d\n", x[I]); + } + + return 0; +} +--EXPECT-- +42.42 +42.42 +42 +42 +42 +42 +42 +42 +42 +42 diff --git a/tests/vector/replace-010.test b/tests/vector/replace-010.test new file mode 100644 index 0000000..1f010b7 --- /dev/null +++ b/tests/vector/replace-010.test @@ -0,0 +1,167 @@ +--TEST-- +REPLACE.010: 256-bit vectors AVX+AVX2 (low) +--TARGET-- +!aarch64 +--ARGS-- +-mavx --run +--CODE-- +#define N 32 +#define I 1 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef double __attribute__((__vector_size__(N))) v_d; +typedef float __attribute__((__vector_size__(N))) v_f; +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_d __attribute__((noinline)) test_v_d(v_d v, double x) +{ + v[I] = x; + return v; +} + +v_f __attribute__((noinline)) test_v_f(v_f v, float x) +{ + v[I] = x; + return v; +} + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x) +{ + v[I] = x; + return v; +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x) +{ + v[I] = x; + return v; +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x) +{ + v[I] = x; + return v; +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x) +{ + v[I] = x; + return v; +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x) +{ + v[I] = x; + return v; +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x) +{ + v[I] = x; + return v; +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x) +{ + v[I] = x; + return v; +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x) +{ + v[I] = x; + return v; +} + +int main() +{ + { + v_d x = {}; + x = test_v_d(x, 42.42); + printf("%g\n", x[I]); + } + + { + v_f x = {}; + x = test_v_f(x, 42.42); + printf("%g\n", x[I]); + } + + { + v_i64 x = {}; + x = test_v_i64(x, 42); + printf("%lld\n", x[I]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42); + printf("%lld\n", x[I]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42); + printf("%d\n", x[I]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42); + printf("%d\n", x[I]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42); + printf("%d\n", x[I]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42); + printf("%d\n", x[I]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42); + printf("%d\n", x[I]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42); + printf("%d\n", x[I]); + } + + return 0; +} +--EXPECT-- +42.42 +42.42 +42 +42 +42 +42 +42 +42 +42 +42 diff --git a/tests/vector/replace-011.test b/tests/vector/replace-011.test new file mode 100644 index 0000000..3b15b63 --- /dev/null +++ b/tests/vector/replace-011.test @@ -0,0 +1,166 @@ +--TEST-- +REPLACE.011: 256-bit vectors AVX (high) +--TARGET-- +!aarch64 +--ARGS-- +-mavx -mno-avx2 --run +--CODE-- +#define N 32 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef double __attribute__((__vector_size__(N))) v_d; +typedef float __attribute__((__vector_size__(N))) v_f; +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_d __attribute__((noinline)) test_v_d(v_d v, double x) +{ + v[3] = x; + return v; +} + +v_f __attribute__((noinline)) test_v_f(v_f v, float x) +{ + v[5] = x; + return v; +} + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x) +{ + v[3] = x; + return v; +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x) +{ + v[3] = x; + return v; +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x) +{ + v[5] = x; + return v; +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x) +{ + v[5] = x; + return v; +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x) +{ + v[9] = x; + return v; +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x) +{ + v[9] = x; + return v; +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x) +{ + v[17] = x; + return v; +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x) +{ + v[17] = x; + return v; +} + +int main() +{ + { + v_d x = {}; + x = test_v_d(x, 42.42); + printf("%g\n", x[3]); + } + + { + v_f x = {}; + x = test_v_f(x, 42.42); + printf("%g\n", x[5]); + } + + { + v_i64 x = {}; + x = test_v_i64(x, 42); + printf("%lld\n", x[3]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42); + printf("%lld\n", x[3]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42); + printf("%d\n", x[5]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42); + printf("%d\n", x[5]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42); + printf("%d\n", x[9]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42); + printf("%d\n", x[9]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42); + printf("%d\n", x[17]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42); + printf("%d\n", x[17]); + } + + return 0; +} +--EXPECT-- +42.42 +42.42 +42 +42 +42 +42 +42 +42 +42 +42 diff --git a/tests/vector/replace-012.test b/tests/vector/replace-012.test new file mode 100644 index 0000000..25efd4d --- /dev/null +++ b/tests/vector/replace-012.test @@ -0,0 +1,166 @@ +--TEST-- +REPLACE.012: 256-bit vectors AVX+AVX2 (high) +--TARGET-- +!aarch64 +--ARGS-- +-mavx --run +--CODE-- +#define N 32 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef double __attribute__((__vector_size__(N))) v_d; +typedef float __attribute__((__vector_size__(N))) v_f; +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_d __attribute__((noinline)) test_v_d(v_d v, double x) +{ + v[3] = x; + return v; +} + +v_f __attribute__((noinline)) test_v_f(v_f v, float x) +{ + v[5] = x; + return v; +} + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x) +{ + v[3] = x; + return v; +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x) +{ + v[3] = x; + return v; +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x) +{ + v[5] = x; + return v; +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x) +{ + v[5] = x; + return v; +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x) +{ + v[9] = x; + return v; +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x) +{ + v[9] = x; + return v; +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x) +{ + v[17] = x; + return v; +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x) +{ + v[17] = x; + return v; +} + +int main() +{ + { + v_d x = {}; + x = test_v_d(x, 42.42); + printf("%g\n", x[3]); + } + + { + v_f x = {}; + x = test_v_f(x, 42.42); + printf("%g\n", x[5]); + } + + { + v_i64 x = {}; + x = test_v_i64(x, 42); + printf("%lld\n", x[3]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42); + printf("%lld\n", x[3]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42); + printf("%d\n", x[5]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42); + printf("%d\n", x[5]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42); + printf("%d\n", x[9]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42); + printf("%d\n", x[9]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42); + printf("%d\n", x[17]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42); + printf("%d\n", x[17]); + } + + return 0; +} +--EXPECT-- +42.42 +42.42 +42 +42 +42 +42 +42 +42 +42 +42 From f5f7577c01a54ac2febcf074ce2e37b5c674696b Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Tue, 14 Jul 2026 16:31:53 +0300 Subject: [PATCH 18/31] Fix missing EXTRACT --- rcc_semantic.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/rcc_semantic.c b/rcc_semantic.c index 30d42e2..2cfa40b 100644 --- a/rcc_semantic.c +++ b/rcc_semantic.c @@ -4625,11 +4625,12 @@ void c_do_array_dim(rcc_ctx *rcc, c_value *v, c_value *dim) c_value_rval(rcc, dim); if (c_value_is_lval(v)) { c_value_set_lval(v, type->vec.type, c_type2ir(rcc, type->vec.type), v->u.ref); + v->u.proto = C_VECTOR_DIM(vt); + v->u.op2 = c_value_ref(rcc, dim); } else { - c_value_set_rval(v, type->vec.type, c_type2ir(rcc, type->vec.type), c_value_ref(rcc, v)); + ir_type t = c_type2ir(rcc, type->vec.type); + c_value_set_rval(v, type->vec.type, t, ir_EXTRACT(t, c_value_ref(rcc, v), c_value_ref(rcc, dim))); } - v->u.proto = C_VECTOR_DIM(vt); - v->u.op2 = c_value_ref(rcc, dim);; return; } else { type = dim->type; From bbdc648463c6a92beb6c0bce14fd00c44c1bbcb1 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Tue, 14 Jul 2026 16:41:12 +0300 Subject: [PATCH 19/31] Add more test for vector opearations --- tests/vector/add-001.test | 2 +- tests/vector/add-002.test | 2 +- tests/vector/add-003.test | 2 +- tests/vector/add-004.test | 2 +- tests/vector/add-005.test | 2 +- tests/vector/add-006.test | 2 +- tests/vector/add-007.test | 2 +- tests/vector/add-008.test | 2 +- tests/vector/add-009.test | 2 +- tests/vector/add-010.test | 2 +- tests/vector/eq-001.test | 199 ++++++++++++++++++++++++++++ tests/vector/eq-002.test | 199 ++++++++++++++++++++++++++++ tests/vector/eq-003.test | 199 ++++++++++++++++++++++++++++ tests/vector/eq-004.test | 199 ++++++++++++++++++++++++++++ tests/vector/eq-005.test | 199 ++++++++++++++++++++++++++++ tests/vector/eq-006.test | 199 ++++++++++++++++++++++++++++ tests/vector/ge-001.test | 239 ++++++++++++++++++++++++++++++++++ tests/vector/ge-002.test | 239 ++++++++++++++++++++++++++++++++++ tests/vector/ge-003.test | 239 ++++++++++++++++++++++++++++++++++ tests/vector/ge-004.test | 239 ++++++++++++++++++++++++++++++++++ tests/vector/ge-005.test | 239 ++++++++++++++++++++++++++++++++++ tests/vector/ge-006.test | 239 ++++++++++++++++++++++++++++++++++ tests/vector/ge-007.test | 239 ++++++++++++++++++++++++++++++++++ tests/vector/ge-008.test | 239 ++++++++++++++++++++++++++++++++++ tests/vector/gt-001.test | 239 ++++++++++++++++++++++++++++++++++ tests/vector/gt-002.test | 239 ++++++++++++++++++++++++++++++++++ tests/vector/gt-003.test | 239 ++++++++++++++++++++++++++++++++++ tests/vector/gt-004.test | 239 ++++++++++++++++++++++++++++++++++ tests/vector/gt-005.test | 239 ++++++++++++++++++++++++++++++++++ tests/vector/gt-006.test | 239 ++++++++++++++++++++++++++++++++++ tests/vector/gt-007.test | 239 ++++++++++++++++++++++++++++++++++ tests/vector/gt-008.test | 239 ++++++++++++++++++++++++++++++++++ tests/vector/le-001.test | 239 ++++++++++++++++++++++++++++++++++ tests/vector/le-002.test | 239 ++++++++++++++++++++++++++++++++++ tests/vector/le-003.test | 239 ++++++++++++++++++++++++++++++++++ tests/vector/le-004.test | 239 ++++++++++++++++++++++++++++++++++ tests/vector/le-005.test | 239 ++++++++++++++++++++++++++++++++++ tests/vector/le-006.test | 239 ++++++++++++++++++++++++++++++++++ tests/vector/le-007.test | 239 ++++++++++++++++++++++++++++++++++ tests/vector/le-008.test | 239 ++++++++++++++++++++++++++++++++++ tests/vector/lt-001.test | 239 ++++++++++++++++++++++++++++++++++ tests/vector/lt-002.test | 239 ++++++++++++++++++++++++++++++++++ tests/vector/lt-003.test | 239 ++++++++++++++++++++++++++++++++++ tests/vector/lt-004.test | 239 ++++++++++++++++++++++++++++++++++ tests/vector/lt-005.test | 239 ++++++++++++++++++++++++++++++++++ tests/vector/lt-006.test | 239 ++++++++++++++++++++++++++++++++++ tests/vector/lt-007.test | 239 ++++++++++++++++++++++++++++++++++ tests/vector/lt-008.test | 239 ++++++++++++++++++++++++++++++++++ tests/vector/ne-001.test | 199 ++++++++++++++++++++++++++++ tests/vector/ne-002.test | 199 ++++++++++++++++++++++++++++ tests/vector/ne-003.test | 199 ++++++++++++++++++++++++++++ tests/vector/ne-004.test | 199 ++++++++++++++++++++++++++++ tests/vector/ne-005.test | 199 ++++++++++++++++++++++++++++ tests/vector/ne-006.test | 199 ++++++++++++++++++++++++++++ tests/vector/neg-001.test | 2 +- tests/vector/neg-002.test | 2 +- tests/vector/neg-003.test | 2 +- tests/vector/neg-004.test | 2 +- tests/vector/neg-005.test | 2 +- tests/vector/neg-006.test | 2 +- tests/vector/not-001.test | 2 +- tests/vector/not-002.test | 2 +- tests/vector/not-003.test | 2 +- tests/vector/not-004.test | 2 +- tests/vector/not-005.test | 2 +- tests/vector/not-006.test | 2 +- tests/vector/or-001.test | 2 +- tests/vector/or-002.test | 2 +- tests/vector/or-003.test | 2 +- tests/vector/or-004.test | 2 +- tests/vector/or-005.test | 2 +- tests/vector/or-006.test | 2 +- tests/vector/replace-001.test | 2 +- tests/vector/replace-002.test | 2 +- tests/vector/replace-003.test | 2 +- tests/vector/replace-004.test | 2 +- tests/vector/replace-005.test | 2 +- tests/vector/replace-006.test | 2 +- tests/vector/replace-007.test | 2 +- tests/vector/replace-008.test | 2 +- tests/vector/replace-009.test | 2 +- tests/vector/replace-010.test | 2 +- tests/vector/replace-011.test | 2 +- tests/vector/replace-012.test | 2 +- 84 files changed, 10076 insertions(+), 40 deletions(-) create mode 100644 tests/vector/eq-001.test create mode 100644 tests/vector/eq-002.test create mode 100644 tests/vector/eq-003.test create mode 100644 tests/vector/eq-004.test create mode 100644 tests/vector/eq-005.test create mode 100644 tests/vector/eq-006.test create mode 100644 tests/vector/ge-001.test create mode 100644 tests/vector/ge-002.test create mode 100644 tests/vector/ge-003.test create mode 100644 tests/vector/ge-004.test create mode 100644 tests/vector/ge-005.test create mode 100644 tests/vector/ge-006.test create mode 100644 tests/vector/ge-007.test create mode 100644 tests/vector/ge-008.test create mode 100644 tests/vector/gt-001.test create mode 100644 tests/vector/gt-002.test create mode 100644 tests/vector/gt-003.test create mode 100644 tests/vector/gt-004.test create mode 100644 tests/vector/gt-005.test create mode 100644 tests/vector/gt-006.test create mode 100644 tests/vector/gt-007.test create mode 100644 tests/vector/gt-008.test create mode 100644 tests/vector/le-001.test create mode 100644 tests/vector/le-002.test create mode 100644 tests/vector/le-003.test create mode 100644 tests/vector/le-004.test create mode 100644 tests/vector/le-005.test create mode 100644 tests/vector/le-006.test create mode 100644 tests/vector/le-007.test create mode 100644 tests/vector/le-008.test create mode 100644 tests/vector/lt-001.test create mode 100644 tests/vector/lt-002.test create mode 100644 tests/vector/lt-003.test create mode 100644 tests/vector/lt-004.test create mode 100644 tests/vector/lt-005.test create mode 100644 tests/vector/lt-006.test create mode 100644 tests/vector/lt-007.test create mode 100644 tests/vector/lt-008.test create mode 100644 tests/vector/ne-001.test create mode 100644 tests/vector/ne-002.test create mode 100644 tests/vector/ne-003.test create mode 100644 tests/vector/ne-004.test create mode 100644 tests/vector/ne-005.test create mode 100644 tests/vector/ne-006.test diff --git a/tests/vector/add-001.test b/tests/vector/add-001.test index ed1cb4e..7d73a28 100644 --- a/tests/vector/add-001.test +++ b/tests/vector/add-001.test @@ -152,7 +152,7 @@ int main() printf("%d\n", x[I]); } - return 0; + return 0; } --EXPECT-- 42.42 diff --git a/tests/vector/add-002.test b/tests/vector/add-002.test index 6a995b2..0249a5f 100644 --- a/tests/vector/add-002.test +++ b/tests/vector/add-002.test @@ -152,7 +152,7 @@ int main() printf("%d\n", x[I]); } - return 0; + return 0; } --EXPECT-- 42.42 diff --git a/tests/vector/add-003.test b/tests/vector/add-003.test index 8c1bc33..0cacb4a 100644 --- a/tests/vector/add-003.test +++ b/tests/vector/add-003.test @@ -152,7 +152,7 @@ int main() printf("%d\n", x[I]); } - return 0; + return 0; } --EXPECT-- 42.42 diff --git a/tests/vector/add-004.test b/tests/vector/add-004.test index 97468ec..dc14bfd 100644 --- a/tests/vector/add-004.test +++ b/tests/vector/add-004.test @@ -152,7 +152,7 @@ int main() printf("%d\n", x[I]); } - return 0; + return 0; } --EXPECT-- 42.42 diff --git a/tests/vector/add-005.test b/tests/vector/add-005.test index e7fe1d1..938a5e2 100644 --- a/tests/vector/add-005.test +++ b/tests/vector/add-005.test @@ -152,7 +152,7 @@ int main() printf("%d\n", x[I]); } - return 0; + return 0; } --EXPECT-- 42.42 diff --git a/tests/vector/add-006.test b/tests/vector/add-006.test index c138b37..e49c13f 100644 --- a/tests/vector/add-006.test +++ b/tests/vector/add-006.test @@ -152,7 +152,7 @@ int main() printf("%d\n", x[I]); } - return 0; + return 0; } --EXPECT-- 42.42 diff --git a/tests/vector/add-007.test b/tests/vector/add-007.test index 000cca0..b9df0c4 100644 --- a/tests/vector/add-007.test +++ b/tests/vector/add-007.test @@ -152,7 +152,7 @@ int main() printf("%d\n", x[I]); } - return 0; + return 0; } --EXPECT-- 42.42 diff --git a/tests/vector/add-008.test b/tests/vector/add-008.test index 7334708..e1766ce 100644 --- a/tests/vector/add-008.test +++ b/tests/vector/add-008.test @@ -152,7 +152,7 @@ int main() printf("%d\n", x[I]); } - return 0; + return 0; } --EXPECT-- 42.42 diff --git a/tests/vector/add-009.test b/tests/vector/add-009.test index 9583329..0e45c28 100644 --- a/tests/vector/add-009.test +++ b/tests/vector/add-009.test @@ -152,7 +152,7 @@ int main() printf("%d\n", x[I]); } - return 0; + return 0; } --EXPECT-- 42.42 diff --git a/tests/vector/add-010.test b/tests/vector/add-010.test index 8e6d574..f6a4175 100644 --- a/tests/vector/add-010.test +++ b/tests/vector/add-010.test @@ -152,7 +152,7 @@ int main() printf("%d\n", x[I]); } - return 0; + return 0; } --EXPECT-- 42.42 diff --git a/tests/vector/eq-001.test b/tests/vector/eq-001.test new file mode 100644 index 0000000..6354d71 --- /dev/null +++ b/tests/vector/eq-001.test @@ -0,0 +1,199 @@ +--TEST-- +EQ.001: 128-bit vectors SSE2 +--TARGET-- +!aarch64 +--ARGS-- +-mno-sse4 -mno-avx2 --run +--CODE-- +#define N 16 +#define I 1 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef double __attribute__((__vector_size__(N))) v_d; +typedef float __attribute__((__vector_size__(N))) v_f; +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_d __attribute__((noinline)) test_v_d(v_d v, double x, double y) +{ + return (v + x == y); +} + +v_f __attribute__((noinline)) test_v_f(v_f v, float x, float y) +{ + return (v + x == y); +} + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x, i64 y) +{ + return (v + x == y); +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x, u64 y) +{ + return (v + x == y); +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x, i32 y) +{ + return (v + x == y); +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x, u32 y) +{ + return (v + x == y); +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x, i16 y) +{ + return (v + x == y); +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x, u16 y) +{ + return (v + x == y); +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x, i8 y) +{ + return (v + x == y); +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x, u8 y) +{ + return (v + x == y); +} + +int main() +{ + { + v_d x = {}; + v_i64 y; + y = (v_i64)test_v_d(x, 42.42, 42.42); + printf("%lld\n", y[I]); + x = (v_d){}; + y = (v_i64)test_v_d(x, 42.42, 13.13); + printf("%lld\n", y[I]); + } + + { + v_f x = {}; + v_i32 y; + y = (v_i32)test_v_f(x, 42.42, 42.42); + printf("%d\n", y[I]); + x = (v_f){}; + y = (v_i32)test_v_f(x, 42.42, 13.13); + printf("%d\n", y[I]); + } + + { + v_i64 x = {}; + x = test_v_i64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_i64){}; + x = test_v_i64(x, 42, 13); + printf("%lld\n", x[I]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_u64){}; + x = test_v_u64(x, 42, 13); + printf("%lld\n", x[I]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i32){}; + x = test_v_i32(x, 42, 13); + printf("%d\n", x[I]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_u32){}; + x = test_v_u32(x, 42, 13); + printf("%d\n", x[I]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i16){}; + x = test_v_i16(x, 42, 13); + printf("%d\n", x[I]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42, 42); + printf("%d\n", (i16)x[I]); + x = (v_u16){}; + x = test_v_u16(x, 42, 13); + printf("%d\n", (i16)x[I]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i8){}; + x = test_v_i8(x, 42, 13); + printf("%d\n", x[I]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42, 42); + printf("%d\n", (i8)x[I]); + x = (v_u8){}; + x = test_v_u8(x, 42, 13); + printf("%d\n", (i8)x[I]); + } + + return 0; +} +--EXPECT-- +-1 +0 +-1 +0 +-1 +0 +-1 +0 +-1 +0 +-1 +0 +-1 +0 +-1 +0 +-1 +0 +-1 +0 diff --git a/tests/vector/eq-002.test b/tests/vector/eq-002.test new file mode 100644 index 0000000..5e31a09 --- /dev/null +++ b/tests/vector/eq-002.test @@ -0,0 +1,199 @@ +--TEST-- +EQ.002: 128-bit vectors SSE2+SSE4 +--TARGET-- +!aarch64 +--ARGS-- +-mno-avx2 --run +--CODE-- +#define N 16 +#define I 1 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef double __attribute__((__vector_size__(N))) v_d; +typedef float __attribute__((__vector_size__(N))) v_f; +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_d __attribute__((noinline)) test_v_d(v_d v, double x, double y) +{ + return (v + x == y); +} + +v_f __attribute__((noinline)) test_v_f(v_f v, float x, float y) +{ + return (v + x == y); +} + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x, i64 y) +{ + return (v + x == y); +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x, u64 y) +{ + return (v + x == y); +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x, i32 y) +{ + return (v + x == y); +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x, u32 y) +{ + return (v + x == y); +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x, i16 y) +{ + return (v + x == y); +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x, u16 y) +{ + return (v + x == y); +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x, i8 y) +{ + return (v + x == y); +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x, u8 y) +{ + return (v + x == y); +} + +int main() +{ + { + v_d x = {}; + v_i64 y; + y = (v_i64)test_v_d(x, 42.42, 42.42); + printf("%lld\n", y[I]); + x = (v_d){}; + y = (v_i64)test_v_d(x, 42.42, 13.13); + printf("%lld\n", y[I]); + } + + { + v_f x = {}; + v_i32 y; + y = (v_i32)test_v_f(x, 42.42, 42.42); + printf("%d\n", y[I]); + x = (v_f){}; + y = (v_i32)test_v_f(x, 42.42, 13.13); + printf("%d\n", y[I]); + } + + { + v_i64 x = {}; + x = test_v_i64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_i64){}; + x = test_v_i64(x, 42, 13); + printf("%lld\n", x[I]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_u64){}; + x = test_v_u64(x, 42, 13); + printf("%lld\n", x[I]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i32){}; + x = test_v_i32(x, 42, 13); + printf("%d\n", x[I]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_u32){}; + x = test_v_u32(x, 42, 13); + printf("%d\n", x[I]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i16){}; + x = test_v_i16(x, 42, 13); + printf("%d\n", x[I]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42, 42); + printf("%d\n", (i16)x[I]); + x = (v_u16){}; + x = test_v_u16(x, 42, 13); + printf("%d\n", (i16)x[I]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i8){}; + x = test_v_i8(x, 42, 13); + printf("%d\n", x[I]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42, 42); + printf("%d\n", (i8)x[I]); + x = (v_u8){}; + x = test_v_u8(x, 42, 13); + printf("%d\n", (i8)x[I]); + } + + return 0; +} +--EXPECT-- +-1 +0 +-1 +0 +-1 +0 +-1 +0 +-1 +0 +-1 +0 +-1 +0 +-1 +0 +-1 +0 +-1 +0 diff --git a/tests/vector/eq-003.test b/tests/vector/eq-003.test new file mode 100644 index 0000000..ad24549 --- /dev/null +++ b/tests/vector/eq-003.test @@ -0,0 +1,199 @@ +--TEST-- +EQ.003: 128-bit vectors AVX +--TARGET-- +!aarch64 +--ARGS-- +-mavx -mno-avx2 --run +--CODE-- +#define N 16 +#define I 1 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef double __attribute__((__vector_size__(N))) v_d; +typedef float __attribute__((__vector_size__(N))) v_f; +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_d __attribute__((noinline)) test_v_d(v_d v, double x, double y) +{ + return (v + x == y); +} + +v_f __attribute__((noinline)) test_v_f(v_f v, float x, float y) +{ + return (v + x == y); +} + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x, i64 y) +{ + return (v + x == y); +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x, u64 y) +{ + return (v + x == y); +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x, i32 y) +{ + return (v + x == y); +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x, u32 y) +{ + return (v + x == y); +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x, i16 y) +{ + return (v + x == y); +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x, u16 y) +{ + return (v + x == y); +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x, i8 y) +{ + return (v + x == y); +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x, u8 y) +{ + return (v + x == y); +} + +int main() +{ + { + v_d x = {}; + v_i64 y; + y = (v_i64)test_v_d(x, 42.42, 42.42); + printf("%lld\n", y[I]); + x = (v_d){}; + y = (v_i64)test_v_d(x, 42.42, 13.13); + printf("%lld\n", y[I]); + } + + { + v_f x = {}; + v_i32 y; + y = (v_i32)test_v_f(x, 42.42, 42.42); + printf("%d\n", y[I]); + x = (v_f){}; + y = (v_i32)test_v_f(x, 42.42, 13.13); + printf("%d\n", y[I]); + } + + { + v_i64 x = {}; + x = test_v_i64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_i64){}; + x = test_v_i64(x, 42, 13); + printf("%lld\n", x[I]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_u64){}; + x = test_v_u64(x, 42, 13); + printf("%lld\n", x[I]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i32){}; + x = test_v_i32(x, 42, 13); + printf("%d\n", x[I]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_u32){}; + x = test_v_u32(x, 42, 13); + printf("%d\n", x[I]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i16){}; + x = test_v_i16(x, 42, 13); + printf("%d\n", x[I]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42, 42); + printf("%d\n", (i16)x[I]); + x = (v_u16){}; + x = test_v_u16(x, 42, 13); + printf("%d\n", (i16)x[I]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i8){}; + x = test_v_i8(x, 42, 13); + printf("%d\n", x[I]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42, 42); + printf("%d\n", (i8)x[I]); + x = (v_u8){}; + x = test_v_u8(x, 42, 13); + printf("%d\n", (i8)x[I]); + } + + return 0; +} +--EXPECT-- +-1 +0 +-1 +0 +-1 +0 +-1 +0 +-1 +0 +-1 +0 +-1 +0 +-1 +0 +-1 +0 +-1 +0 diff --git a/tests/vector/eq-004.test b/tests/vector/eq-004.test new file mode 100644 index 0000000..8bb18ec --- /dev/null +++ b/tests/vector/eq-004.test @@ -0,0 +1,199 @@ +--TEST-- +EQ.004: 64-bit vectors SSE2 +--TARGET-- +!aarch64 +--ARGS-- +-mno-sse4 -mno-avx2 --run +--CODE-- +#define N 8 +#define I 0 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef double __attribute__((__vector_size__(N))) v_d; +typedef float __attribute__((__vector_size__(N))) v_f; +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_d __attribute__((noinline)) test_v_d(v_d v, double x, double y) +{ + return (v + x == y); +} + +v_f __attribute__((noinline)) test_v_f(v_f v, float x, float y) +{ + return (v + x == y); +} + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x, i64 y) +{ + return (v + x == y); +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x, u64 y) +{ + return (v + x == y); +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x, i32 y) +{ + return (v + x == y); +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x, u32 y) +{ + return (v + x == y); +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x, i16 y) +{ + return (v + x == y); +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x, u16 y) +{ + return (v + x == y); +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x, i8 y) +{ + return (v + x == y); +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x, u8 y) +{ + return (v + x == y); +} + +int main() +{ + { + v_d x = {}; + v_i64 y; + y = (v_i64)test_v_d(x, 42.42, 42.42); + printf("%lld\n", y[I]); + x = (v_d){}; + y = (v_i64)test_v_d(x, 42.42, 13.13); + printf("%lld\n", y[I]); + } + + { + v_f x = {}; + v_i32 y; + y = (v_i32)test_v_f(x, 42.42, 42.42); + printf("%d\n", y[I]); + x = (v_f){}; + y = (v_i32)test_v_f(x, 42.42, 13.13); + printf("%d\n", y[I]); + } + + { + v_i64 x = {}; + x = test_v_i64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_i64){}; + x = test_v_i64(x, 42, 13); + printf("%lld\n", x[I]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_u64){}; + x = test_v_u64(x, 42, 13); + printf("%lld\n", x[I]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i32){}; + x = test_v_i32(x, 42, 13); + printf("%d\n", x[I]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_u32){}; + x = test_v_u32(x, 42, 13); + printf("%d\n", x[I]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i16){}; + x = test_v_i16(x, 42, 13); + printf("%d\n", x[I]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42, 42); + printf("%d\n", (i16)x[I]); + x = (v_u16){}; + x = test_v_u16(x, 42, 13); + printf("%d\n", (i16)x[I]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i8){}; + x = test_v_i8(x, 42, 13); + printf("%d\n", x[I]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42, 42); + printf("%d\n", (i8)x[I]); + x = (v_u8){}; + x = test_v_u8(x, 42, 13); + printf("%d\n", (i8)x[I]); + } + + return 0; +} +--EXPECT-- +-1 +0 +-1 +0 +-1 +0 +-1 +0 +-1 +0 +-1 +0 +-1 +0 +-1 +0 +-1 +0 +-1 +0 diff --git a/tests/vector/eq-005.test b/tests/vector/eq-005.test new file mode 100644 index 0000000..65dfdcc --- /dev/null +++ b/tests/vector/eq-005.test @@ -0,0 +1,199 @@ +--TEST-- +EQ.005: 256-bit vectors AVX +--TARGET-- +!aarch64 +--ARGS-- +-mavx -mno-avx2 --run +--CODE-- +#define N 32 +#define I 3 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef double __attribute__((__vector_size__(N))) v_d; +typedef float __attribute__((__vector_size__(N))) v_f; +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_d __attribute__((noinline)) test_v_d(v_d v, double x, double y) +{ + return (v + x == y); +} + +v_f __attribute__((noinline)) test_v_f(v_f v, float x, float y) +{ + return (v + x == y); +} + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x, i64 y) +{ + return (v + x == y); +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x, u64 y) +{ + return (v + x == y); +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x, i32 y) +{ + return (v + x == y); +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x, u32 y) +{ + return (v + x == y); +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x, i16 y) +{ + return (v + x == y); +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x, u16 y) +{ + return (v + x == y); +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x, i8 y) +{ + return (v + x == y); +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x, u8 y) +{ + return (v + x == y); +} + +int main() +{ + { + v_d x = {}; + v_i64 y; + y = (v_i64)test_v_d(x, 42.42, 42.42); + printf("%lld\n", y[I]); + x = (v_d){}; + y = (v_i64)test_v_d(x, 42.42, 13.13); + printf("%lld\n", y[I]); + } + + { + v_f x = {}; + v_i32 y; + y = (v_i32)test_v_f(x, 42.42, 42.42); + printf("%d\n", y[I]); + x = (v_f){}; + y = (v_i32)test_v_f(x, 42.42, 13.13); + printf("%d\n", y[I]); + } + + { + v_i64 x = {}; + x = test_v_i64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_i64){}; + x = test_v_i64(x, 42, 13); + printf("%lld\n", x[I]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_u64){}; + x = test_v_u64(x, 42, 13); + printf("%lld\n", x[I]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i32){}; + x = test_v_i32(x, 42, 13); + printf("%d\n", x[I]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_u32){}; + x = test_v_u32(x, 42, 13); + printf("%d\n", x[I]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i16){}; + x = test_v_i16(x, 42, 13); + printf("%d\n", x[I]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42, 42); + printf("%d\n", (i16)x[I]); + x = (v_u16){}; + x = test_v_u16(x, 42, 13); + printf("%d\n", (i16)x[I]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i8){}; + x = test_v_i8(x, 42, 13); + printf("%d\n", x[I]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42, 42); + printf("%d\n", (i8)x[I]); + x = (v_u8){}; + x = test_v_u8(x, 42, 13); + printf("%d\n", (i8)x[I]); + } + + return 0; +} +--EXPECT-- +-1 +0 +-1 +0 +-1 +0 +-1 +0 +-1 +0 +-1 +0 +-1 +0 +-1 +0 +-1 +0 +-1 +0 diff --git a/tests/vector/eq-006.test b/tests/vector/eq-006.test new file mode 100644 index 0000000..71e7a1b --- /dev/null +++ b/tests/vector/eq-006.test @@ -0,0 +1,199 @@ +--TEST-- +EQ.006: 128-bit vectors SSE +--TARGET-- +!aarch64 +--ARGS-- +-mno-sse4 -mno-avx2 --run +--CODE-- +#define N 16 +#define I 1 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef double __attribute__((__vector_size__(N))) v_d; +typedef float __attribute__((__vector_size__(N))) v_f; +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_d __attribute__((noinline)) test_v_d(v_d v, double x) +{ + return (v + x == 42.42); +} + +v_f __attribute__((noinline)) test_v_f(v_f v, float x) +{ + return (v + x == 42.42f); +} + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x) +{ + return (v + x == 42); +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x) +{ + return (v + x == 42); +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x) +{ + return (v + x == 42); +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x) +{ + return (v + x == 42); +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x) +{ + return (v + x == 42); +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x) +{ + return (v + x == 42); +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x) +{ + return (v + x == 42); +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x) +{ + return (v + x == 42); +} + +int main() +{ + { + v_d x = {}; + v_i64 y; + y = (v_i64)test_v_d(x, 42.42); + printf("%lld\n", y[I]); + x = (v_d){}; + y = (v_i64)test_v_d(x, 13.13); + printf("%lld\n", y[I]); + } + + { + v_f x = {}; + v_i32 y; + y = (v_i32)test_v_f(x, 42.42); + printf("%d\n", y[I]); + x = (v_f){}; + y = (v_i32)test_v_f(x, 13.13); + printf("%d\n", y[I]); + } + + { + v_i64 x = {}; + x = test_v_i64(x, 42); + printf("%lld\n", x[I]); + x = (v_i64){}; + x = test_v_i64(x, 13); + printf("%lld\n", x[I]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42); + printf("%lld\n", x[I]); + x = (v_u64){}; + x = test_v_u64(x, 13); + printf("%lld\n", x[I]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42); + printf("%d\n", x[I]); + x = (v_i32){}; + x = test_v_i32(x, 13); + printf("%d\n", x[I]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42); + printf("%d\n", x[I]); + x = (v_u32){}; + x = test_v_u32(x, 13); + printf("%d\n", x[I]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42); + printf("%d\n", x[I]); + x = (v_i16){}; + x = test_v_i16(x, 13); + printf("%d\n", x[I]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42); + printf("%d\n", (i16)x[I]); + x = (v_u16){}; + x = test_v_u16(x, 13); + printf("%d\n", (i16)x[I]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42); + printf("%d\n", x[I]); + x = (v_i8){}; + x = test_v_i8(x, 13); + printf("%d\n", x[I]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42); + printf("%d\n", (i8)x[I]); + x = (v_u8){}; + x = test_v_u8(x, 13); + printf("%d\n", (i8)x[I]); + } + + return 0; +} +--EXPECT-- +-1 +0 +-1 +0 +-1 +0 +-1 +0 +-1 +0 +-1 +0 +-1 +0 +-1 +0 +-1 +0 +-1 +0 diff --git a/tests/vector/ge-001.test b/tests/vector/ge-001.test new file mode 100644 index 0000000..cd7524a --- /dev/null +++ b/tests/vector/ge-001.test @@ -0,0 +1,239 @@ +--TEST-- +GE.001: 128-bit vectors SSE2 +--TARGET-- +!aarch64 +--ARGS-- +-mno-sse4 -mno-avx2 --run +--CODE-- +#define N 16 +#define I 1 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef double __attribute__((__vector_size__(N))) v_d; +typedef float __attribute__((__vector_size__(N))) v_f; +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_d __attribute__((noinline)) test_v_d(v_d v, double x, double y) +{ + return (v + x >= y); +} + +v_f __attribute__((noinline)) test_v_f(v_f v, float x, float y) +{ + return (v + x >= y); +} + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x, i64 y) +{ + return (v + x >= y); +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x, u64 y) +{ + return (v + x >= y); +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x, i32 y) +{ + return (v + x >= y); +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x, u32 y) +{ + return (v + x >= y); +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x, i16 y) +{ + return (v + x >= y); +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x, u16 y) +{ + return (v + x >= y); +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x, i8 y) +{ + return (v + x >= y); +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x, u8 y) +{ + return (v + x >= y); +} + +int main() +{ + { + v_d x = {}; + v_i64 y; + y = (v_i64)test_v_d(x, 42.42, 42.42); + printf("%lld\n", y[I]); + x = (v_d){}; + y = (v_i64)test_v_d(x, 42.42, 13.13); + printf("%lld\n", y[I]); + x = (v_d){}; + y = (v_i64)test_v_d(x, 42.42, 55.55); + printf("%lld\n", y[I]); + } + + { + v_f x = {}; + v_i32 y; + y = (v_i32)test_v_f(x, 42.42, 42.42); + printf("%d\n", y[I]); + x = (v_f){}; + y = (v_i32)test_v_f(x, 42.42, 13.13); + printf("%d\n", y[I]); + x = (v_f){}; + y = (v_i32)test_v_f(x, 42.42, 55.55); + printf("%d\n", y[I]); + } + + { + v_i64 x = {}; + x = test_v_i64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_i64){}; + x = test_v_i64(x, 42, 13); + printf("%lld\n", x[I]); + x = (v_i64){}; + x = test_v_i64(x, 42, 55); + printf("%lld\n", x[I]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_u64){}; + x = test_v_u64(x, 42, 13); + printf("%lld\n", x[I]); + x = (v_u64){}; + x = test_v_u64(x, 42, 55); + printf("%lld\n", x[I]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i32){}; + x = test_v_i32(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i32){}; + x = test_v_i32(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_u32){}; + x = test_v_u32(x, 42, 13); + printf("%d\n", x[I]); + x = (v_u32){}; + x = test_v_u32(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i16){}; + x = test_v_i16(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i16){}; + x = test_v_i16(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42, 42); + printf("%d\n", (i16)x[I]); + x = (v_u16){}; + x = test_v_u16(x, 42, 13); + printf("%d\n", (i16)x[I]); + x = (v_u16){}; + x = test_v_u16(x, 42, 55); + printf("%d\n", (i16)x[I]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i8){}; + x = test_v_i8(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i8){}; + x = test_v_i8(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42, 42); + printf("%d\n", (i8)x[I]); + x = (v_u8){}; + x = test_v_u8(x, 42, 13); + printf("%d\n", (i8)x[I]); + x = (v_u8){}; + x = test_v_u8(x, 42, 55); + printf("%d\n", (i8)x[I]); + } + + return 0; +} +--EXPECT-- +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 diff --git a/tests/vector/ge-002.test b/tests/vector/ge-002.test new file mode 100644 index 0000000..233f121 --- /dev/null +++ b/tests/vector/ge-002.test @@ -0,0 +1,239 @@ +--TEST-- +GE.002: 128-bit vectors SSE2+SSE4 +--TARGET-- +!aarch64 +--ARGS-- +-mno-avx2 --run +--CODE-- +#define N 16 +#define I 1 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef double __attribute__((__vector_size__(N))) v_d; +typedef float __attribute__((__vector_size__(N))) v_f; +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_d __attribute__((noinline)) test_v_d(v_d v, double x, double y) +{ + return (v + x >= y); +} + +v_f __attribute__((noinline)) test_v_f(v_f v, float x, float y) +{ + return (v + x >= y); +} + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x, i64 y) +{ + return (v + x >= y); +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x, u64 y) +{ + return (v + x >= y); +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x, i32 y) +{ + return (v + x >= y); +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x, u32 y) +{ + return (v + x >= y); +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x, i16 y) +{ + return (v + x >= y); +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x, u16 y) +{ + return (v + x >= y); +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x, i8 y) +{ + return (v + x >= y); +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x, u8 y) +{ + return (v + x >= y); +} + +int main() +{ + { + v_d x = {}; + v_i64 y; + y = (v_i64)test_v_d(x, 42.42, 42.42); + printf("%lld\n", y[I]); + x = (v_d){}; + y = (v_i64)test_v_d(x, 42.42, 13.13); + printf("%lld\n", y[I]); + x = (v_d){}; + y = (v_i64)test_v_d(x, 42.42, 55.55); + printf("%lld\n", y[I]); + } + + { + v_f x = {}; + v_i32 y; + y = (v_i32)test_v_f(x, 42.42, 42.42); + printf("%d\n", y[I]); + x = (v_f){}; + y = (v_i32)test_v_f(x, 42.42, 13.13); + printf("%d\n", y[I]); + x = (v_f){}; + y = (v_i32)test_v_f(x, 42.42, 55.55); + printf("%d\n", y[I]); + } + + { + v_i64 x = {}; + x = test_v_i64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_i64){}; + x = test_v_i64(x, 42, 13); + printf("%lld\n", x[I]); + x = (v_i64){}; + x = test_v_i64(x, 42, 55); + printf("%lld\n", x[I]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_u64){}; + x = test_v_u64(x, 42, 13); + printf("%lld\n", x[I]); + x = (v_u64){}; + x = test_v_u64(x, 42, 55); + printf("%lld\n", x[I]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i32){}; + x = test_v_i32(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i32){}; + x = test_v_i32(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_u32){}; + x = test_v_u32(x, 42, 13); + printf("%d\n", x[I]); + x = (v_u32){}; + x = test_v_u32(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i16){}; + x = test_v_i16(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i16){}; + x = test_v_i16(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42, 42); + printf("%d\n", (i16)x[I]); + x = (v_u16){}; + x = test_v_u16(x, 42, 13); + printf("%d\n", (i16)x[I]); + x = (v_u16){}; + x = test_v_u16(x, 42, 55); + printf("%d\n", (i16)x[I]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i8){}; + x = test_v_i8(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i8){}; + x = test_v_i8(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42, 42); + printf("%d\n", (i8)x[I]); + x = (v_u8){}; + x = test_v_u8(x, 42, 13); + printf("%d\n", (i8)x[I]); + x = (v_u8){}; + x = test_v_u8(x, 42, 55); + printf("%d\n", (i8)x[I]); + } + + return 0; +} +--EXPECT-- +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 diff --git a/tests/vector/ge-003.test b/tests/vector/ge-003.test new file mode 100644 index 0000000..b235997 --- /dev/null +++ b/tests/vector/ge-003.test @@ -0,0 +1,239 @@ +--TEST-- +GE.003: 128-bit vectors AVX +--TARGET-- +!aarch64 +--ARGS-- +-mavx -mno-avx2 --run +--CODE-- +#define N 16 +#define I 1 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef double __attribute__((__vector_size__(N))) v_d; +typedef float __attribute__((__vector_size__(N))) v_f; +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_d __attribute__((noinline)) test_v_d(v_d v, double x, double y) +{ + return (v + x >= y); +} + +v_f __attribute__((noinline)) test_v_f(v_f v, float x, float y) +{ + return (v + x >= y); +} + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x, i64 y) +{ + return (v + x >= y); +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x, u64 y) +{ + return (v + x >= y); +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x, i32 y) +{ + return (v + x >= y); +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x, u32 y) +{ + return (v + x >= y); +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x, i16 y) +{ + return (v + x >= y); +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x, u16 y) +{ + return (v + x >= y); +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x, i8 y) +{ + return (v + x >= y); +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x, u8 y) +{ + return (v + x >= y); +} + +int main() +{ + { + v_d x = {}; + v_i64 y; + y = (v_i64)test_v_d(x, 42.42, 42.42); + printf("%lld\n", y[I]); + x = (v_d){}; + y = (v_i64)test_v_d(x, 42.42, 13.13); + printf("%lld\n", y[I]); + x = (v_d){}; + y = (v_i64)test_v_d(x, 42.42, 55.55); + printf("%lld\n", y[I]); + } + + { + v_f x = {}; + v_i32 y; + y = (v_i32)test_v_f(x, 42.42, 42.42); + printf("%d\n", y[I]); + x = (v_f){}; + y = (v_i32)test_v_f(x, 42.42, 13.13); + printf("%d\n", y[I]); + x = (v_f){}; + y = (v_i32)test_v_f(x, 42.42, 55.55); + printf("%d\n", y[I]); + } + + { + v_i64 x = {}; + x = test_v_i64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_i64){}; + x = test_v_i64(x, 42, 13); + printf("%lld\n", x[I]); + x = (v_i64){}; + x = test_v_i64(x, 42, 55); + printf("%lld\n", x[I]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_u64){}; + x = test_v_u64(x, 42, 13); + printf("%lld\n", x[I]); + x = (v_u64){}; + x = test_v_u64(x, 42, 55); + printf("%lld\n", x[I]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i32){}; + x = test_v_i32(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i32){}; + x = test_v_i32(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_u32){}; + x = test_v_u32(x, 42, 13); + printf("%d\n", x[I]); + x = (v_u32){}; + x = test_v_u32(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i16){}; + x = test_v_i16(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i16){}; + x = test_v_i16(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42, 42); + printf("%d\n", (i16)x[I]); + x = (v_u16){}; + x = test_v_u16(x, 42, 13); + printf("%d\n", (i16)x[I]); + x = (v_u16){}; + x = test_v_u16(x, 42, 55); + printf("%d\n", (i16)x[I]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i8){}; + x = test_v_i8(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i8){}; + x = test_v_i8(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42, 42); + printf("%d\n", (i8)x[I]); + x = (v_u8){}; + x = test_v_u8(x, 42, 13); + printf("%d\n", (i8)x[I]); + x = (v_u8){}; + x = test_v_u8(x, 42, 55); + printf("%d\n", (i8)x[I]); + } + + return 0; +} +--EXPECT-- +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 diff --git a/tests/vector/ge-004.test b/tests/vector/ge-004.test new file mode 100644 index 0000000..7c20c10 --- /dev/null +++ b/tests/vector/ge-004.test @@ -0,0 +1,239 @@ +--TEST-- +GE.004: 128-bit vectors AVX+AVX2 +--TARGET-- +!aarch64 +--ARGS-- +-mavx --run +--CODE-- +#define N 16 +#define I 1 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef double __attribute__((__vector_size__(N))) v_d; +typedef float __attribute__((__vector_size__(N))) v_f; +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_d __attribute__((noinline)) test_v_d(v_d v, double x, double y) +{ + return (v + x >= y); +} + +v_f __attribute__((noinline)) test_v_f(v_f v, float x, float y) +{ + return (v + x >= y); +} + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x, i64 y) +{ + return (v + x >= y); +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x, u64 y) +{ + return (v + x >= y); +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x, i32 y) +{ + return (v + x >= y); +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x, u32 y) +{ + return (v + x >= y); +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x, i16 y) +{ + return (v + x >= y); +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x, u16 y) +{ + return (v + x >= y); +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x, i8 y) +{ + return (v + x >= y); +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x, u8 y) +{ + return (v + x >= y); +} + +int main() +{ + { + v_d x = {}; + v_i64 y; + y = (v_i64)test_v_d(x, 42.42, 42.42); + printf("%lld\n", y[I]); + x = (v_d){}; + y = (v_i64)test_v_d(x, 42.42, 13.13); + printf("%lld\n", y[I]); + x = (v_d){}; + y = (v_i64)test_v_d(x, 42.42, 55.55); + printf("%lld\n", y[I]); + } + + { + v_f x = {}; + v_i32 y; + y = (v_i32)test_v_f(x, 42.42, 42.42); + printf("%d\n", y[I]); + x = (v_f){}; + y = (v_i32)test_v_f(x, 42.42, 13.13); + printf("%d\n", y[I]); + x = (v_f){}; + y = (v_i32)test_v_f(x, 42.42, 55.55); + printf("%d\n", y[I]); + } + + { + v_i64 x = {}; + x = test_v_i64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_i64){}; + x = test_v_i64(x, 42, 13); + printf("%lld\n", x[I]); + x = (v_i64){}; + x = test_v_i64(x, 42, 55); + printf("%lld\n", x[I]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_u64){}; + x = test_v_u64(x, 42, 13); + printf("%lld\n", x[I]); + x = (v_u64){}; + x = test_v_u64(x, 42, 55); + printf("%lld\n", x[I]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i32){}; + x = test_v_i32(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i32){}; + x = test_v_i32(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_u32){}; + x = test_v_u32(x, 42, 13); + printf("%d\n", x[I]); + x = (v_u32){}; + x = test_v_u32(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i16){}; + x = test_v_i16(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i16){}; + x = test_v_i16(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42, 42); + printf("%d\n", (i16)x[I]); + x = (v_u16){}; + x = test_v_u16(x, 42, 13); + printf("%d\n", (i16)x[I]); + x = (v_u16){}; + x = test_v_u16(x, 42, 55); + printf("%d\n", (i16)x[I]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i8){}; + x = test_v_i8(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i8){}; + x = test_v_i8(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42, 42); + printf("%d\n", (i8)x[I]); + x = (v_u8){}; + x = test_v_u8(x, 42, 13); + printf("%d\n", (i8)x[I]); + x = (v_u8){}; + x = test_v_u8(x, 42, 55); + printf("%d\n", (i8)x[I]); + } + + return 0; +} +--EXPECT-- +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 diff --git a/tests/vector/ge-005.test b/tests/vector/ge-005.test new file mode 100644 index 0000000..444014e --- /dev/null +++ b/tests/vector/ge-005.test @@ -0,0 +1,239 @@ +--TEST-- +GE.005: 64-bit vectors SSE2 +--TARGET-- +!aarch64 +--ARGS-- +-mno-sse4 -mno-avx2 --run +--CODE-- +#define N 8 +#define I 0 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef double __attribute__((__vector_size__(N))) v_d; +typedef float __attribute__((__vector_size__(N))) v_f; +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_d __attribute__((noinline)) test_v_d(v_d v, double x, double y) +{ + return (v + x >= y); +} + +v_f __attribute__((noinline)) test_v_f(v_f v, float x, float y) +{ + return (v + x >= y); +} + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x, i64 y) +{ + return (v + x >= y); +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x, u64 y) +{ + return (v + x >= y); +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x, i32 y) +{ + return (v + x >= y); +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x, u32 y) +{ + return (v + x >= y); +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x, i16 y) +{ + return (v + x >= y); +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x, u16 y) +{ + return (v + x >= y); +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x, i8 y) +{ + return (v + x >= y); +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x, u8 y) +{ + return (v + x >= y); +} + +int main() +{ + { + v_d x = {}; + v_i64 y; + y = (v_i64)test_v_d(x, 42.42, 42.42); + printf("%lld\n", y[I]); + x = (v_d){}; + y = (v_i64)test_v_d(x, 42.42, 13.13); + printf("%lld\n", y[I]); + x = (v_d){}; + y = (v_i64)test_v_d(x, 42.42, 55.55); + printf("%lld\n", y[I]); + } + + { + v_f x = {}; + v_i32 y; + y = (v_i32)test_v_f(x, 42.42, 42.42); + printf("%d\n", y[I]); + x = (v_f){}; + y = (v_i32)test_v_f(x, 42.42, 13.13); + printf("%d\n", y[I]); + x = (v_f){}; + y = (v_i32)test_v_f(x, 42.42, 55.55); + printf("%d\n", y[I]); + } + + { + v_i64 x = {}; + x = test_v_i64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_i64){}; + x = test_v_i64(x, 42, 13); + printf("%lld\n", x[I]); + x = (v_i64){}; + x = test_v_i64(x, 42, 55); + printf("%lld\n", x[I]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_u64){}; + x = test_v_u64(x, 42, 13); + printf("%lld\n", x[I]); + x = (v_u64){}; + x = test_v_u64(x, 42, 55); + printf("%lld\n", x[I]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i32){}; + x = test_v_i32(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i32){}; + x = test_v_i32(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_u32){}; + x = test_v_u32(x, 42, 13); + printf("%d\n", x[I]); + x = (v_u32){}; + x = test_v_u32(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i16){}; + x = test_v_i16(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i16){}; + x = test_v_i16(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42, 42); + printf("%d\n", (i16)x[I]); + x = (v_u16){}; + x = test_v_u16(x, 42, 13); + printf("%d\n", (i16)x[I]); + x = (v_u16){}; + x = test_v_u16(x, 42, 55); + printf("%d\n", (i16)x[I]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i8){}; + x = test_v_i8(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i8){}; + x = test_v_i8(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42, 42); + printf("%d\n", (i8)x[I]); + x = (v_u8){}; + x = test_v_u8(x, 42, 13); + printf("%d\n", (i8)x[I]); + x = (v_u8){}; + x = test_v_u8(x, 42, 55); + printf("%d\n", (i8)x[I]); + } + + return 0; +} +--EXPECT-- +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 diff --git a/tests/vector/ge-006.test b/tests/vector/ge-006.test new file mode 100644 index 0000000..497c7d8 --- /dev/null +++ b/tests/vector/ge-006.test @@ -0,0 +1,239 @@ +--TEST-- +GE.006: 64-bit vectors AVX +--TARGET-- +!aarch64 +--ARGS-- +-mavx -mno-avx2 --run +--CODE-- +#define N 8 +#define I 0 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef double __attribute__((__vector_size__(N))) v_d; +typedef float __attribute__((__vector_size__(N))) v_f; +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_d __attribute__((noinline)) test_v_d(v_d v, double x, double y) +{ + return (v + x >= y); +} + +v_f __attribute__((noinline)) test_v_f(v_f v, float x, float y) +{ + return (v + x >= y); +} + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x, i64 y) +{ + return (v + x >= y); +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x, u64 y) +{ + return (v + x >= y); +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x, i32 y) +{ + return (v + x >= y); +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x, u32 y) +{ + return (v + x >= y); +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x, i16 y) +{ + return (v + x >= y); +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x, u16 y) +{ + return (v + x >= y); +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x, i8 y) +{ + return (v + x >= y); +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x, u8 y) +{ + return (v + x >= y); +} + +int main() +{ + { + v_d x = {}; + v_i64 y; + y = (v_i64)test_v_d(x, 42.42, 42.42); + printf("%lld\n", y[I]); + x = (v_d){}; + y = (v_i64)test_v_d(x, 42.42, 13.13); + printf("%lld\n", y[I]); + x = (v_d){}; + y = (v_i64)test_v_d(x, 42.42, 55.55); + printf("%lld\n", y[I]); + } + + { + v_f x = {}; + v_i32 y; + y = (v_i32)test_v_f(x, 42.42, 42.42); + printf("%d\n", y[I]); + x = (v_f){}; + y = (v_i32)test_v_f(x, 42.42, 13.13); + printf("%d\n", y[I]); + x = (v_f){}; + y = (v_i32)test_v_f(x, 42.42, 55.55); + printf("%d\n", y[I]); + } + + { + v_i64 x = {}; + x = test_v_i64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_i64){}; + x = test_v_i64(x, 42, 13); + printf("%lld\n", x[I]); + x = (v_i64){}; + x = test_v_i64(x, 42, 55); + printf("%lld\n", x[I]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_u64){}; + x = test_v_u64(x, 42, 13); + printf("%lld\n", x[I]); + x = (v_u64){}; + x = test_v_u64(x, 42, 55); + printf("%lld\n", x[I]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i32){}; + x = test_v_i32(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i32){}; + x = test_v_i32(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_u32){}; + x = test_v_u32(x, 42, 13); + printf("%d\n", x[I]); + x = (v_u32){}; + x = test_v_u32(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i16){}; + x = test_v_i16(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i16){}; + x = test_v_i16(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42, 42); + printf("%d\n", (i16)x[I]); + x = (v_u16){}; + x = test_v_u16(x, 42, 13); + printf("%d\n", (i16)x[I]); + x = (v_u16){}; + x = test_v_u16(x, 42, 55); + printf("%d\n", (i16)x[I]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i8){}; + x = test_v_i8(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i8){}; + x = test_v_i8(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42, 42); + printf("%d\n", (i8)x[I]); + x = (v_u8){}; + x = test_v_u8(x, 42, 13); + printf("%d\n", (i8)x[I]); + x = (v_u8){}; + x = test_v_u8(x, 42, 55); + printf("%d\n", (i8)x[I]); + } + + return 0; +} +--EXPECT-- +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 diff --git a/tests/vector/ge-007.test b/tests/vector/ge-007.test new file mode 100644 index 0000000..789715f --- /dev/null +++ b/tests/vector/ge-007.test @@ -0,0 +1,239 @@ +--TEST-- +GE.007: 256-bit vectors AVX +--TARGET-- +!aarch64 +--ARGS-- +-mavx -mno-avx2 --run +--CODE-- +#define N 32 +#define I 3 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef double __attribute__((__vector_size__(N))) v_d; +typedef float __attribute__((__vector_size__(N))) v_f; +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_d __attribute__((noinline)) test_v_d(v_d v, double x, double y) +{ + return (v + x >= y); +} + +v_f __attribute__((noinline)) test_v_f(v_f v, float x, float y) +{ + return (v + x >= y); +} + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x, i64 y) +{ + return (v + x >= y); +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x, u64 y) +{ + return (v + x >= y); +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x, i32 y) +{ + return (v + x >= y); +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x, u32 y) +{ + return (v + x >= y); +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x, i16 y) +{ + return (v + x >= y); +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x, u16 y) +{ + return (v + x >= y); +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x, i8 y) +{ + return (v + x >= y); +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x, u8 y) +{ + return (v + x >= y); +} + +int main() +{ + { + v_d x = {}; + v_i64 y; + y = (v_i64)test_v_d(x, 42.42, 42.42); + printf("%lld\n", y[I]); + x = (v_d){}; + y = (v_i64)test_v_d(x, 42.42, 13.13); + printf("%lld\n", y[I]); + x = (v_d){}; + y = (v_i64)test_v_d(x, 42.42, 55.55); + printf("%lld\n", y[I]); + } + + { + v_f x = {}; + v_i32 y; + y = (v_i32)test_v_f(x, 42.42, 42.42); + printf("%d\n", y[I]); + x = (v_f){}; + y = (v_i32)test_v_f(x, 42.42, 13.13); + printf("%d\n", y[I]); + x = (v_f){}; + y = (v_i32)test_v_f(x, 42.42, 55.55); + printf("%d\n", y[I]); + } + + { + v_i64 x = {}; + x = test_v_i64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_i64){}; + x = test_v_i64(x, 42, 13); + printf("%lld\n", x[I]); + x = (v_i64){}; + x = test_v_i64(x, 42, 55); + printf("%lld\n", x[I]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_u64){}; + x = test_v_u64(x, 42, 13); + printf("%lld\n", x[I]); + x = (v_u64){}; + x = test_v_u64(x, 42, 55); + printf("%lld\n", x[I]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i32){}; + x = test_v_i32(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i32){}; + x = test_v_i32(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_u32){}; + x = test_v_u32(x, 42, 13); + printf("%d\n", x[I]); + x = (v_u32){}; + x = test_v_u32(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i16){}; + x = test_v_i16(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i16){}; + x = test_v_i16(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42, 42); + printf("%d\n", (i16)x[I]); + x = (v_u16){}; + x = test_v_u16(x, 42, 13); + printf("%d\n", (i16)x[I]); + x = (v_u16){}; + x = test_v_u16(x, 42, 55); + printf("%d\n", (i16)x[I]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i8){}; + x = test_v_i8(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i8){}; + x = test_v_i8(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42, 42); + printf("%d\n", (i8)x[I]); + x = (v_u8){}; + x = test_v_u8(x, 42, 13); + printf("%d\n", (i8)x[I]); + x = (v_u8){}; + x = test_v_u8(x, 42, 55); + printf("%d\n", (i8)x[I]); + } + + return 0; +} +--EXPECT-- +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 diff --git a/tests/vector/ge-008.test b/tests/vector/ge-008.test new file mode 100644 index 0000000..0932487 --- /dev/null +++ b/tests/vector/ge-008.test @@ -0,0 +1,239 @@ +--TEST-- +GE.008: 256-bit vectors AVX+AVX2 +--TARGET-- +!aarch64 +--ARGS-- +-mavx --run +--CODE-- +#define N 32 +#define I 3 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef double __attribute__((__vector_size__(N))) v_d; +typedef float __attribute__((__vector_size__(N))) v_f; +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_d __attribute__((noinline)) test_v_d(v_d v, double x, double y) +{ + return (v + x >= y); +} + +v_f __attribute__((noinline)) test_v_f(v_f v, float x, float y) +{ + return (v + x >= y); +} + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x, i64 y) +{ + return (v + x >= y); +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x, u64 y) +{ + return (v + x >= y); +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x, i32 y) +{ + return (v + x >= y); +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x, u32 y) +{ + return (v + x >= y); +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x, i16 y) +{ + return (v + x >= y); +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x, u16 y) +{ + return (v + x >= y); +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x, i8 y) +{ + return (v + x >= y); +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x, u8 y) +{ + return (v + x >= y); +} + +int main() +{ + { + v_d x = {}; + v_i64 y; + y = (v_i64)test_v_d(x, 42.42, 42.42); + printf("%lld\n", y[I]); + x = (v_d){}; + y = (v_i64)test_v_d(x, 42.42, 13.13); + printf("%lld\n", y[I]); + x = (v_d){}; + y = (v_i64)test_v_d(x, 42.42, 55.55); + printf("%lld\n", y[I]); + } + + { + v_f x = {}; + v_i32 y; + y = (v_i32)test_v_f(x, 42.42, 42.42); + printf("%d\n", y[I]); + x = (v_f){}; + y = (v_i32)test_v_f(x, 42.42, 13.13); + printf("%d\n", y[I]); + x = (v_f){}; + y = (v_i32)test_v_f(x, 42.42, 55.55); + printf("%d\n", y[I]); + } + + { + v_i64 x = {}; + x = test_v_i64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_i64){}; + x = test_v_i64(x, 42, 13); + printf("%lld\n", x[I]); + x = (v_i64){}; + x = test_v_i64(x, 42, 55); + printf("%lld\n", x[I]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_u64){}; + x = test_v_u64(x, 42, 13); + printf("%lld\n", x[I]); + x = (v_u64){}; + x = test_v_u64(x, 42, 55); + printf("%lld\n", x[I]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i32){}; + x = test_v_i32(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i32){}; + x = test_v_i32(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_u32){}; + x = test_v_u32(x, 42, 13); + printf("%d\n", x[I]); + x = (v_u32){}; + x = test_v_u32(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i16){}; + x = test_v_i16(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i16){}; + x = test_v_i16(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42, 42); + printf("%d\n", (i16)x[I]); + x = (v_u16){}; + x = test_v_u16(x, 42, 13); + printf("%d\n", (i16)x[I]); + x = (v_u16){}; + x = test_v_u16(x, 42, 55); + printf("%d\n", (i16)x[I]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i8){}; + x = test_v_i8(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i8){}; + x = test_v_i8(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42, 42); + printf("%d\n", (i8)x[I]); + x = (v_u8){}; + x = test_v_u8(x, 42, 13); + printf("%d\n", (i8)x[I]); + x = (v_u8){}; + x = test_v_u8(x, 42, 55); + printf("%d\n", (i8)x[I]); + } + + return 0; +} +--EXPECT-- +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 diff --git a/tests/vector/gt-001.test b/tests/vector/gt-001.test new file mode 100644 index 0000000..49a794f --- /dev/null +++ b/tests/vector/gt-001.test @@ -0,0 +1,239 @@ +--TEST-- +GT.001: 128-bit vectors SSE2 +--TARGET-- +!aarch64 +--ARGS-- +-mno-sse4 -mno-avx2 --run +--CODE-- +#define N 16 +#define I 1 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef double __attribute__((__vector_size__(N))) v_d; +typedef float __attribute__((__vector_size__(N))) v_f; +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_d __attribute__((noinline)) test_v_d(v_d v, double x, double y) +{ + return (v + x > y); +} + +v_f __attribute__((noinline)) test_v_f(v_f v, float x, float y) +{ + return (v + x > y); +} + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x, i64 y) +{ + return (v + x > y); +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x, u64 y) +{ + return (v + x > y); +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x, i32 y) +{ + return (v + x > y); +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x, u32 y) +{ + return (v + x > y); +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x, i16 y) +{ + return (v + x > y); +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x, u16 y) +{ + return (v + x > y); +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x, i8 y) +{ + return (v + x > y); +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x, u8 y) +{ + return (v + x > y); +} + +int main() +{ + { + v_d x = {}; + v_i64 y; + y = (v_i64)test_v_d(x, 42.42, 42.42); + printf("%lld\n", y[I]); + x = (v_d){}; + y = (v_i64)test_v_d(x, 42.42, 13.13); + printf("%lld\n", y[I]); + x = (v_d){}; + y = (v_i64)test_v_d(x, 42.42, 55.55); + printf("%lld\n", y[I]); + } + + { + v_f x = {}; + v_i32 y; + y = (v_i32)test_v_f(x, 42.42, 42.42); + printf("%d\n", y[I]); + x = (v_f){}; + y = (v_i32)test_v_f(x, 42.42, 13.13); + printf("%d\n", y[I]); + x = (v_f){}; + y = (v_i32)test_v_f(x, 42.42, 55.55); + printf("%d\n", y[I]); + } + + { + v_i64 x = {}; + x = test_v_i64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_i64){}; + x = test_v_i64(x, 42, 13); + printf("%lld\n", x[I]); + x = (v_i64){}; + x = test_v_i64(x, 42, 55); + printf("%lld\n", x[I]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_u64){}; + x = test_v_u64(x, 42, 13); + printf("%lld\n", x[I]); + x = (v_u64){}; + x = test_v_u64(x, 42, 55); + printf("%lld\n", x[I]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i32){}; + x = test_v_i32(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i32){}; + x = test_v_i32(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_u32){}; + x = test_v_u32(x, 42, 13); + printf("%d\n", x[I]); + x = (v_u32){}; + x = test_v_u32(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i16){}; + x = test_v_i16(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i16){}; + x = test_v_i16(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42, 42); + printf("%d\n", (i16)x[I]); + x = (v_u16){}; + x = test_v_u16(x, 42, 13); + printf("%d\n", (i16)x[I]); + x = (v_u16){}; + x = test_v_u16(x, 42, 55); + printf("%d\n", (i16)x[I]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i8){}; + x = test_v_i8(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i8){}; + x = test_v_i8(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42, 42); + printf("%d\n", (i8)x[I]); + x = (v_u8){}; + x = test_v_u8(x, 42, 13); + printf("%d\n", (i8)x[I]); + x = (v_u8){}; + x = test_v_u8(x, 42, 55); + printf("%d\n", (i8)x[I]); + } + + return 0; +} +--EXPECT-- +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 diff --git a/tests/vector/gt-002.test b/tests/vector/gt-002.test new file mode 100644 index 0000000..07bbe13 --- /dev/null +++ b/tests/vector/gt-002.test @@ -0,0 +1,239 @@ +--TEST-- +GT.002: 128-bit vectors SSE2+SSE4 +--TARGET-- +!aarch64 +--ARGS-- +-mno-avx2 --run +--CODE-- +#define N 16 +#define I 1 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef double __attribute__((__vector_size__(N))) v_d; +typedef float __attribute__((__vector_size__(N))) v_f; +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_d __attribute__((noinline)) test_v_d(v_d v, double x, double y) +{ + return (v + x > y); +} + +v_f __attribute__((noinline)) test_v_f(v_f v, float x, float y) +{ + return (v + x > y); +} + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x, i64 y) +{ + return (v + x > y); +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x, u64 y) +{ + return (v + x > y); +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x, i32 y) +{ + return (v + x > y); +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x, u32 y) +{ + return (v + x > y); +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x, i16 y) +{ + return (v + x > y); +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x, u16 y) +{ + return (v + x > y); +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x, i8 y) +{ + return (v + x > y); +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x, u8 y) +{ + return (v + x > y); +} + +int main() +{ + { + v_d x = {}; + v_i64 y; + y = (v_i64)test_v_d(x, 42.42, 42.42); + printf("%lld\n", y[I]); + x = (v_d){}; + y = (v_i64)test_v_d(x, 42.42, 13.13); + printf("%lld\n", y[I]); + x = (v_d){}; + y = (v_i64)test_v_d(x, 42.42, 55.55); + printf("%lld\n", y[I]); + } + + { + v_f x = {}; + v_i32 y; + y = (v_i32)test_v_f(x, 42.42, 42.42); + printf("%d\n", y[I]); + x = (v_f){}; + y = (v_i32)test_v_f(x, 42.42, 13.13); + printf("%d\n", y[I]); + x = (v_f){}; + y = (v_i32)test_v_f(x, 42.42, 55.55); + printf("%d\n", y[I]); + } + + { + v_i64 x = {}; + x = test_v_i64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_i64){}; + x = test_v_i64(x, 42, 13); + printf("%lld\n", x[I]); + x = (v_i64){}; + x = test_v_i64(x, 42, 55); + printf("%lld\n", x[I]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_u64){}; + x = test_v_u64(x, 42, 13); + printf("%lld\n", x[I]); + x = (v_u64){}; + x = test_v_u64(x, 42, 55); + printf("%lld\n", x[I]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i32){}; + x = test_v_i32(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i32){}; + x = test_v_i32(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_u32){}; + x = test_v_u32(x, 42, 13); + printf("%d\n", x[I]); + x = (v_u32){}; + x = test_v_u32(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i16){}; + x = test_v_i16(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i16){}; + x = test_v_i16(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42, 42); + printf("%d\n", (i16)x[I]); + x = (v_u16){}; + x = test_v_u16(x, 42, 13); + printf("%d\n", (i16)x[I]); + x = (v_u16){}; + x = test_v_u16(x, 42, 55); + printf("%d\n", (i16)x[I]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i8){}; + x = test_v_i8(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i8){}; + x = test_v_i8(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42, 42); + printf("%d\n", (i8)x[I]); + x = (v_u8){}; + x = test_v_u8(x, 42, 13); + printf("%d\n", (i8)x[I]); + x = (v_u8){}; + x = test_v_u8(x, 42, 55); + printf("%d\n", (i8)x[I]); + } + + return 0; +} +--EXPECT-- +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 diff --git a/tests/vector/gt-003.test b/tests/vector/gt-003.test new file mode 100644 index 0000000..7d3145d --- /dev/null +++ b/tests/vector/gt-003.test @@ -0,0 +1,239 @@ +--TEST-- +GT.003: 128-bit vectors AVX +--TARGET-- +!aarch64 +--ARGS-- +-mavx -mno-avx2 --run +--CODE-- +#define N 16 +#define I 1 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef double __attribute__((__vector_size__(N))) v_d; +typedef float __attribute__((__vector_size__(N))) v_f; +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_d __attribute__((noinline)) test_v_d(v_d v, double x, double y) +{ + return (v + x > y); +} + +v_f __attribute__((noinline)) test_v_f(v_f v, float x, float y) +{ + return (v + x > y); +} + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x, i64 y) +{ + return (v + x > y); +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x, u64 y) +{ + return (v + x > y); +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x, i32 y) +{ + return (v + x > y); +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x, u32 y) +{ + return (v + x > y); +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x, i16 y) +{ + return (v + x > y); +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x, u16 y) +{ + return (v + x > y); +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x, i8 y) +{ + return (v + x > y); +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x, u8 y) +{ + return (v + x > y); +} + +int main() +{ + { + v_d x = {}; + v_i64 y; + y = (v_i64)test_v_d(x, 42.42, 42.42); + printf("%lld\n", y[I]); + x = (v_d){}; + y = (v_i64)test_v_d(x, 42.42, 13.13); + printf("%lld\n", y[I]); + x = (v_d){}; + y = (v_i64)test_v_d(x, 42.42, 55.55); + printf("%lld\n", y[I]); + } + + { + v_f x = {}; + v_i32 y; + y = (v_i32)test_v_f(x, 42.42, 42.42); + printf("%d\n", y[I]); + x = (v_f){}; + y = (v_i32)test_v_f(x, 42.42, 13.13); + printf("%d\n", y[I]); + x = (v_f){}; + y = (v_i32)test_v_f(x, 42.42, 55.55); + printf("%d\n", y[I]); + } + + { + v_i64 x = {}; + x = test_v_i64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_i64){}; + x = test_v_i64(x, 42, 13); + printf("%lld\n", x[I]); + x = (v_i64){}; + x = test_v_i64(x, 42, 55); + printf("%lld\n", x[I]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_u64){}; + x = test_v_u64(x, 42, 13); + printf("%lld\n", x[I]); + x = (v_u64){}; + x = test_v_u64(x, 42, 55); + printf("%lld\n", x[I]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i32){}; + x = test_v_i32(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i32){}; + x = test_v_i32(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_u32){}; + x = test_v_u32(x, 42, 13); + printf("%d\n", x[I]); + x = (v_u32){}; + x = test_v_u32(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i16){}; + x = test_v_i16(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i16){}; + x = test_v_i16(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42, 42); + printf("%d\n", (i16)x[I]); + x = (v_u16){}; + x = test_v_u16(x, 42, 13); + printf("%d\n", (i16)x[I]); + x = (v_u16){}; + x = test_v_u16(x, 42, 55); + printf("%d\n", (i16)x[I]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i8){}; + x = test_v_i8(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i8){}; + x = test_v_i8(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42, 42); + printf("%d\n", (i8)x[I]); + x = (v_u8){}; + x = test_v_u8(x, 42, 13); + printf("%d\n", (i8)x[I]); + x = (v_u8){}; + x = test_v_u8(x, 42, 55); + printf("%d\n", (i8)x[I]); + } + + return 0; +} +--EXPECT-- +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 diff --git a/tests/vector/gt-004.test b/tests/vector/gt-004.test new file mode 100644 index 0000000..b4c1910 --- /dev/null +++ b/tests/vector/gt-004.test @@ -0,0 +1,239 @@ +--TEST-- +GT.004: 128-bit vectors AVX+AVX2 +--TARGET-- +!aarch64 +--ARGS-- +-mavx --run +--CODE-- +#define N 16 +#define I 1 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef double __attribute__((__vector_size__(N))) v_d; +typedef float __attribute__((__vector_size__(N))) v_f; +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_d __attribute__((noinline)) test_v_d(v_d v, double x, double y) +{ + return (v + x > y); +} + +v_f __attribute__((noinline)) test_v_f(v_f v, float x, float y) +{ + return (v + x > y); +} + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x, i64 y) +{ + return (v + x > y); +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x, u64 y) +{ + return (v + x > y); +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x, i32 y) +{ + return (v + x > y); +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x, u32 y) +{ + return (v + x > y); +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x, i16 y) +{ + return (v + x > y); +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x, u16 y) +{ + return (v + x > y); +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x, i8 y) +{ + return (v + x > y); +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x, u8 y) +{ + return (v + x > y); +} + +int main() +{ + { + v_d x = {}; + v_i64 y; + y = (v_i64)test_v_d(x, 42.42, 42.42); + printf("%lld\n", y[I]); + x = (v_d){}; + y = (v_i64)test_v_d(x, 42.42, 13.13); + printf("%lld\n", y[I]); + x = (v_d){}; + y = (v_i64)test_v_d(x, 42.42, 55.55); + printf("%lld\n", y[I]); + } + + { + v_f x = {}; + v_i32 y; + y = (v_i32)test_v_f(x, 42.42, 42.42); + printf("%d\n", y[I]); + x = (v_f){}; + y = (v_i32)test_v_f(x, 42.42, 13.13); + printf("%d\n", y[I]); + x = (v_f){}; + y = (v_i32)test_v_f(x, 42.42, 55.55); + printf("%d\n", y[I]); + } + + { + v_i64 x = {}; + x = test_v_i64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_i64){}; + x = test_v_i64(x, 42, 13); + printf("%lld\n", x[I]); + x = (v_i64){}; + x = test_v_i64(x, 42, 55); + printf("%lld\n", x[I]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_u64){}; + x = test_v_u64(x, 42, 13); + printf("%lld\n", x[I]); + x = (v_u64){}; + x = test_v_u64(x, 42, 55); + printf("%lld\n", x[I]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i32){}; + x = test_v_i32(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i32){}; + x = test_v_i32(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_u32){}; + x = test_v_u32(x, 42, 13); + printf("%d\n", x[I]); + x = (v_u32){}; + x = test_v_u32(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i16){}; + x = test_v_i16(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i16){}; + x = test_v_i16(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42, 42); + printf("%d\n", (i16)x[I]); + x = (v_u16){}; + x = test_v_u16(x, 42, 13); + printf("%d\n", (i16)x[I]); + x = (v_u16){}; + x = test_v_u16(x, 42, 55); + printf("%d\n", (i16)x[I]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i8){}; + x = test_v_i8(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i8){}; + x = test_v_i8(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42, 42); + printf("%d\n", (i8)x[I]); + x = (v_u8){}; + x = test_v_u8(x, 42, 13); + printf("%d\n", (i8)x[I]); + x = (v_u8){}; + x = test_v_u8(x, 42, 55); + printf("%d\n", (i8)x[I]); + } + + return 0; +} +--EXPECT-- +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 diff --git a/tests/vector/gt-005.test b/tests/vector/gt-005.test new file mode 100644 index 0000000..e2053f7 --- /dev/null +++ b/tests/vector/gt-005.test @@ -0,0 +1,239 @@ +--TEST-- +GT.005: 64-bit vectors SSE2 +--TARGET-- +!aarch64 +--ARGS-- +-mno-sse4 -mno-avx2 --run +--CODE-- +#define N 8 +#define I 0 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef double __attribute__((__vector_size__(N))) v_d; +typedef float __attribute__((__vector_size__(N))) v_f; +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_d __attribute__((noinline)) test_v_d(v_d v, double x, double y) +{ + return (v + x > y); +} + +v_f __attribute__((noinline)) test_v_f(v_f v, float x, float y) +{ + return (v + x > y); +} + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x, i64 y) +{ + return (v + x > y); +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x, u64 y) +{ + return (v + x > y); +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x, i32 y) +{ + return (v + x > y); +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x, u32 y) +{ + return (v + x > y); +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x, i16 y) +{ + return (v + x > y); +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x, u16 y) +{ + return (v + x > y); +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x, i8 y) +{ + return (v + x > y); +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x, u8 y) +{ + return (v + x > y); +} + +int main() +{ + { + v_d x = {}; + v_i64 y; + y = (v_i64)test_v_d(x, 42.42, 42.42); + printf("%lld\n", y[I]); + x = (v_d){}; + y = (v_i64)test_v_d(x, 42.42, 13.13); + printf("%lld\n", y[I]); + x = (v_d){}; + y = (v_i64)test_v_d(x, 42.42, 55.55); + printf("%lld\n", y[I]); + } + + { + v_f x = {}; + v_i32 y; + y = (v_i32)test_v_f(x, 42.42, 42.42); + printf("%d\n", y[I]); + x = (v_f){}; + y = (v_i32)test_v_f(x, 42.42, 13.13); + printf("%d\n", y[I]); + x = (v_f){}; + y = (v_i32)test_v_f(x, 42.42, 55.55); + printf("%d\n", y[I]); + } + + { + v_i64 x = {}; + x = test_v_i64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_i64){}; + x = test_v_i64(x, 42, 13); + printf("%lld\n", x[I]); + x = (v_i64){}; + x = test_v_i64(x, 42, 55); + printf("%lld\n", x[I]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_u64){}; + x = test_v_u64(x, 42, 13); + printf("%lld\n", x[I]); + x = (v_u64){}; + x = test_v_u64(x, 42, 55); + printf("%lld\n", x[I]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i32){}; + x = test_v_i32(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i32){}; + x = test_v_i32(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_u32){}; + x = test_v_u32(x, 42, 13); + printf("%d\n", x[I]); + x = (v_u32){}; + x = test_v_u32(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i16){}; + x = test_v_i16(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i16){}; + x = test_v_i16(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42, 42); + printf("%d\n", (i16)x[I]); + x = (v_u16){}; + x = test_v_u16(x, 42, 13); + printf("%d\n", (i16)x[I]); + x = (v_u16){}; + x = test_v_u16(x, 42, 55); + printf("%d\n", (i16)x[I]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i8){}; + x = test_v_i8(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i8){}; + x = test_v_i8(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42, 42); + printf("%d\n", (i8)x[I]); + x = (v_u8){}; + x = test_v_u8(x, 42, 13); + printf("%d\n", (i8)x[I]); + x = (v_u8){}; + x = test_v_u8(x, 42, 55); + printf("%d\n", (i8)x[I]); + } + + return 0; +} +--EXPECT-- +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 diff --git a/tests/vector/gt-006.test b/tests/vector/gt-006.test new file mode 100644 index 0000000..902962c --- /dev/null +++ b/tests/vector/gt-006.test @@ -0,0 +1,239 @@ +--TEST-- +GT.006: 64-bit vectors AVX +--TARGET-- +!aarch64 +--ARGS-- +-mavx -mno-avx2 --run +--CODE-- +#define N 8 +#define I 0 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef double __attribute__((__vector_size__(N))) v_d; +typedef float __attribute__((__vector_size__(N))) v_f; +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_d __attribute__((noinline)) test_v_d(v_d v, double x, double y) +{ + return (v + x > y); +} + +v_f __attribute__((noinline)) test_v_f(v_f v, float x, float y) +{ + return (v + x > y); +} + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x, i64 y) +{ + return (v + x > y); +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x, u64 y) +{ + return (v + x > y); +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x, i32 y) +{ + return (v + x > y); +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x, u32 y) +{ + return (v + x > y); +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x, i16 y) +{ + return (v + x > y); +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x, u16 y) +{ + return (v + x > y); +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x, i8 y) +{ + return (v + x > y); +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x, u8 y) +{ + return (v + x > y); +} + +int main() +{ + { + v_d x = {}; + v_i64 y; + y = (v_i64)test_v_d(x, 42.42, 42.42); + printf("%lld\n", y[I]); + x = (v_d){}; + y = (v_i64)test_v_d(x, 42.42, 13.13); + printf("%lld\n", y[I]); + x = (v_d){}; + y = (v_i64)test_v_d(x, 42.42, 55.55); + printf("%lld\n", y[I]); + } + + { + v_f x = {}; + v_i32 y; + y = (v_i32)test_v_f(x, 42.42, 42.42); + printf("%d\n", y[I]); + x = (v_f){}; + y = (v_i32)test_v_f(x, 42.42, 13.13); + printf("%d\n", y[I]); + x = (v_f){}; + y = (v_i32)test_v_f(x, 42.42, 55.55); + printf("%d\n", y[I]); + } + + { + v_i64 x = {}; + x = test_v_i64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_i64){}; + x = test_v_i64(x, 42, 13); + printf("%lld\n", x[I]); + x = (v_i64){}; + x = test_v_i64(x, 42, 55); + printf("%lld\n", x[I]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_u64){}; + x = test_v_u64(x, 42, 13); + printf("%lld\n", x[I]); + x = (v_u64){}; + x = test_v_u64(x, 42, 55); + printf("%lld\n", x[I]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i32){}; + x = test_v_i32(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i32){}; + x = test_v_i32(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_u32){}; + x = test_v_u32(x, 42, 13); + printf("%d\n", x[I]); + x = (v_u32){}; + x = test_v_u32(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i16){}; + x = test_v_i16(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i16){}; + x = test_v_i16(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42, 42); + printf("%d\n", (i16)x[I]); + x = (v_u16){}; + x = test_v_u16(x, 42, 13); + printf("%d\n", (i16)x[I]); + x = (v_u16){}; + x = test_v_u16(x, 42, 55); + printf("%d\n", (i16)x[I]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i8){}; + x = test_v_i8(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i8){}; + x = test_v_i8(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42, 42); + printf("%d\n", (i8)x[I]); + x = (v_u8){}; + x = test_v_u8(x, 42, 13); + printf("%d\n", (i8)x[I]); + x = (v_u8){}; + x = test_v_u8(x, 42, 55); + printf("%d\n", (i8)x[I]); + } + + return 0; +} +--EXPECT-- +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 diff --git a/tests/vector/gt-007.test b/tests/vector/gt-007.test new file mode 100644 index 0000000..fbf441b --- /dev/null +++ b/tests/vector/gt-007.test @@ -0,0 +1,239 @@ +--TEST-- +GT.007: 256-bit vectors AVX +--TARGET-- +!aarch64 +--ARGS-- +-mavx -mno-avx2 --run +--CODE-- +#define N 32 +#define I 3 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef double __attribute__((__vector_size__(N))) v_d; +typedef float __attribute__((__vector_size__(N))) v_f; +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_d __attribute__((noinline)) test_v_d(v_d v, double x, double y) +{ + return (v + x > y); +} + +v_f __attribute__((noinline)) test_v_f(v_f v, float x, float y) +{ + return (v + x > y); +} + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x, i64 y) +{ + return (v + x > y); +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x, u64 y) +{ + return (v + x > y); +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x, i32 y) +{ + return (v + x > y); +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x, u32 y) +{ + return (v + x > y); +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x, i16 y) +{ + return (v + x > y); +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x, u16 y) +{ + return (v + x > y); +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x, i8 y) +{ + return (v + x > y); +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x, u8 y) +{ + return (v + x > y); +} + +int main() +{ + { + v_d x = {}; + v_i64 y; + y = (v_i64)test_v_d(x, 42.42, 42.42); + printf("%lld\n", y[I]); + x = (v_d){}; + y = (v_i64)test_v_d(x, 42.42, 13.13); + printf("%lld\n", y[I]); + x = (v_d){}; + y = (v_i64)test_v_d(x, 42.42, 55.55); + printf("%lld\n", y[I]); + } + + { + v_f x = {}; + v_i32 y; + y = (v_i32)test_v_f(x, 42.42, 42.42); + printf("%d\n", y[I]); + x = (v_f){}; + y = (v_i32)test_v_f(x, 42.42, 13.13); + printf("%d\n", y[I]); + x = (v_f){}; + y = (v_i32)test_v_f(x, 42.42, 55.55); + printf("%d\n", y[I]); + } + + { + v_i64 x = {}; + x = test_v_i64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_i64){}; + x = test_v_i64(x, 42, 13); + printf("%lld\n", x[I]); + x = (v_i64){}; + x = test_v_i64(x, 42, 55); + printf("%lld\n", x[I]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_u64){}; + x = test_v_u64(x, 42, 13); + printf("%lld\n", x[I]); + x = (v_u64){}; + x = test_v_u64(x, 42, 55); + printf("%lld\n", x[I]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i32){}; + x = test_v_i32(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i32){}; + x = test_v_i32(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_u32){}; + x = test_v_u32(x, 42, 13); + printf("%d\n", x[I]); + x = (v_u32){}; + x = test_v_u32(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i16){}; + x = test_v_i16(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i16){}; + x = test_v_i16(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42, 42); + printf("%d\n", (i16)x[I]); + x = (v_u16){}; + x = test_v_u16(x, 42, 13); + printf("%d\n", (i16)x[I]); + x = (v_u16){}; + x = test_v_u16(x, 42, 55); + printf("%d\n", (i16)x[I]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i8){}; + x = test_v_i8(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i8){}; + x = test_v_i8(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42, 42); + printf("%d\n", (i8)x[I]); + x = (v_u8){}; + x = test_v_u8(x, 42, 13); + printf("%d\n", (i8)x[I]); + x = (v_u8){}; + x = test_v_u8(x, 42, 55); + printf("%d\n", (i8)x[I]); + } + + return 0; +} +--EXPECT-- +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 diff --git a/tests/vector/gt-008.test b/tests/vector/gt-008.test new file mode 100644 index 0000000..3cd1534 --- /dev/null +++ b/tests/vector/gt-008.test @@ -0,0 +1,239 @@ +--TEST-- +GT.008: 256-bit vectors AVX+AVX2 +--TARGET-- +!aarch64 +--ARGS-- +-mavx --run +--CODE-- +#define N 32 +#define I 3 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef double __attribute__((__vector_size__(N))) v_d; +typedef float __attribute__((__vector_size__(N))) v_f; +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_d __attribute__((noinline)) test_v_d(v_d v, double x, double y) +{ + return (v + x > y); +} + +v_f __attribute__((noinline)) test_v_f(v_f v, float x, float y) +{ + return (v + x > y); +} + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x, i64 y) +{ + return (v + x > y); +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x, u64 y) +{ + return (v + x > y); +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x, i32 y) +{ + return (v + x > y); +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x, u32 y) +{ + return (v + x > y); +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x, i16 y) +{ + return (v + x > y); +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x, u16 y) +{ + return (v + x > y); +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x, i8 y) +{ + return (v + x > y); +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x, u8 y) +{ + return (v + x > y); +} + +int main() +{ + { + v_d x = {}; + v_i64 y; + y = (v_i64)test_v_d(x, 42.42, 42.42); + printf("%lld\n", y[I]); + x = (v_d){}; + y = (v_i64)test_v_d(x, 42.42, 13.13); + printf("%lld\n", y[I]); + x = (v_d){}; + y = (v_i64)test_v_d(x, 42.42, 55.55); + printf("%lld\n", y[I]); + } + + { + v_f x = {}; + v_i32 y; + y = (v_i32)test_v_f(x, 42.42, 42.42); + printf("%d\n", y[I]); + x = (v_f){}; + y = (v_i32)test_v_f(x, 42.42, 13.13); + printf("%d\n", y[I]); + x = (v_f){}; + y = (v_i32)test_v_f(x, 42.42, 55.55); + printf("%d\n", y[I]); + } + + { + v_i64 x = {}; + x = test_v_i64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_i64){}; + x = test_v_i64(x, 42, 13); + printf("%lld\n", x[I]); + x = (v_i64){}; + x = test_v_i64(x, 42, 55); + printf("%lld\n", x[I]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_u64){}; + x = test_v_u64(x, 42, 13); + printf("%lld\n", x[I]); + x = (v_u64){}; + x = test_v_u64(x, 42, 55); + printf("%lld\n", x[I]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i32){}; + x = test_v_i32(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i32){}; + x = test_v_i32(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_u32){}; + x = test_v_u32(x, 42, 13); + printf("%d\n", x[I]); + x = (v_u32){}; + x = test_v_u32(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i16){}; + x = test_v_i16(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i16){}; + x = test_v_i16(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42, 42); + printf("%d\n", (i16)x[I]); + x = (v_u16){}; + x = test_v_u16(x, 42, 13); + printf("%d\n", (i16)x[I]); + x = (v_u16){}; + x = test_v_u16(x, 42, 55); + printf("%d\n", (i16)x[I]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i8){}; + x = test_v_i8(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i8){}; + x = test_v_i8(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42, 42); + printf("%d\n", (i8)x[I]); + x = (v_u8){}; + x = test_v_u8(x, 42, 13); + printf("%d\n", (i8)x[I]); + x = (v_u8){}; + x = test_v_u8(x, 42, 55); + printf("%d\n", (i8)x[I]); + } + + return 0; +} +--EXPECT-- +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 diff --git a/tests/vector/le-001.test b/tests/vector/le-001.test new file mode 100644 index 0000000..6d0b42f --- /dev/null +++ b/tests/vector/le-001.test @@ -0,0 +1,239 @@ +--TEST-- +LE.001: 128-bit vectors SSE2 +--TARGET-- +!aarch64 +--ARGS-- +-mno-sse4 -mno-avx2 --run +--CODE-- +#define N 16 +#define I 1 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef double __attribute__((__vector_size__(N))) v_d; +typedef float __attribute__((__vector_size__(N))) v_f; +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_d __attribute__((noinline)) test_v_d(v_d v, double x, double y) +{ + return (v + x <= y); +} + +v_f __attribute__((noinline)) test_v_f(v_f v, float x, float y) +{ + return (v + x <= y); +} + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x, i64 y) +{ + return (v + x <= y); +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x, u64 y) +{ + return (v + x <= y); +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x, i32 y) +{ + return (v + x <= y); +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x, u32 y) +{ + return (v + x <= y); +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x, i16 y) +{ + return (v + x <= y); +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x, u16 y) +{ + return (v + x <= y); +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x, i8 y) +{ + return (v + x <= y); +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x, u8 y) +{ + return (v + x <= y); +} + +int main() +{ + { + v_d x = {}; + v_i64 y; + y = (v_i64)test_v_d(x, 42.42, 42.42); + printf("%lld\n", y[I]); + x = (v_d){}; + y = (v_i64)test_v_d(x, 42.42, 13.13); + printf("%lld\n", y[I]); + x = (v_d){}; + y = (v_i64)test_v_d(x, 42.42, 55.55); + printf("%lld\n", y[I]); + } + + { + v_f x = {}; + v_i32 y; + y = (v_i32)test_v_f(x, 42.42, 42.42); + printf("%d\n", y[I]); + x = (v_f){}; + y = (v_i32)test_v_f(x, 42.42, 13.13); + printf("%d\n", y[I]); + x = (v_f){}; + y = (v_i32)test_v_f(x, 42.42, 55.55); + printf("%d\n", y[I]); + } + + { + v_i64 x = {}; + x = test_v_i64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_i64){}; + x = test_v_i64(x, 42, 13); + printf("%lld\n", x[I]); + x = (v_i64){}; + x = test_v_i64(x, 42, 55); + printf("%lld\n", x[I]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_u64){}; + x = test_v_u64(x, 42, 13); + printf("%lld\n", x[I]); + x = (v_u64){}; + x = test_v_u64(x, 42, 55); + printf("%lld\n", x[I]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i32){}; + x = test_v_i32(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i32){}; + x = test_v_i32(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_u32){}; + x = test_v_u32(x, 42, 13); + printf("%d\n", x[I]); + x = (v_u32){}; + x = test_v_u32(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i16){}; + x = test_v_i16(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i16){}; + x = test_v_i16(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42, 42); + printf("%d\n", (i16)x[I]); + x = (v_u16){}; + x = test_v_u16(x, 42, 13); + printf("%d\n", (i16)x[I]); + x = (v_u16){}; + x = test_v_u16(x, 42, 55); + printf("%d\n", (i16)x[I]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i8){}; + x = test_v_i8(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i8){}; + x = test_v_i8(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42, 42); + printf("%d\n", (i8)x[I]); + x = (v_u8){}; + x = test_v_u8(x, 42, 13); + printf("%d\n", (i8)x[I]); + x = (v_u8){}; + x = test_v_u8(x, 42, 55); + printf("%d\n", (i8)x[I]); + } + + return 0; +} +--EXPECT-- +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 diff --git a/tests/vector/le-002.test b/tests/vector/le-002.test new file mode 100644 index 0000000..b8f9808 --- /dev/null +++ b/tests/vector/le-002.test @@ -0,0 +1,239 @@ +--TEST-- +LE.002: 128-bit vectors SSE2+SSE4 +--TARGET-- +!aarch64 +--ARGS-- +-mno-avx2 --run +--CODE-- +#define N 16 +#define I 1 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef double __attribute__((__vector_size__(N))) v_d; +typedef float __attribute__((__vector_size__(N))) v_f; +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_d __attribute__((noinline)) test_v_d(v_d v, double x, double y) +{ + return (v + x <= y); +} + +v_f __attribute__((noinline)) test_v_f(v_f v, float x, float y) +{ + return (v + x <= y); +} + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x, i64 y) +{ + return (v + x <= y); +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x, u64 y) +{ + return (v + x <= y); +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x, i32 y) +{ + return (v + x <= y); +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x, u32 y) +{ + return (v + x <= y); +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x, i16 y) +{ + return (v + x <= y); +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x, u16 y) +{ + return (v + x <= y); +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x, i8 y) +{ + return (v + x <= y); +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x, u8 y) +{ + return (v + x <= y); +} + +int main() +{ + { + v_d x = {}; + v_i64 y; + y = (v_i64)test_v_d(x, 42.42, 42.42); + printf("%lld\n", y[I]); + x = (v_d){}; + y = (v_i64)test_v_d(x, 42.42, 13.13); + printf("%lld\n", y[I]); + x = (v_d){}; + y = (v_i64)test_v_d(x, 42.42, 55.55); + printf("%lld\n", y[I]); + } + + { + v_f x = {}; + v_i32 y; + y = (v_i32)test_v_f(x, 42.42, 42.42); + printf("%d\n", y[I]); + x = (v_f){}; + y = (v_i32)test_v_f(x, 42.42, 13.13); + printf("%d\n", y[I]); + x = (v_f){}; + y = (v_i32)test_v_f(x, 42.42, 55.55); + printf("%d\n", y[I]); + } + + { + v_i64 x = {}; + x = test_v_i64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_i64){}; + x = test_v_i64(x, 42, 13); + printf("%lld\n", x[I]); + x = (v_i64){}; + x = test_v_i64(x, 42, 55); + printf("%lld\n", x[I]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_u64){}; + x = test_v_u64(x, 42, 13); + printf("%lld\n", x[I]); + x = (v_u64){}; + x = test_v_u64(x, 42, 55); + printf("%lld\n", x[I]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i32){}; + x = test_v_i32(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i32){}; + x = test_v_i32(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_u32){}; + x = test_v_u32(x, 42, 13); + printf("%d\n", x[I]); + x = (v_u32){}; + x = test_v_u32(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i16){}; + x = test_v_i16(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i16){}; + x = test_v_i16(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42, 42); + printf("%d\n", (i16)x[I]); + x = (v_u16){}; + x = test_v_u16(x, 42, 13); + printf("%d\n", (i16)x[I]); + x = (v_u16){}; + x = test_v_u16(x, 42, 55); + printf("%d\n", (i16)x[I]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i8){}; + x = test_v_i8(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i8){}; + x = test_v_i8(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42, 42); + printf("%d\n", (i8)x[I]); + x = (v_u8){}; + x = test_v_u8(x, 42, 13); + printf("%d\n", (i8)x[I]); + x = (v_u8){}; + x = test_v_u8(x, 42, 55); + printf("%d\n", (i8)x[I]); + } + + return 0; +} +--EXPECT-- +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 diff --git a/tests/vector/le-003.test b/tests/vector/le-003.test new file mode 100644 index 0000000..3297813 --- /dev/null +++ b/tests/vector/le-003.test @@ -0,0 +1,239 @@ +--TEST-- +LE.003: 128-bit vectors AVX +--TARGET-- +!aarch64 +--ARGS-- +-mavx -mno-avx2 --run +--CODE-- +#define N 16 +#define I 1 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef double __attribute__((__vector_size__(N))) v_d; +typedef float __attribute__((__vector_size__(N))) v_f; +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_d __attribute__((noinline)) test_v_d(v_d v, double x, double y) +{ + return (v + x <= y); +} + +v_f __attribute__((noinline)) test_v_f(v_f v, float x, float y) +{ + return (v + x <= y); +} + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x, i64 y) +{ + return (v + x <= y); +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x, u64 y) +{ + return (v + x <= y); +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x, i32 y) +{ + return (v + x <= y); +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x, u32 y) +{ + return (v + x <= y); +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x, i16 y) +{ + return (v + x <= y); +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x, u16 y) +{ + return (v + x <= y); +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x, i8 y) +{ + return (v + x <= y); +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x, u8 y) +{ + return (v + x <= y); +} + +int main() +{ + { + v_d x = {}; + v_i64 y; + y = (v_i64)test_v_d(x, 42.42, 42.42); + printf("%lld\n", y[I]); + x = (v_d){}; + y = (v_i64)test_v_d(x, 42.42, 13.13); + printf("%lld\n", y[I]); + x = (v_d){}; + y = (v_i64)test_v_d(x, 42.42, 55.55); + printf("%lld\n", y[I]); + } + + { + v_f x = {}; + v_i32 y; + y = (v_i32)test_v_f(x, 42.42, 42.42); + printf("%d\n", y[I]); + x = (v_f){}; + y = (v_i32)test_v_f(x, 42.42, 13.13); + printf("%d\n", y[I]); + x = (v_f){}; + y = (v_i32)test_v_f(x, 42.42, 55.55); + printf("%d\n", y[I]); + } + + { + v_i64 x = {}; + x = test_v_i64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_i64){}; + x = test_v_i64(x, 42, 13); + printf("%lld\n", x[I]); + x = (v_i64){}; + x = test_v_i64(x, 42, 55); + printf("%lld\n", x[I]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_u64){}; + x = test_v_u64(x, 42, 13); + printf("%lld\n", x[I]); + x = (v_u64){}; + x = test_v_u64(x, 42, 55); + printf("%lld\n", x[I]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i32){}; + x = test_v_i32(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i32){}; + x = test_v_i32(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_u32){}; + x = test_v_u32(x, 42, 13); + printf("%d\n", x[I]); + x = (v_u32){}; + x = test_v_u32(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i16){}; + x = test_v_i16(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i16){}; + x = test_v_i16(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42, 42); + printf("%d\n", (i16)x[I]); + x = (v_u16){}; + x = test_v_u16(x, 42, 13); + printf("%d\n", (i16)x[I]); + x = (v_u16){}; + x = test_v_u16(x, 42, 55); + printf("%d\n", (i16)x[I]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i8){}; + x = test_v_i8(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i8){}; + x = test_v_i8(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42, 42); + printf("%d\n", (i8)x[I]); + x = (v_u8){}; + x = test_v_u8(x, 42, 13); + printf("%d\n", (i8)x[I]); + x = (v_u8){}; + x = test_v_u8(x, 42, 55); + printf("%d\n", (i8)x[I]); + } + + return 0; +} +--EXPECT-- +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 diff --git a/tests/vector/le-004.test b/tests/vector/le-004.test new file mode 100644 index 0000000..fda6fc6 --- /dev/null +++ b/tests/vector/le-004.test @@ -0,0 +1,239 @@ +--TEST-- +LE.004: 128-bit vectors AVX+AVX2 +--TARGET-- +!aarch64 +--ARGS-- +-mavx --run +--CODE-- +#define N 16 +#define I 1 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef double __attribute__((__vector_size__(N))) v_d; +typedef float __attribute__((__vector_size__(N))) v_f; +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_d __attribute__((noinline)) test_v_d(v_d v, double x, double y) +{ + return (v + x <= y); +} + +v_f __attribute__((noinline)) test_v_f(v_f v, float x, float y) +{ + return (v + x <= y); +} + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x, i64 y) +{ + return (v + x <= y); +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x, u64 y) +{ + return (v + x <= y); +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x, i32 y) +{ + return (v + x <= y); +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x, u32 y) +{ + return (v + x <= y); +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x, i16 y) +{ + return (v + x <= y); +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x, u16 y) +{ + return (v + x <= y); +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x, i8 y) +{ + return (v + x <= y); +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x, u8 y) +{ + return (v + x <= y); +} + +int main() +{ + { + v_d x = {}; + v_i64 y; + y = (v_i64)test_v_d(x, 42.42, 42.42); + printf("%lld\n", y[I]); + x = (v_d){}; + y = (v_i64)test_v_d(x, 42.42, 13.13); + printf("%lld\n", y[I]); + x = (v_d){}; + y = (v_i64)test_v_d(x, 42.42, 55.55); + printf("%lld\n", y[I]); + } + + { + v_f x = {}; + v_i32 y; + y = (v_i32)test_v_f(x, 42.42, 42.42); + printf("%d\n", y[I]); + x = (v_f){}; + y = (v_i32)test_v_f(x, 42.42, 13.13); + printf("%d\n", y[I]); + x = (v_f){}; + y = (v_i32)test_v_f(x, 42.42, 55.55); + printf("%d\n", y[I]); + } + + { + v_i64 x = {}; + x = test_v_i64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_i64){}; + x = test_v_i64(x, 42, 13); + printf("%lld\n", x[I]); + x = (v_i64){}; + x = test_v_i64(x, 42, 55); + printf("%lld\n", x[I]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_u64){}; + x = test_v_u64(x, 42, 13); + printf("%lld\n", x[I]); + x = (v_u64){}; + x = test_v_u64(x, 42, 55); + printf("%lld\n", x[I]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i32){}; + x = test_v_i32(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i32){}; + x = test_v_i32(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_u32){}; + x = test_v_u32(x, 42, 13); + printf("%d\n", x[I]); + x = (v_u32){}; + x = test_v_u32(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i16){}; + x = test_v_i16(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i16){}; + x = test_v_i16(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42, 42); + printf("%d\n", (i16)x[I]); + x = (v_u16){}; + x = test_v_u16(x, 42, 13); + printf("%d\n", (i16)x[I]); + x = (v_u16){}; + x = test_v_u16(x, 42, 55); + printf("%d\n", (i16)x[I]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i8){}; + x = test_v_i8(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i8){}; + x = test_v_i8(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42, 42); + printf("%d\n", (i8)x[I]); + x = (v_u8){}; + x = test_v_u8(x, 42, 13); + printf("%d\n", (i8)x[I]); + x = (v_u8){}; + x = test_v_u8(x, 42, 55); + printf("%d\n", (i8)x[I]); + } + + return 0; +} +--EXPECT-- +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 diff --git a/tests/vector/le-005.test b/tests/vector/le-005.test new file mode 100644 index 0000000..523ca6d --- /dev/null +++ b/tests/vector/le-005.test @@ -0,0 +1,239 @@ +--TEST-- +LE.005: 64-bit vectors SSE2 +--TARGET-- +!aarch64 +--ARGS-- +-mno-sse4 -mno-avx2 --run +--CODE-- +#define N 8 +#define I 0 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef double __attribute__((__vector_size__(N))) v_d; +typedef float __attribute__((__vector_size__(N))) v_f; +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_d __attribute__((noinline)) test_v_d(v_d v, double x, double y) +{ + return (v + x <= y); +} + +v_f __attribute__((noinline)) test_v_f(v_f v, float x, float y) +{ + return (v + x <= y); +} + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x, i64 y) +{ + return (v + x <= y); +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x, u64 y) +{ + return (v + x <= y); +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x, i32 y) +{ + return (v + x <= y); +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x, u32 y) +{ + return (v + x <= y); +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x, i16 y) +{ + return (v + x <= y); +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x, u16 y) +{ + return (v + x <= y); +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x, i8 y) +{ + return (v + x <= y); +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x, u8 y) +{ + return (v + x <= y); +} + +int main() +{ + { + v_d x = {}; + v_i64 y; + y = (v_i64)test_v_d(x, 42.42, 42.42); + printf("%lld\n", y[I]); + x = (v_d){}; + y = (v_i64)test_v_d(x, 42.42, 13.13); + printf("%lld\n", y[I]); + x = (v_d){}; + y = (v_i64)test_v_d(x, 42.42, 55.55); + printf("%lld\n", y[I]); + } + + { + v_f x = {}; + v_i32 y; + y = (v_i32)test_v_f(x, 42.42, 42.42); + printf("%d\n", y[I]); + x = (v_f){}; + y = (v_i32)test_v_f(x, 42.42, 13.13); + printf("%d\n", y[I]); + x = (v_f){}; + y = (v_i32)test_v_f(x, 42.42, 55.55); + printf("%d\n", y[I]); + } + + { + v_i64 x = {}; + x = test_v_i64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_i64){}; + x = test_v_i64(x, 42, 13); + printf("%lld\n", x[I]); + x = (v_i64){}; + x = test_v_i64(x, 42, 55); + printf("%lld\n", x[I]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_u64){}; + x = test_v_u64(x, 42, 13); + printf("%lld\n", x[I]); + x = (v_u64){}; + x = test_v_u64(x, 42, 55); + printf("%lld\n", x[I]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i32){}; + x = test_v_i32(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i32){}; + x = test_v_i32(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_u32){}; + x = test_v_u32(x, 42, 13); + printf("%d\n", x[I]); + x = (v_u32){}; + x = test_v_u32(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i16){}; + x = test_v_i16(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i16){}; + x = test_v_i16(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42, 42); + printf("%d\n", (i16)x[I]); + x = (v_u16){}; + x = test_v_u16(x, 42, 13); + printf("%d\n", (i16)x[I]); + x = (v_u16){}; + x = test_v_u16(x, 42, 55); + printf("%d\n", (i16)x[I]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i8){}; + x = test_v_i8(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i8){}; + x = test_v_i8(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42, 42); + printf("%d\n", (i8)x[I]); + x = (v_u8){}; + x = test_v_u8(x, 42, 13); + printf("%d\n", (i8)x[I]); + x = (v_u8){}; + x = test_v_u8(x, 42, 55); + printf("%d\n", (i8)x[I]); + } + + return 0; +} +--EXPECT-- +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 diff --git a/tests/vector/le-006.test b/tests/vector/le-006.test new file mode 100644 index 0000000..41da71a --- /dev/null +++ b/tests/vector/le-006.test @@ -0,0 +1,239 @@ +--TEST-- +LE.006: 64-bit vectors AVX +--TARGET-- +!aarch64 +--ARGS-- +-mavx -mno-avx2 --run +--CODE-- +#define N 8 +#define I 0 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef double __attribute__((__vector_size__(N))) v_d; +typedef float __attribute__((__vector_size__(N))) v_f; +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_d __attribute__((noinline)) test_v_d(v_d v, double x, double y) +{ + return (v + x <= y); +} + +v_f __attribute__((noinline)) test_v_f(v_f v, float x, float y) +{ + return (v + x <= y); +} + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x, i64 y) +{ + return (v + x <= y); +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x, u64 y) +{ + return (v + x <= y); +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x, i32 y) +{ + return (v + x <= y); +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x, u32 y) +{ + return (v + x <= y); +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x, i16 y) +{ + return (v + x <= y); +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x, u16 y) +{ + return (v + x <= y); +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x, i8 y) +{ + return (v + x <= y); +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x, u8 y) +{ + return (v + x <= y); +} + +int main() +{ + { + v_d x = {}; + v_i64 y; + y = (v_i64)test_v_d(x, 42.42, 42.42); + printf("%lld\n", y[I]); + x = (v_d){}; + y = (v_i64)test_v_d(x, 42.42, 13.13); + printf("%lld\n", y[I]); + x = (v_d){}; + y = (v_i64)test_v_d(x, 42.42, 55.55); + printf("%lld\n", y[I]); + } + + { + v_f x = {}; + v_i32 y; + y = (v_i32)test_v_f(x, 42.42, 42.42); + printf("%d\n", y[I]); + x = (v_f){}; + y = (v_i32)test_v_f(x, 42.42, 13.13); + printf("%d\n", y[I]); + x = (v_f){}; + y = (v_i32)test_v_f(x, 42.42, 55.55); + printf("%d\n", y[I]); + } + + { + v_i64 x = {}; + x = test_v_i64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_i64){}; + x = test_v_i64(x, 42, 13); + printf("%lld\n", x[I]); + x = (v_i64){}; + x = test_v_i64(x, 42, 55); + printf("%lld\n", x[I]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_u64){}; + x = test_v_u64(x, 42, 13); + printf("%lld\n", x[I]); + x = (v_u64){}; + x = test_v_u64(x, 42, 55); + printf("%lld\n", x[I]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i32){}; + x = test_v_i32(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i32){}; + x = test_v_i32(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_u32){}; + x = test_v_u32(x, 42, 13); + printf("%d\n", x[I]); + x = (v_u32){}; + x = test_v_u32(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i16){}; + x = test_v_i16(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i16){}; + x = test_v_i16(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42, 42); + printf("%d\n", (i16)x[I]); + x = (v_u16){}; + x = test_v_u16(x, 42, 13); + printf("%d\n", (i16)x[I]); + x = (v_u16){}; + x = test_v_u16(x, 42, 55); + printf("%d\n", (i16)x[I]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i8){}; + x = test_v_i8(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i8){}; + x = test_v_i8(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42, 42); + printf("%d\n", (i8)x[I]); + x = (v_u8){}; + x = test_v_u8(x, 42, 13); + printf("%d\n", (i8)x[I]); + x = (v_u8){}; + x = test_v_u8(x, 42, 55); + printf("%d\n", (i8)x[I]); + } + + return 0; +} +--EXPECT-- +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 diff --git a/tests/vector/le-007.test b/tests/vector/le-007.test new file mode 100644 index 0000000..079e009 --- /dev/null +++ b/tests/vector/le-007.test @@ -0,0 +1,239 @@ +--TEST-- +LE.007: 256-bit vectors AVX +--TARGET-- +!aarch64 +--ARGS-- +-mavx -mno-avx2 --run +--CODE-- +#define N 32 +#define I 3 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef double __attribute__((__vector_size__(N))) v_d; +typedef float __attribute__((__vector_size__(N))) v_f; +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_d __attribute__((noinline)) test_v_d(v_d v, double x, double y) +{ + return (v + x <= y); +} + +v_f __attribute__((noinline)) test_v_f(v_f v, float x, float y) +{ + return (v + x <= y); +} + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x, i64 y) +{ + return (v + x <= y); +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x, u64 y) +{ + return (v + x <= y); +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x, i32 y) +{ + return (v + x <= y); +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x, u32 y) +{ + return (v + x <= y); +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x, i16 y) +{ + return (v + x <= y); +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x, u16 y) +{ + return (v + x <= y); +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x, i8 y) +{ + return (v + x <= y); +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x, u8 y) +{ + return (v + x <= y); +} + +int main() +{ + { + v_d x = {}; + v_i64 y; + y = (v_i64)test_v_d(x, 42.42, 42.42); + printf("%lld\n", y[I]); + x = (v_d){}; + y = (v_i64)test_v_d(x, 42.42, 13.13); + printf("%lld\n", y[I]); + x = (v_d){}; + y = (v_i64)test_v_d(x, 42.42, 55.55); + printf("%lld\n", y[I]); + } + + { + v_f x = {}; + v_i32 y; + y = (v_i32)test_v_f(x, 42.42, 42.42); + printf("%d\n", y[I]); + x = (v_f){}; + y = (v_i32)test_v_f(x, 42.42, 13.13); + printf("%d\n", y[I]); + x = (v_f){}; + y = (v_i32)test_v_f(x, 42.42, 55.55); + printf("%d\n", y[I]); + } + + { + v_i64 x = {}; + x = test_v_i64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_i64){}; + x = test_v_i64(x, 42, 13); + printf("%lld\n", x[I]); + x = (v_i64){}; + x = test_v_i64(x, 42, 55); + printf("%lld\n", x[I]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_u64){}; + x = test_v_u64(x, 42, 13); + printf("%lld\n", x[I]); + x = (v_u64){}; + x = test_v_u64(x, 42, 55); + printf("%lld\n", x[I]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i32){}; + x = test_v_i32(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i32){}; + x = test_v_i32(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_u32){}; + x = test_v_u32(x, 42, 13); + printf("%d\n", x[I]); + x = (v_u32){}; + x = test_v_u32(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i16){}; + x = test_v_i16(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i16){}; + x = test_v_i16(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42, 42); + printf("%d\n", (i16)x[I]); + x = (v_u16){}; + x = test_v_u16(x, 42, 13); + printf("%d\n", (i16)x[I]); + x = (v_u16){}; + x = test_v_u16(x, 42, 55); + printf("%d\n", (i16)x[I]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i8){}; + x = test_v_i8(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i8){}; + x = test_v_i8(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42, 42); + printf("%d\n", (i8)x[I]); + x = (v_u8){}; + x = test_v_u8(x, 42, 13); + printf("%d\n", (i8)x[I]); + x = (v_u8){}; + x = test_v_u8(x, 42, 55); + printf("%d\n", (i8)x[I]); + } + + return 0; +} +--EXPECT-- +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 diff --git a/tests/vector/le-008.test b/tests/vector/le-008.test new file mode 100644 index 0000000..b95c938 --- /dev/null +++ b/tests/vector/le-008.test @@ -0,0 +1,239 @@ +--TEST-- +LE.008: 256-bit vectors AVX+AVX2 +--TARGET-- +!aarch64 +--ARGS-- +-mavx --run +--CODE-- +#define N 32 +#define I 3 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef double __attribute__((__vector_size__(N))) v_d; +typedef float __attribute__((__vector_size__(N))) v_f; +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_d __attribute__((noinline)) test_v_d(v_d v, double x, double y) +{ + return (v + x <= y); +} + +v_f __attribute__((noinline)) test_v_f(v_f v, float x, float y) +{ + return (v + x <= y); +} + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x, i64 y) +{ + return (v + x <= y); +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x, u64 y) +{ + return (v + x <= y); +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x, i32 y) +{ + return (v + x <= y); +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x, u32 y) +{ + return (v + x <= y); +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x, i16 y) +{ + return (v + x <= y); +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x, u16 y) +{ + return (v + x <= y); +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x, i8 y) +{ + return (v + x <= y); +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x, u8 y) +{ + return (v + x <= y); +} + +int main() +{ + { + v_d x = {}; + v_i64 y; + y = (v_i64)test_v_d(x, 42.42, 42.42); + printf("%lld\n", y[I]); + x = (v_d){}; + y = (v_i64)test_v_d(x, 42.42, 13.13); + printf("%lld\n", y[I]); + x = (v_d){}; + y = (v_i64)test_v_d(x, 42.42, 55.55); + printf("%lld\n", y[I]); + } + + { + v_f x = {}; + v_i32 y; + y = (v_i32)test_v_f(x, 42.42, 42.42); + printf("%d\n", y[I]); + x = (v_f){}; + y = (v_i32)test_v_f(x, 42.42, 13.13); + printf("%d\n", y[I]); + x = (v_f){}; + y = (v_i32)test_v_f(x, 42.42, 55.55); + printf("%d\n", y[I]); + } + + { + v_i64 x = {}; + x = test_v_i64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_i64){}; + x = test_v_i64(x, 42, 13); + printf("%lld\n", x[I]); + x = (v_i64){}; + x = test_v_i64(x, 42, 55); + printf("%lld\n", x[I]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_u64){}; + x = test_v_u64(x, 42, 13); + printf("%lld\n", x[I]); + x = (v_u64){}; + x = test_v_u64(x, 42, 55); + printf("%lld\n", x[I]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i32){}; + x = test_v_i32(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i32){}; + x = test_v_i32(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_u32){}; + x = test_v_u32(x, 42, 13); + printf("%d\n", x[I]); + x = (v_u32){}; + x = test_v_u32(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i16){}; + x = test_v_i16(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i16){}; + x = test_v_i16(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42, 42); + printf("%d\n", (i16)x[I]); + x = (v_u16){}; + x = test_v_u16(x, 42, 13); + printf("%d\n", (i16)x[I]); + x = (v_u16){}; + x = test_v_u16(x, 42, 55); + printf("%d\n", (i16)x[I]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i8){}; + x = test_v_i8(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i8){}; + x = test_v_i8(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42, 42); + printf("%d\n", (i8)x[I]); + x = (v_u8){}; + x = test_v_u8(x, 42, 13); + printf("%d\n", (i8)x[I]); + x = (v_u8){}; + x = test_v_u8(x, 42, 55); + printf("%d\n", (i8)x[I]); + } + + return 0; +} +--EXPECT-- +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 +-1 +0 +-1 diff --git a/tests/vector/lt-001.test b/tests/vector/lt-001.test new file mode 100644 index 0000000..18b0183 --- /dev/null +++ b/tests/vector/lt-001.test @@ -0,0 +1,239 @@ +--TEST-- +LT.001: 128-bit vectors SSE2 +--TARGET-- +!aarch64 +--ARGS-- +-mno-sse4 -mno-avx2 --run +--CODE-- +#define N 16 +#define I 1 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef double __attribute__((__vector_size__(N))) v_d; +typedef float __attribute__((__vector_size__(N))) v_f; +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_d __attribute__((noinline)) test_v_d(v_d v, double x, double y) +{ + return (v + x < y); +} + +v_f __attribute__((noinline)) test_v_f(v_f v, float x, float y) +{ + return (v + x < y); +} + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x, i64 y) +{ + return (v + x < y); +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x, u64 y) +{ + return (v + x < y); +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x, i32 y) +{ + return (v + x < y); +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x, u32 y) +{ + return (v + x < y); +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x, i16 y) +{ + return (v + x < y); +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x, u16 y) +{ + return (v + x < y); +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x, i8 y) +{ + return (v + x < y); +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x, u8 y) +{ + return (v + x < y); +} + +int main() +{ + { + v_d x = {}; + v_i64 y; + y = (v_i64)test_v_d(x, 42.42, 42.42); + printf("%lld\n", y[I]); + x = (v_d){}; + y = (v_i64)test_v_d(x, 42.42, 13.13); + printf("%lld\n", y[I]); + x = (v_d){}; + y = (v_i64)test_v_d(x, 42.42, 55.55); + printf("%lld\n", y[I]); + } + + { + v_f x = {}; + v_i32 y; + y = (v_i32)test_v_f(x, 42.42, 42.42); + printf("%d\n", y[I]); + x = (v_f){}; + y = (v_i32)test_v_f(x, 42.42, 13.13); + printf("%d\n", y[I]); + x = (v_f){}; + y = (v_i32)test_v_f(x, 42.42, 55.55); + printf("%d\n", y[I]); + } + + { + v_i64 x = {}; + x = test_v_i64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_i64){}; + x = test_v_i64(x, 42, 13); + printf("%lld\n", x[I]); + x = (v_i64){}; + x = test_v_i64(x, 42, 55); + printf("%lld\n", x[I]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_u64){}; + x = test_v_u64(x, 42, 13); + printf("%lld\n", x[I]); + x = (v_u64){}; + x = test_v_u64(x, 42, 55); + printf("%lld\n", x[I]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i32){}; + x = test_v_i32(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i32){}; + x = test_v_i32(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_u32){}; + x = test_v_u32(x, 42, 13); + printf("%d\n", x[I]); + x = (v_u32){}; + x = test_v_u32(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i16){}; + x = test_v_i16(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i16){}; + x = test_v_i16(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42, 42); + printf("%d\n", (i16)x[I]); + x = (v_u16){}; + x = test_v_u16(x, 42, 13); + printf("%d\n", (i16)x[I]); + x = (v_u16){}; + x = test_v_u16(x, 42, 55); + printf("%d\n", (i16)x[I]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i8){}; + x = test_v_i8(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i8){}; + x = test_v_i8(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42, 42); + printf("%d\n", (i8)x[I]); + x = (v_u8){}; + x = test_v_u8(x, 42, 13); + printf("%d\n", (i8)x[I]); + x = (v_u8){}; + x = test_v_u8(x, 42, 55); + printf("%d\n", (i8)x[I]); + } + + return 0; +} +--EXPECT-- +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 diff --git a/tests/vector/lt-002.test b/tests/vector/lt-002.test new file mode 100644 index 0000000..ab709c1 --- /dev/null +++ b/tests/vector/lt-002.test @@ -0,0 +1,239 @@ +--TEST-- +LT.002: 128-bit vectors SSE2+SSE4 +--TARGET-- +!aarch64 +--ARGS-- +-mno-avx2 --run +--CODE-- +#define N 16 +#define I 1 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef double __attribute__((__vector_size__(N))) v_d; +typedef float __attribute__((__vector_size__(N))) v_f; +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_d __attribute__((noinline)) test_v_d(v_d v, double x, double y) +{ + return (v + x < y); +} + +v_f __attribute__((noinline)) test_v_f(v_f v, float x, float y) +{ + return (v + x < y); +} + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x, i64 y) +{ + return (v + x < y); +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x, u64 y) +{ + return (v + x < y); +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x, i32 y) +{ + return (v + x < y); +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x, u32 y) +{ + return (v + x < y); +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x, i16 y) +{ + return (v + x < y); +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x, u16 y) +{ + return (v + x < y); +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x, i8 y) +{ + return (v + x < y); +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x, u8 y) +{ + return (v + x < y); +} + +int main() +{ + { + v_d x = {}; + v_i64 y; + y = (v_i64)test_v_d(x, 42.42, 42.42); + printf("%lld\n", y[I]); + x = (v_d){}; + y = (v_i64)test_v_d(x, 42.42, 13.13); + printf("%lld\n", y[I]); + x = (v_d){}; + y = (v_i64)test_v_d(x, 42.42, 55.55); + printf("%lld\n", y[I]); + } + + { + v_f x = {}; + v_i32 y; + y = (v_i32)test_v_f(x, 42.42, 42.42); + printf("%d\n", y[I]); + x = (v_f){}; + y = (v_i32)test_v_f(x, 42.42, 13.13); + printf("%d\n", y[I]); + x = (v_f){}; + y = (v_i32)test_v_f(x, 42.42, 55.55); + printf("%d\n", y[I]); + } + + { + v_i64 x = {}; + x = test_v_i64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_i64){}; + x = test_v_i64(x, 42, 13); + printf("%lld\n", x[I]); + x = (v_i64){}; + x = test_v_i64(x, 42, 55); + printf("%lld\n", x[I]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_u64){}; + x = test_v_u64(x, 42, 13); + printf("%lld\n", x[I]); + x = (v_u64){}; + x = test_v_u64(x, 42, 55); + printf("%lld\n", x[I]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i32){}; + x = test_v_i32(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i32){}; + x = test_v_i32(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_u32){}; + x = test_v_u32(x, 42, 13); + printf("%d\n", x[I]); + x = (v_u32){}; + x = test_v_u32(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i16){}; + x = test_v_i16(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i16){}; + x = test_v_i16(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42, 42); + printf("%d\n", (i16)x[I]); + x = (v_u16){}; + x = test_v_u16(x, 42, 13); + printf("%d\n", (i16)x[I]); + x = (v_u16){}; + x = test_v_u16(x, 42, 55); + printf("%d\n", (i16)x[I]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i8){}; + x = test_v_i8(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i8){}; + x = test_v_i8(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42, 42); + printf("%d\n", (i8)x[I]); + x = (v_u8){}; + x = test_v_u8(x, 42, 13); + printf("%d\n", (i8)x[I]); + x = (v_u8){}; + x = test_v_u8(x, 42, 55); + printf("%d\n", (i8)x[I]); + } + + return 0; +} +--EXPECT-- +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 diff --git a/tests/vector/lt-003.test b/tests/vector/lt-003.test new file mode 100644 index 0000000..af15526 --- /dev/null +++ b/tests/vector/lt-003.test @@ -0,0 +1,239 @@ +--TEST-- +LT.003: 128-bit vectors AVX +--TARGET-- +!aarch64 +--ARGS-- +-mavx -mno-avx2 --run +--CODE-- +#define N 16 +#define I 1 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef double __attribute__((__vector_size__(N))) v_d; +typedef float __attribute__((__vector_size__(N))) v_f; +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_d __attribute__((noinline)) test_v_d(v_d v, double x, double y) +{ + return (v + x < y); +} + +v_f __attribute__((noinline)) test_v_f(v_f v, float x, float y) +{ + return (v + x < y); +} + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x, i64 y) +{ + return (v + x < y); +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x, u64 y) +{ + return (v + x < y); +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x, i32 y) +{ + return (v + x < y); +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x, u32 y) +{ + return (v + x < y); +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x, i16 y) +{ + return (v + x < y); +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x, u16 y) +{ + return (v + x < y); +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x, i8 y) +{ + return (v + x < y); +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x, u8 y) +{ + return (v + x < y); +} + +int main() +{ + { + v_d x = {}; + v_i64 y; + y = (v_i64)test_v_d(x, 42.42, 42.42); + printf("%lld\n", y[I]); + x = (v_d){}; + y = (v_i64)test_v_d(x, 42.42, 13.13); + printf("%lld\n", y[I]); + x = (v_d){}; + y = (v_i64)test_v_d(x, 42.42, 55.55); + printf("%lld\n", y[I]); + } + + { + v_f x = {}; + v_i32 y; + y = (v_i32)test_v_f(x, 42.42, 42.42); + printf("%d\n", y[I]); + x = (v_f){}; + y = (v_i32)test_v_f(x, 42.42, 13.13); + printf("%d\n", y[I]); + x = (v_f){}; + y = (v_i32)test_v_f(x, 42.42, 55.55); + printf("%d\n", y[I]); + } + + { + v_i64 x = {}; + x = test_v_i64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_i64){}; + x = test_v_i64(x, 42, 13); + printf("%lld\n", x[I]); + x = (v_i64){}; + x = test_v_i64(x, 42, 55); + printf("%lld\n", x[I]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_u64){}; + x = test_v_u64(x, 42, 13); + printf("%lld\n", x[I]); + x = (v_u64){}; + x = test_v_u64(x, 42, 55); + printf("%lld\n", x[I]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i32){}; + x = test_v_i32(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i32){}; + x = test_v_i32(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_u32){}; + x = test_v_u32(x, 42, 13); + printf("%d\n", x[I]); + x = (v_u32){}; + x = test_v_u32(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i16){}; + x = test_v_i16(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i16){}; + x = test_v_i16(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42, 42); + printf("%d\n", (i16)x[I]); + x = (v_u16){}; + x = test_v_u16(x, 42, 13); + printf("%d\n", (i16)x[I]); + x = (v_u16){}; + x = test_v_u16(x, 42, 55); + printf("%d\n", (i16)x[I]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i8){}; + x = test_v_i8(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i8){}; + x = test_v_i8(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42, 42); + printf("%d\n", (i8)x[I]); + x = (v_u8){}; + x = test_v_u8(x, 42, 13); + printf("%d\n", (i8)x[I]); + x = (v_u8){}; + x = test_v_u8(x, 42, 55); + printf("%d\n", (i8)x[I]); + } + + return 0; +} +--EXPECT-- +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 diff --git a/tests/vector/lt-004.test b/tests/vector/lt-004.test new file mode 100644 index 0000000..850dc87 --- /dev/null +++ b/tests/vector/lt-004.test @@ -0,0 +1,239 @@ +--TEST-- +LT.004: 128-bit vectors AVX+AVX2 +--TARGET-- +!aarch64 +--ARGS-- +-mavx --run +--CODE-- +#define N 16 +#define I 1 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef double __attribute__((__vector_size__(N))) v_d; +typedef float __attribute__((__vector_size__(N))) v_f; +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_d __attribute__((noinline)) test_v_d(v_d v, double x, double y) +{ + return (v + x < y); +} + +v_f __attribute__((noinline)) test_v_f(v_f v, float x, float y) +{ + return (v + x < y); +} + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x, i64 y) +{ + return (v + x < y); +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x, u64 y) +{ + return (v + x < y); +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x, i32 y) +{ + return (v + x < y); +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x, u32 y) +{ + return (v + x < y); +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x, i16 y) +{ + return (v + x < y); +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x, u16 y) +{ + return (v + x < y); +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x, i8 y) +{ + return (v + x < y); +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x, u8 y) +{ + return (v + x < y); +} + +int main() +{ + { + v_d x = {}; + v_i64 y; + y = (v_i64)test_v_d(x, 42.42, 42.42); + printf("%lld\n", y[I]); + x = (v_d){}; + y = (v_i64)test_v_d(x, 42.42, 13.13); + printf("%lld\n", y[I]); + x = (v_d){}; + y = (v_i64)test_v_d(x, 42.42, 55.55); + printf("%lld\n", y[I]); + } + + { + v_f x = {}; + v_i32 y; + y = (v_i32)test_v_f(x, 42.42, 42.42); + printf("%d\n", y[I]); + x = (v_f){}; + y = (v_i32)test_v_f(x, 42.42, 13.13); + printf("%d\n", y[I]); + x = (v_f){}; + y = (v_i32)test_v_f(x, 42.42, 55.55); + printf("%d\n", y[I]); + } + + { + v_i64 x = {}; + x = test_v_i64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_i64){}; + x = test_v_i64(x, 42, 13); + printf("%lld\n", x[I]); + x = (v_i64){}; + x = test_v_i64(x, 42, 55); + printf("%lld\n", x[I]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_u64){}; + x = test_v_u64(x, 42, 13); + printf("%lld\n", x[I]); + x = (v_u64){}; + x = test_v_u64(x, 42, 55); + printf("%lld\n", x[I]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i32){}; + x = test_v_i32(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i32){}; + x = test_v_i32(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_u32){}; + x = test_v_u32(x, 42, 13); + printf("%d\n", x[I]); + x = (v_u32){}; + x = test_v_u32(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i16){}; + x = test_v_i16(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i16){}; + x = test_v_i16(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42, 42); + printf("%d\n", (i16)x[I]); + x = (v_u16){}; + x = test_v_u16(x, 42, 13); + printf("%d\n", (i16)x[I]); + x = (v_u16){}; + x = test_v_u16(x, 42, 55); + printf("%d\n", (i16)x[I]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i8){}; + x = test_v_i8(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i8){}; + x = test_v_i8(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42, 42); + printf("%d\n", (i8)x[I]); + x = (v_u8){}; + x = test_v_u8(x, 42, 13); + printf("%d\n", (i8)x[I]); + x = (v_u8){}; + x = test_v_u8(x, 42, 55); + printf("%d\n", (i8)x[I]); + } + + return 0; +} +--EXPECT-- +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 diff --git a/tests/vector/lt-005.test b/tests/vector/lt-005.test new file mode 100644 index 0000000..8c92a2d --- /dev/null +++ b/tests/vector/lt-005.test @@ -0,0 +1,239 @@ +--TEST-- +LT.005: 64-bit vectors SSE2 +--TARGET-- +!aarch64 +--ARGS-- +-mno-sse4 -mno-avx2 --run +--CODE-- +#define N 8 +#define I 0 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef double __attribute__((__vector_size__(N))) v_d; +typedef float __attribute__((__vector_size__(N))) v_f; +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_d __attribute__((noinline)) test_v_d(v_d v, double x, double y) +{ + return (v + x < y); +} + +v_f __attribute__((noinline)) test_v_f(v_f v, float x, float y) +{ + return (v + x < y); +} + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x, i64 y) +{ + return (v + x < y); +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x, u64 y) +{ + return (v + x < y); +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x, i32 y) +{ + return (v + x < y); +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x, u32 y) +{ + return (v + x < y); +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x, i16 y) +{ + return (v + x < y); +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x, u16 y) +{ + return (v + x < y); +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x, i8 y) +{ + return (v + x < y); +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x, u8 y) +{ + return (v + x < y); +} + +int main() +{ + { + v_d x = {}; + v_i64 y; + y = (v_i64)test_v_d(x, 42.42, 42.42); + printf("%lld\n", y[I]); + x = (v_d){}; + y = (v_i64)test_v_d(x, 42.42, 13.13); + printf("%lld\n", y[I]); + x = (v_d){}; + y = (v_i64)test_v_d(x, 42.42, 55.55); + printf("%lld\n", y[I]); + } + + { + v_f x = {}; + v_i32 y; + y = (v_i32)test_v_f(x, 42.42, 42.42); + printf("%d\n", y[I]); + x = (v_f){}; + y = (v_i32)test_v_f(x, 42.42, 13.13); + printf("%d\n", y[I]); + x = (v_f){}; + y = (v_i32)test_v_f(x, 42.42, 55.55); + printf("%d\n", y[I]); + } + + { + v_i64 x = {}; + x = test_v_i64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_i64){}; + x = test_v_i64(x, 42, 13); + printf("%lld\n", x[I]); + x = (v_i64){}; + x = test_v_i64(x, 42, 55); + printf("%lld\n", x[I]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_u64){}; + x = test_v_u64(x, 42, 13); + printf("%lld\n", x[I]); + x = (v_u64){}; + x = test_v_u64(x, 42, 55); + printf("%lld\n", x[I]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i32){}; + x = test_v_i32(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i32){}; + x = test_v_i32(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_u32){}; + x = test_v_u32(x, 42, 13); + printf("%d\n", x[I]); + x = (v_u32){}; + x = test_v_u32(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i16){}; + x = test_v_i16(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i16){}; + x = test_v_i16(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42, 42); + printf("%d\n", (i16)x[I]); + x = (v_u16){}; + x = test_v_u16(x, 42, 13); + printf("%d\n", (i16)x[I]); + x = (v_u16){}; + x = test_v_u16(x, 42, 55); + printf("%d\n", (i16)x[I]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i8){}; + x = test_v_i8(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i8){}; + x = test_v_i8(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42, 42); + printf("%d\n", (i8)x[I]); + x = (v_u8){}; + x = test_v_u8(x, 42, 13); + printf("%d\n", (i8)x[I]); + x = (v_u8){}; + x = test_v_u8(x, 42, 55); + printf("%d\n", (i8)x[I]); + } + + return 0; +} +--EXPECT-- +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 diff --git a/tests/vector/lt-006.test b/tests/vector/lt-006.test new file mode 100644 index 0000000..6ed265a --- /dev/null +++ b/tests/vector/lt-006.test @@ -0,0 +1,239 @@ +--TEST-- +LT.006: 64-bit vectors AVX +--TARGET-- +!aarch64 +--ARGS-- +-mavx -mno-avx2 --run +--CODE-- +#define N 8 +#define I 0 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef double __attribute__((__vector_size__(N))) v_d; +typedef float __attribute__((__vector_size__(N))) v_f; +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_d __attribute__((noinline)) test_v_d(v_d v, double x, double y) +{ + return (v + x < y); +} + +v_f __attribute__((noinline)) test_v_f(v_f v, float x, float y) +{ + return (v + x < y); +} + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x, i64 y) +{ + return (v + x < y); +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x, u64 y) +{ + return (v + x < y); +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x, i32 y) +{ + return (v + x < y); +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x, u32 y) +{ + return (v + x < y); +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x, i16 y) +{ + return (v + x < y); +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x, u16 y) +{ + return (v + x < y); +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x, i8 y) +{ + return (v + x < y); +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x, u8 y) +{ + return (v + x < y); +} + +int main() +{ + { + v_d x = {}; + v_i64 y; + y = (v_i64)test_v_d(x, 42.42, 42.42); + printf("%lld\n", y[I]); + x = (v_d){}; + y = (v_i64)test_v_d(x, 42.42, 13.13); + printf("%lld\n", y[I]); + x = (v_d){}; + y = (v_i64)test_v_d(x, 42.42, 55.55); + printf("%lld\n", y[I]); + } + + { + v_f x = {}; + v_i32 y; + y = (v_i32)test_v_f(x, 42.42, 42.42); + printf("%d\n", y[I]); + x = (v_f){}; + y = (v_i32)test_v_f(x, 42.42, 13.13); + printf("%d\n", y[I]); + x = (v_f){}; + y = (v_i32)test_v_f(x, 42.42, 55.55); + printf("%d\n", y[I]); + } + + { + v_i64 x = {}; + x = test_v_i64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_i64){}; + x = test_v_i64(x, 42, 13); + printf("%lld\n", x[I]); + x = (v_i64){}; + x = test_v_i64(x, 42, 55); + printf("%lld\n", x[I]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_u64){}; + x = test_v_u64(x, 42, 13); + printf("%lld\n", x[I]); + x = (v_u64){}; + x = test_v_u64(x, 42, 55); + printf("%lld\n", x[I]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i32){}; + x = test_v_i32(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i32){}; + x = test_v_i32(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_u32){}; + x = test_v_u32(x, 42, 13); + printf("%d\n", x[I]); + x = (v_u32){}; + x = test_v_u32(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i16){}; + x = test_v_i16(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i16){}; + x = test_v_i16(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42, 42); + printf("%d\n", (i16)x[I]); + x = (v_u16){}; + x = test_v_u16(x, 42, 13); + printf("%d\n", (i16)x[I]); + x = (v_u16){}; + x = test_v_u16(x, 42, 55); + printf("%d\n", (i16)x[I]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i8){}; + x = test_v_i8(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i8){}; + x = test_v_i8(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42, 42); + printf("%d\n", (i8)x[I]); + x = (v_u8){}; + x = test_v_u8(x, 42, 13); + printf("%d\n", (i8)x[I]); + x = (v_u8){}; + x = test_v_u8(x, 42, 55); + printf("%d\n", (i8)x[I]); + } + + return 0; +} +--EXPECT-- +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 diff --git a/tests/vector/lt-007.test b/tests/vector/lt-007.test new file mode 100644 index 0000000..1c6391b --- /dev/null +++ b/tests/vector/lt-007.test @@ -0,0 +1,239 @@ +--TEST-- +LT.007: 256-bit vectors AVX +--TARGET-- +!aarch64 +--ARGS-- +-mavx -mno-avx2 --run +--CODE-- +#define N 32 +#define I 3 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef double __attribute__((__vector_size__(N))) v_d; +typedef float __attribute__((__vector_size__(N))) v_f; +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_d __attribute__((noinline)) test_v_d(v_d v, double x, double y) +{ + return (v + x < y); +} + +v_f __attribute__((noinline)) test_v_f(v_f v, float x, float y) +{ + return (v + x < y); +} + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x, i64 y) +{ + return (v + x < y); +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x, u64 y) +{ + return (v + x < y); +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x, i32 y) +{ + return (v + x < y); +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x, u32 y) +{ + return (v + x < y); +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x, i16 y) +{ + return (v + x < y); +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x, u16 y) +{ + return (v + x < y); +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x, i8 y) +{ + return (v + x < y); +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x, u8 y) +{ + return (v + x < y); +} + +int main() +{ + { + v_d x = {}; + v_i64 y; + y = (v_i64)test_v_d(x, 42.42, 42.42); + printf("%lld\n", y[I]); + x = (v_d){}; + y = (v_i64)test_v_d(x, 42.42, 13.13); + printf("%lld\n", y[I]); + x = (v_d){}; + y = (v_i64)test_v_d(x, 42.42, 55.55); + printf("%lld\n", y[I]); + } + + { + v_f x = {}; + v_i32 y; + y = (v_i32)test_v_f(x, 42.42, 42.42); + printf("%d\n", y[I]); + x = (v_f){}; + y = (v_i32)test_v_f(x, 42.42, 13.13); + printf("%d\n", y[I]); + x = (v_f){}; + y = (v_i32)test_v_f(x, 42.42, 55.55); + printf("%d\n", y[I]); + } + + { + v_i64 x = {}; + x = test_v_i64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_i64){}; + x = test_v_i64(x, 42, 13); + printf("%lld\n", x[I]); + x = (v_i64){}; + x = test_v_i64(x, 42, 55); + printf("%lld\n", x[I]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_u64){}; + x = test_v_u64(x, 42, 13); + printf("%lld\n", x[I]); + x = (v_u64){}; + x = test_v_u64(x, 42, 55); + printf("%lld\n", x[I]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i32){}; + x = test_v_i32(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i32){}; + x = test_v_i32(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_u32){}; + x = test_v_u32(x, 42, 13); + printf("%d\n", x[I]); + x = (v_u32){}; + x = test_v_u32(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i16){}; + x = test_v_i16(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i16){}; + x = test_v_i16(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42, 42); + printf("%d\n", (i16)x[I]); + x = (v_u16){}; + x = test_v_u16(x, 42, 13); + printf("%d\n", (i16)x[I]); + x = (v_u16){}; + x = test_v_u16(x, 42, 55); + printf("%d\n", (i16)x[I]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i8){}; + x = test_v_i8(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i8){}; + x = test_v_i8(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42, 42); + printf("%d\n", (i8)x[I]); + x = (v_u8){}; + x = test_v_u8(x, 42, 13); + printf("%d\n", (i8)x[I]); + x = (v_u8){}; + x = test_v_u8(x, 42, 55); + printf("%d\n", (i8)x[I]); + } + + return 0; +} +--EXPECT-- +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 diff --git a/tests/vector/lt-008.test b/tests/vector/lt-008.test new file mode 100644 index 0000000..1e109f0 --- /dev/null +++ b/tests/vector/lt-008.test @@ -0,0 +1,239 @@ +--TEST-- +LT.008: 256-bit vectors AVX+AVX2 +--TARGET-- +!aarch64 +--ARGS-- +-mavx --run +--CODE-- +#define N 32 +#define I 3 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef double __attribute__((__vector_size__(N))) v_d; +typedef float __attribute__((__vector_size__(N))) v_f; +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_d __attribute__((noinline)) test_v_d(v_d v, double x, double y) +{ + return (v + x < y); +} + +v_f __attribute__((noinline)) test_v_f(v_f v, float x, float y) +{ + return (v + x < y); +} + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x, i64 y) +{ + return (v + x < y); +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x, u64 y) +{ + return (v + x < y); +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x, i32 y) +{ + return (v + x < y); +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x, u32 y) +{ + return (v + x < y); +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x, i16 y) +{ + return (v + x < y); +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x, u16 y) +{ + return (v + x < y); +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x, i8 y) +{ + return (v + x < y); +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x, u8 y) +{ + return (v + x < y); +} + +int main() +{ + { + v_d x = {}; + v_i64 y; + y = (v_i64)test_v_d(x, 42.42, 42.42); + printf("%lld\n", y[I]); + x = (v_d){}; + y = (v_i64)test_v_d(x, 42.42, 13.13); + printf("%lld\n", y[I]); + x = (v_d){}; + y = (v_i64)test_v_d(x, 42.42, 55.55); + printf("%lld\n", y[I]); + } + + { + v_f x = {}; + v_i32 y; + y = (v_i32)test_v_f(x, 42.42, 42.42); + printf("%d\n", y[I]); + x = (v_f){}; + y = (v_i32)test_v_f(x, 42.42, 13.13); + printf("%d\n", y[I]); + x = (v_f){}; + y = (v_i32)test_v_f(x, 42.42, 55.55); + printf("%d\n", y[I]); + } + + { + v_i64 x = {}; + x = test_v_i64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_i64){}; + x = test_v_i64(x, 42, 13); + printf("%lld\n", x[I]); + x = (v_i64){}; + x = test_v_i64(x, 42, 55); + printf("%lld\n", x[I]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_u64){}; + x = test_v_u64(x, 42, 13); + printf("%lld\n", x[I]); + x = (v_u64){}; + x = test_v_u64(x, 42, 55); + printf("%lld\n", x[I]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i32){}; + x = test_v_i32(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i32){}; + x = test_v_i32(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_u32){}; + x = test_v_u32(x, 42, 13); + printf("%d\n", x[I]); + x = (v_u32){}; + x = test_v_u32(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i16){}; + x = test_v_i16(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i16){}; + x = test_v_i16(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42, 42); + printf("%d\n", (i16)x[I]); + x = (v_u16){}; + x = test_v_u16(x, 42, 13); + printf("%d\n", (i16)x[I]); + x = (v_u16){}; + x = test_v_u16(x, 42, 55); + printf("%d\n", (i16)x[I]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i8){}; + x = test_v_i8(x, 42, 13); + printf("%d\n", x[I]); + x = (v_i8){}; + x = test_v_i8(x, 42, 55); + printf("%d\n", x[I]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42, 42); + printf("%d\n", (i8)x[I]); + x = (v_u8){}; + x = test_v_u8(x, 42, 13); + printf("%d\n", (i8)x[I]); + x = (v_u8){}; + x = test_v_u8(x, 42, 55); + printf("%d\n", (i8)x[I]); + } + + return 0; +} +--EXPECT-- +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 +0 +0 +-1 diff --git a/tests/vector/ne-001.test b/tests/vector/ne-001.test new file mode 100644 index 0000000..e7ac9d6 --- /dev/null +++ b/tests/vector/ne-001.test @@ -0,0 +1,199 @@ +--TEST-- +NE.001: 128-bit vectors SSE2 +--TARGET-- +!aarch64 +--ARGS-- +-mno-sse4 -mno-avx2 --run +--CODE-- +#define N 16 +#define I 1 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef double __attribute__((__vector_size__(N))) v_d; +typedef float __attribute__((__vector_size__(N))) v_f; +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_d __attribute__((noinline)) test_v_d(v_d v, double x, double y) +{ + return (v + x != y); +} + +v_f __attribute__((noinline)) test_v_f(v_f v, float x, float y) +{ + return (v + x != y); +} + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x, i64 y) +{ + return (v + x != y); +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x, u64 y) +{ + return (v + x != y); +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x, i32 y) +{ + return (v + x != y); +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x, u32 y) +{ + return (v + x != y); +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x, i16 y) +{ + return (v + x != y); +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x, u16 y) +{ + return (v + x != y); +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x, i8 y) +{ + return (v + x != y); +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x, u8 y) +{ + return (v + x != y); +} + +int main() +{ + { + v_d x = {}; + v_i64 y; + y = (v_i64)test_v_d(x, 42.42, 42.42); + printf("%lld\n", y[I]); + x = (v_d){}; + y = (v_i64)test_v_d(x, 42.42, 13.13); + printf("%lld\n", y[I]); + } + + { + v_f x = {}; + v_i32 y; + y = (v_i32)test_v_f(x, 42.42, 42.42); + printf("%d\n", y[I]); + x = (v_f){}; + y = (v_i32)test_v_f(x, 42.42, 13.13); + printf("%d\n", y[I]); + } + + { + v_i64 x = {}; + x = test_v_i64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_i64){}; + x = test_v_i64(x, 42, 13); + printf("%lld\n", x[I]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_u64){}; + x = test_v_u64(x, 42, 13); + printf("%lld\n", x[I]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i32){}; + x = test_v_i32(x, 42, 13); + printf("%d\n", x[I]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_u32){}; + x = test_v_u32(x, 42, 13); + printf("%d\n", x[I]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i16){}; + x = test_v_i16(x, 42, 13); + printf("%d\n", x[I]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42, 42); + printf("%d\n", (i16)x[I]); + x = (v_u16){}; + x = test_v_u16(x, 42, 13); + printf("%d\n", (i16)x[I]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i8){}; + x = test_v_i8(x, 42, 13); + printf("%d\n", x[I]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42, 42); + printf("%d\n", (i8)x[I]); + x = (v_u8){}; + x = test_v_u8(x, 42, 13); + printf("%d\n", (i8)x[I]); + } + + return 0; +} +--EXPECT-- +0 +-1 +0 +-1 +0 +-1 +0 +-1 +0 +-1 +0 +-1 +0 +-1 +0 +-1 +0 +-1 +0 +-1 diff --git a/tests/vector/ne-002.test b/tests/vector/ne-002.test new file mode 100644 index 0000000..4e12b10 --- /dev/null +++ b/tests/vector/ne-002.test @@ -0,0 +1,199 @@ +--TEST-- +NE.002: 128-bit vectors SSE2+SSE4 +--TARGET-- +!aarch64 +--ARGS-- +-mno-avx2 --run +--CODE-- +#define N 16 +#define I 1 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef double __attribute__((__vector_size__(N))) v_d; +typedef float __attribute__((__vector_size__(N))) v_f; +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_d __attribute__((noinline)) test_v_d(v_d v, double x, double y) +{ + return (v + x != y); +} + +v_f __attribute__((noinline)) test_v_f(v_f v, float x, float y) +{ + return (v + x != y); +} + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x, i64 y) +{ + return (v + x != y); +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x, u64 y) +{ + return (v + x != y); +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x, i32 y) +{ + return (v + x != y); +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x, u32 y) +{ + return (v + x != y); +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x, i16 y) +{ + return (v + x != y); +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x, u16 y) +{ + return (v + x != y); +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x, i8 y) +{ + return (v + x != y); +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x, u8 y) +{ + return (v + x != y); +} + +int main() +{ + { + v_d x = {}; + v_i64 y; + y = (v_i64)test_v_d(x, 42.42, 42.42); + printf("%lld\n", y[I]); + x = (v_d){}; + y = (v_i64)test_v_d(x, 42.42, 13.13); + printf("%lld\n", y[I]); + } + + { + v_f x = {}; + v_i32 y; + y = (v_i32)test_v_f(x, 42.42, 42.42); + printf("%d\n", y[I]); + x = (v_f){}; + y = (v_i32)test_v_f(x, 42.42, 13.13); + printf("%d\n", y[I]); + } + + { + v_i64 x = {}; + x = test_v_i64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_i64){}; + x = test_v_i64(x, 42, 13); + printf("%lld\n", x[I]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_u64){}; + x = test_v_u64(x, 42, 13); + printf("%lld\n", x[I]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i32){}; + x = test_v_i32(x, 42, 13); + printf("%d\n", x[I]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_u32){}; + x = test_v_u32(x, 42, 13); + printf("%d\n", x[I]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i16){}; + x = test_v_i16(x, 42, 13); + printf("%d\n", x[I]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42, 42); + printf("%d\n", (i16)x[I]); + x = (v_u16){}; + x = test_v_u16(x, 42, 13); + printf("%d\n", (i16)x[I]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i8){}; + x = test_v_i8(x, 42, 13); + printf("%d\n", x[I]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42, 42); + printf("%d\n", (i8)x[I]); + x = (v_u8){}; + x = test_v_u8(x, 42, 13); + printf("%d\n", (i8)x[I]); + } + + return 0; +} +--EXPECT-- +0 +-1 +0 +-1 +0 +-1 +0 +-1 +0 +-1 +0 +-1 +0 +-1 +0 +-1 +0 +-1 +0 +-1 diff --git a/tests/vector/ne-003.test b/tests/vector/ne-003.test new file mode 100644 index 0000000..c96d3af --- /dev/null +++ b/tests/vector/ne-003.test @@ -0,0 +1,199 @@ +--TEST-- +NE.003: 128-bit vectors AVX +--TARGET-- +!aarch64 +--ARGS-- +-mavx -mno-avx2 --run +--CODE-- +#define N 16 +#define I 1 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef double __attribute__((__vector_size__(N))) v_d; +typedef float __attribute__((__vector_size__(N))) v_f; +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_d __attribute__((noinline)) test_v_d(v_d v, double x, double y) +{ + return (v + x != y); +} + +v_f __attribute__((noinline)) test_v_f(v_f v, float x, float y) +{ + return (v + x != y); +} + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x, i64 y) +{ + return (v + x != y); +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x, u64 y) +{ + return (v + x != y); +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x, i32 y) +{ + return (v + x != y); +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x, u32 y) +{ + return (v + x != y); +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x, i16 y) +{ + return (v + x != y); +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x, u16 y) +{ + return (v + x != y); +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x, i8 y) +{ + return (v + x != y); +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x, u8 y) +{ + return (v + x != y); +} + +int main() +{ + { + v_d x = {}; + v_i64 y; + y = (v_i64)test_v_d(x, 42.42, 42.42); + printf("%lld\n", y[I]); + x = (v_d){}; + y = (v_i64)test_v_d(x, 42.42, 13.13); + printf("%lld\n", y[I]); + } + + { + v_f x = {}; + v_i32 y; + y = (v_i32)test_v_f(x, 42.42, 42.42); + printf("%d\n", y[I]); + x = (v_f){}; + y = (v_i32)test_v_f(x, 42.42, 13.13); + printf("%d\n", y[I]); + } + + { + v_i64 x = {}; + x = test_v_i64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_i64){}; + x = test_v_i64(x, 42, 13); + printf("%lld\n", x[I]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_u64){}; + x = test_v_u64(x, 42, 13); + printf("%lld\n", x[I]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i32){}; + x = test_v_i32(x, 42, 13); + printf("%d\n", x[I]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_u32){}; + x = test_v_u32(x, 42, 13); + printf("%d\n", x[I]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i16){}; + x = test_v_i16(x, 42, 13); + printf("%d\n", x[I]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42, 42); + printf("%d\n", (i16)x[I]); + x = (v_u16){}; + x = test_v_u16(x, 42, 13); + printf("%d\n", (i16)x[I]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i8){}; + x = test_v_i8(x, 42, 13); + printf("%d\n", x[I]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42, 42); + printf("%d\n", (i8)x[I]); + x = (v_u8){}; + x = test_v_u8(x, 42, 13); + printf("%d\n", (i8)x[I]); + } + + return 0; +} +--EXPECT-- +0 +-1 +0 +-1 +0 +-1 +0 +-1 +0 +-1 +0 +-1 +0 +-1 +0 +-1 +0 +-1 +0 +-1 diff --git a/tests/vector/ne-004.test b/tests/vector/ne-004.test new file mode 100644 index 0000000..806daf8 --- /dev/null +++ b/tests/vector/ne-004.test @@ -0,0 +1,199 @@ +--TEST-- +NE.004: 64-bit vectors SSE2 +--TARGET-- +!aarch64 +--ARGS-- +-mno-sse4 -mno-avx2 --run +--CODE-- +#define N 8 +#define I 0 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef double __attribute__((__vector_size__(N))) v_d; +typedef float __attribute__((__vector_size__(N))) v_f; +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_d __attribute__((noinline)) test_v_d(v_d v, double x, double y) +{ + return (v + x != y); +} + +v_f __attribute__((noinline)) test_v_f(v_f v, float x, float y) +{ + return (v + x != y); +} + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x, i64 y) +{ + return (v + x != y); +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x, u64 y) +{ + return (v + x != y); +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x, i32 y) +{ + return (v + x != y); +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x, u32 y) +{ + return (v + x != y); +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x, i16 y) +{ + return (v + x != y); +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x, u16 y) +{ + return (v + x != y); +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x, i8 y) +{ + return (v + x != y); +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x, u8 y) +{ + return (v + x != y); +} + +int main() +{ + { + v_d x = {}; + v_i64 y; + y = (v_i64)test_v_d(x, 42.42, 42.42); + printf("%lld\n", y[I]); + x = (v_d){}; + y = (v_i64)test_v_d(x, 42.42, 13.13); + printf("%lld\n", y[I]); + } + + { + v_f x = {}; + v_i32 y; + y = (v_i32)test_v_f(x, 42.42, 42.42); + printf("%d\n", y[I]); + x = (v_f){}; + y = (v_i32)test_v_f(x, 42.42, 13.13); + printf("%d\n", y[I]); + } + + { + v_i64 x = {}; + x = test_v_i64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_i64){}; + x = test_v_i64(x, 42, 13); + printf("%lld\n", x[I]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_u64){}; + x = test_v_u64(x, 42, 13); + printf("%lld\n", x[I]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i32){}; + x = test_v_i32(x, 42, 13); + printf("%d\n", x[I]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_u32){}; + x = test_v_u32(x, 42, 13); + printf("%d\n", x[I]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i16){}; + x = test_v_i16(x, 42, 13); + printf("%d\n", x[I]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42, 42); + printf("%d\n", (i16)x[I]); + x = (v_u16){}; + x = test_v_u16(x, 42, 13); + printf("%d\n", (i16)x[I]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i8){}; + x = test_v_i8(x, 42, 13); + printf("%d\n", x[I]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42, 42); + printf("%d\n", (i8)x[I]); + x = (v_u8){}; + x = test_v_u8(x, 42, 13); + printf("%d\n", (i8)x[I]); + } + + return 0; +} +--EXPECT-- +0 +-1 +0 +-1 +0 +-1 +0 +-1 +0 +-1 +0 +-1 +0 +-1 +0 +-1 +0 +-1 +0 +-1 diff --git a/tests/vector/ne-005.test b/tests/vector/ne-005.test new file mode 100644 index 0000000..7408108 --- /dev/null +++ b/tests/vector/ne-005.test @@ -0,0 +1,199 @@ +--TEST-- +NE.005: 256-bit vectors AVX +--TARGET-- +!aarch64 +--ARGS-- +-mavx -mno-avx2 --run +--CODE-- +#define N 32 +#define I 3 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef double __attribute__((__vector_size__(N))) v_d; +typedef float __attribute__((__vector_size__(N))) v_f; +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_d __attribute__((noinline)) test_v_d(v_d v, double x, double y) +{ + return (v + x != y); +} + +v_f __attribute__((noinline)) test_v_f(v_f v, float x, float y) +{ + return (v + x != y); +} + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x, i64 y) +{ + return (v + x != y); +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x, u64 y) +{ + return (v + x != y); +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x, i32 y) +{ + return (v + x != y); +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x, u32 y) +{ + return (v + x != y); +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x, i16 y) +{ + return (v + x != y); +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x, u16 y) +{ + return (v + x != y); +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x, i8 y) +{ + return (v + x != y); +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x, u8 y) +{ + return (v + x != y); +} + +int main() +{ + { + v_d x = {}; + v_i64 y; + y = (v_i64)test_v_d(x, 42.42, 42.42); + printf("%lld\n", y[I]); + x = (v_d){}; + y = (v_i64)test_v_d(x, 42.42, 13.13); + printf("%lld\n", y[I]); + } + + { + v_f x = {}; + v_i32 y; + y = (v_i32)test_v_f(x, 42.42, 42.42); + printf("%d\n", y[I]); + x = (v_f){}; + y = (v_i32)test_v_f(x, 42.42, 13.13); + printf("%d\n", y[I]); + } + + { + v_i64 x = {}; + x = test_v_i64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_i64){}; + x = test_v_i64(x, 42, 13); + printf("%lld\n", x[I]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42, 42); + printf("%lld\n", x[I]); + x = (v_u64){}; + x = test_v_u64(x, 42, 13); + printf("%lld\n", x[I]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i32){}; + x = test_v_i32(x, 42, 13); + printf("%d\n", x[I]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42, 42); + printf("%d\n", x[I]); + x = (v_u32){}; + x = test_v_u32(x, 42, 13); + printf("%d\n", x[I]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i16){}; + x = test_v_i16(x, 42, 13); + printf("%d\n", x[I]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42, 42); + printf("%d\n", (i16)x[I]); + x = (v_u16){}; + x = test_v_u16(x, 42, 13); + printf("%d\n", (i16)x[I]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42, 42); + printf("%d\n", x[I]); + x = (v_i8){}; + x = test_v_i8(x, 42, 13); + printf("%d\n", x[I]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42, 42); + printf("%d\n", (i8)x[I]); + x = (v_u8){}; + x = test_v_u8(x, 42, 13); + printf("%d\n", (i8)x[I]); + } + + return 0; +} +--EXPECT-- +0 +-1 +0 +-1 +0 +-1 +0 +-1 +0 +-1 +0 +-1 +0 +-1 +0 +-1 +0 +-1 +0 +-1 diff --git a/tests/vector/ne-006.test b/tests/vector/ne-006.test new file mode 100644 index 0000000..6804ac2 --- /dev/null +++ b/tests/vector/ne-006.test @@ -0,0 +1,199 @@ +--TEST-- +NE.006: 128-bit vectors SSE +--TARGET-- +!aarch64 +--ARGS-- +-mno-sse4 -mno-avx2 --run +--CODE-- +#define N 16 +#define I 1 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef double __attribute__((__vector_size__(N))) v_d; +typedef float __attribute__((__vector_size__(N))) v_f; +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_d __attribute__((noinline)) test_v_d(v_d v, double x) +{ + return (v + x != 42.42); +} + +v_f __attribute__((noinline)) test_v_f(v_f v, float x) +{ + return (v + x != 42.42f); +} + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x) +{ + return (v + x != 42); +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x) +{ + return (v + x != 42); +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x) +{ + return (v + x != 42); +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x) +{ + return (v + x != 42); +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x) +{ + return (v + x != 42); +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x) +{ + return (v + x != 42); +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x) +{ + return (v + x != 42); +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x) +{ + return (v + x != 42); +} + +int main() +{ + { + v_d x = {}; + v_i64 y; + y = (v_i64)test_v_d(x, 42.42); + printf("%lld\n", y[I]); + x = (v_d){}; + y = (v_i64)test_v_d(x, 13.13); + printf("%lld\n", y[I]); + } + + { + v_f x = {}; + v_i32 y; + y = (v_i32)test_v_f(x, 42.42); + printf("%d\n", y[I]); + x = (v_f){}; + y = (v_i32)test_v_f(x, 13.13); + printf("%d\n", y[I]); + } + + { + v_i64 x = {}; + x = test_v_i64(x, 42); + printf("%lld\n", x[I]); + x = (v_i64){}; + x = test_v_i64(x, 13); + printf("%lld\n", x[I]); + } + + { + v_u64 x = {}; + x = test_v_u64(x, 42); + printf("%lld\n", x[I]); + x = (v_u64){}; + x = test_v_u64(x, 13); + printf("%lld\n", x[I]); + } + + { + v_i32 x = {}; + x = test_v_i32(x, 42); + printf("%d\n", x[I]); + x = (v_i32){}; + x = test_v_i32(x, 13); + printf("%d\n", x[I]); + } + + { + v_u32 x = {}; + x = test_v_u32(x, 42); + printf("%d\n", x[I]); + x = (v_u32){}; + x = test_v_u32(x, 13); + printf("%d\n", x[I]); + } + + { + v_i16 x = {}; + x = test_v_i16(x, 42); + printf("%d\n", x[I]); + x = (v_i16){}; + x = test_v_i16(x, 13); + printf("%d\n", x[I]); + } + + { + v_u16 x = {}; + x = test_v_u16(x, 42); + printf("%d\n", (i16)x[I]); + x = (v_u16){}; + x = test_v_u16(x, 13); + printf("%d\n", (i16)x[I]); + } + + { + v_i8 x = {}; + x = test_v_i8(x, 42); + printf("%d\n", x[I]); + x = (v_i8){}; + x = test_v_i8(x, 13); + printf("%d\n", x[I]); + } + + { + v_u8 x = {}; + x = test_v_u8(x, 42); + printf("%d\n", (i8)x[I]); + x = (v_u8){}; + x = test_v_u8(x, 13); + printf("%d\n", (i8)x[I]); + } + + return 0; +} +--EXPECT-- +0 +-1 +0 +-1 +0 +-1 +0 +-1 +0 +-1 +0 +-1 +0 +-1 +0 +-1 +0 +-1 +0 +-1 diff --git a/tests/vector/neg-001.test b/tests/vector/neg-001.test index e1b594e..378f663 100644 --- a/tests/vector/neg-001.test +++ b/tests/vector/neg-001.test @@ -152,7 +152,7 @@ int main() printf("%d\n", -(i8)x[I]); } - return 0; + return 0; } --EXPECT-- 42.42 diff --git a/tests/vector/neg-002.test b/tests/vector/neg-002.test index 1a9baac..89a790c 100644 --- a/tests/vector/neg-002.test +++ b/tests/vector/neg-002.test @@ -152,7 +152,7 @@ int main() printf("%d\n", -(i8)x[I]); } - return 0; + return 0; } --EXPECT-- 42.42 diff --git a/tests/vector/neg-003.test b/tests/vector/neg-003.test index 98520cd..101ae42 100644 --- a/tests/vector/neg-003.test +++ b/tests/vector/neg-003.test @@ -152,7 +152,7 @@ int main() printf("%d\n", -(i8)x[I]); } - return 0; + return 0; } --EXPECT-- 42.42 diff --git a/tests/vector/neg-004.test b/tests/vector/neg-004.test index cdaf0a0..842e16f 100644 --- a/tests/vector/neg-004.test +++ b/tests/vector/neg-004.test @@ -152,7 +152,7 @@ int main() printf("%d\n", -(i8)x[I]); } - return 0; + return 0; } --EXPECT-- 42.42 diff --git a/tests/vector/neg-005.test b/tests/vector/neg-005.test index 19d761a..effe8b2 100644 --- a/tests/vector/neg-005.test +++ b/tests/vector/neg-005.test @@ -152,7 +152,7 @@ int main() printf("%d\n", -(i8)x[I]); } - return 0; + return 0; } --EXPECT-- 42.42 diff --git a/tests/vector/neg-006.test b/tests/vector/neg-006.test index 938c157..acf2dc5 100644 --- a/tests/vector/neg-006.test +++ b/tests/vector/neg-006.test @@ -152,7 +152,7 @@ int main() printf("%d\n", -(i8)x[I]); } - return 0; + return 0; } --EXPECT-- 42.42 diff --git a/tests/vector/not-001.test b/tests/vector/not-001.test index 1f54cef..bf6e490 100644 --- a/tests/vector/not-001.test +++ b/tests/vector/not-001.test @@ -126,7 +126,7 @@ int main() printf("%d\n", ~(i8)x[I]); } - return 0; + return 0; } --EXPECT-- 42 diff --git a/tests/vector/not-002.test b/tests/vector/not-002.test index 300f01d..27d0665 100644 --- a/tests/vector/not-002.test +++ b/tests/vector/not-002.test @@ -126,7 +126,7 @@ int main() printf("%d\n", ~(i8)x[I]); } - return 0; + return 0; } --EXPECT-- 42 diff --git a/tests/vector/not-003.test b/tests/vector/not-003.test index 6662949..f6d709a 100644 --- a/tests/vector/not-003.test +++ b/tests/vector/not-003.test @@ -126,7 +126,7 @@ int main() printf("%d\n", ~(i8)x[I]); } - return 0; + return 0; } --EXPECT-- 42 diff --git a/tests/vector/not-004.test b/tests/vector/not-004.test index 502c174..7da0922 100644 --- a/tests/vector/not-004.test +++ b/tests/vector/not-004.test @@ -126,7 +126,7 @@ int main() printf("%d\n", ~(i8)x[I]); } - return 0; + return 0; } --EXPECT-- 42 diff --git a/tests/vector/not-005.test b/tests/vector/not-005.test index 25b6a7c..02c7454 100644 --- a/tests/vector/not-005.test +++ b/tests/vector/not-005.test @@ -126,7 +126,7 @@ int main() printf("%d\n", ~(i8)x[I]); } - return 0; + return 0; } --EXPECT-- 42 diff --git a/tests/vector/not-006.test b/tests/vector/not-006.test index 2239fdb..accd186 100644 --- a/tests/vector/not-006.test +++ b/tests/vector/not-006.test @@ -126,7 +126,7 @@ int main() printf("%d\n", ~(i8)x[I]); } - return 0; + return 0; } --EXPECT-- 42 diff --git a/tests/vector/or-001.test b/tests/vector/or-001.test index 9793ba4..da4dad7 100644 --- a/tests/vector/or-001.test +++ b/tests/vector/or-001.test @@ -126,7 +126,7 @@ int main() printf("%d\n", x[I]); } - return 0; + return 0; } --EXPECT-- 42 diff --git a/tests/vector/or-002.test b/tests/vector/or-002.test index aef7bd5..3cac7c6 100644 --- a/tests/vector/or-002.test +++ b/tests/vector/or-002.test @@ -126,7 +126,7 @@ int main() printf("%d\n", x[I]); } - return 0; + return 0; } --EXPECT-- 42 diff --git a/tests/vector/or-003.test b/tests/vector/or-003.test index 7d42fe6..3ed181a 100644 --- a/tests/vector/or-003.test +++ b/tests/vector/or-003.test @@ -126,7 +126,7 @@ int main() printf("%d\n", x[I]); } - return 0; + return 0; } --EXPECT-- 42 diff --git a/tests/vector/or-004.test b/tests/vector/or-004.test index e5c27f1..8ad2a3c 100644 --- a/tests/vector/or-004.test +++ b/tests/vector/or-004.test @@ -126,7 +126,7 @@ int main() printf("%d\n", x[I]); } - return 0; + return 0; } --EXPECT-- 42 diff --git a/tests/vector/or-005.test b/tests/vector/or-005.test index 54f294d..61759b0 100644 --- a/tests/vector/or-005.test +++ b/tests/vector/or-005.test @@ -126,7 +126,7 @@ int main() printf("%d\n", x[I]); } - return 0; + return 0; } --EXPECT-- 42 diff --git a/tests/vector/or-006.test b/tests/vector/or-006.test index 77cba19..9dba59a 100644 --- a/tests/vector/or-006.test +++ b/tests/vector/or-006.test @@ -126,7 +126,7 @@ int main() printf("%d\n", x[I]); } - return 0; + return 0; } --EXPECT-- 42 diff --git a/tests/vector/replace-001.test b/tests/vector/replace-001.test index f8aecf6..6fa5180 100644 --- a/tests/vector/replace-001.test +++ b/tests/vector/replace-001.test @@ -152,7 +152,7 @@ int main() printf("%d\n", x[I]); } - return 0; + return 0; } --EXPECT-- 42.42 diff --git a/tests/vector/replace-002.test b/tests/vector/replace-002.test index adaf299..8ade7ab 100644 --- a/tests/vector/replace-002.test +++ b/tests/vector/replace-002.test @@ -152,7 +152,7 @@ int main() printf("%d\n", x[I]); } - return 0; + return 0; } --EXPECT-- 42.42 diff --git a/tests/vector/replace-003.test b/tests/vector/replace-003.test index 41aea09..7731043 100644 --- a/tests/vector/replace-003.test +++ b/tests/vector/replace-003.test @@ -152,7 +152,7 @@ int main() printf("%d\n", x[I]); } - return 0; + return 0; } --EXPECT-- 42.42 diff --git a/tests/vector/replace-004.test b/tests/vector/replace-004.test index ce056c6..3e160dd 100644 --- a/tests/vector/replace-004.test +++ b/tests/vector/replace-004.test @@ -152,7 +152,7 @@ int main() printf("%d\n", x[I]); } - return 0; + return 0; } --EXPECT-- 42.42 diff --git a/tests/vector/replace-005.test b/tests/vector/replace-005.test index 3a03349..7ec13fd 100644 --- a/tests/vector/replace-005.test +++ b/tests/vector/replace-005.test @@ -152,7 +152,7 @@ int main() printf("%d\n", x[I]); } - return 0; + return 0; } --EXPECT-- 42.42 diff --git a/tests/vector/replace-006.test b/tests/vector/replace-006.test index 074819a..852b275 100644 --- a/tests/vector/replace-006.test +++ b/tests/vector/replace-006.test @@ -152,7 +152,7 @@ int main() printf("%d\n", x[I]); } - return 0; + return 0; } --EXPECT-- 42.42 diff --git a/tests/vector/replace-007.test b/tests/vector/replace-007.test index 45fd7be..5fbb784 100644 --- a/tests/vector/replace-007.test +++ b/tests/vector/replace-007.test @@ -152,7 +152,7 @@ int main() printf("%d\n", x[I]); } - return 0; + return 0; } --EXPECT-- 42.42 diff --git a/tests/vector/replace-008.test b/tests/vector/replace-008.test index 581dab8..0174ff5 100644 --- a/tests/vector/replace-008.test +++ b/tests/vector/replace-008.test @@ -152,7 +152,7 @@ int main() printf("%d\n", x[I]); } - return 0; + return 0; } --EXPECT-- 42.42 diff --git a/tests/vector/replace-009.test b/tests/vector/replace-009.test index c603a81..856a312 100644 --- a/tests/vector/replace-009.test +++ b/tests/vector/replace-009.test @@ -152,7 +152,7 @@ int main() printf("%d\n", x[I]); } - return 0; + return 0; } --EXPECT-- 42.42 diff --git a/tests/vector/replace-010.test b/tests/vector/replace-010.test index 1f010b7..bf91c0f 100644 --- a/tests/vector/replace-010.test +++ b/tests/vector/replace-010.test @@ -152,7 +152,7 @@ int main() printf("%d\n", x[I]); } - return 0; + return 0; } --EXPECT-- 42.42 diff --git a/tests/vector/replace-011.test b/tests/vector/replace-011.test index 3b15b63..d2dad6e 100644 --- a/tests/vector/replace-011.test +++ b/tests/vector/replace-011.test @@ -151,7 +151,7 @@ int main() printf("%d\n", x[17]); } - return 0; + return 0; } --EXPECT-- 42.42 diff --git a/tests/vector/replace-012.test b/tests/vector/replace-012.test index 25efd4d..b4c442b 100644 --- a/tests/vector/replace-012.test +++ b/tests/vector/replace-012.test @@ -151,7 +151,7 @@ int main() printf("%d\n", x[17]); } - return 0; + return 0; } --EXPECT-- 42.42 From 66eaf2ba27b6f7c51f81876acb6b2a2236879f18 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Tue, 14 Jul 2026 22:06:59 +0300 Subject: [PATCH 20/31] Convert second operand of vector shifts according to x86 sematick --- rcc_semantic.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/rcc_semantic.c b/rcc_semantic.c index 2cfa40b..b17fa0d 100644 --- a/rcc_semantic.c +++ b/rcc_semantic.c @@ -6246,7 +6246,19 @@ static const c_type *c_common_type(rcc_ctx *rcc, yy_sym sym, c_value *op1, c_val } } } else if (C_IS_TYPE_KIND_SCALAR(t2)) { - if (c_do_splat(rcc, op1->type, op2)) { + if (sym == YY__LESS_LESS || sym == YY__GREATER_GREATER) { + /* For shifts: put count into the lower vector element */ + // TODO: may be this should be done in back-end ??? + ir_val v; + ir_ref ref; + ir_type t = c_type2ir(rcc, op1->type); + + v.u64 = 0; + ref = ir_SPLAT(t, ir_const(rcc->active_ctx, v, IR_VECTOR_BASE_TYPE(t))); + ref = ir_REPLACE(t, ref, ir_const_u8(rcc->active_ctx, 0), c_value_ref(rcc, op2)); + c_value_set_rval(op2, op1->type, t, ref); + return op1->type; + } else if (c_do_splat(rcc, op1->type, op2)) { return op1->type; } } From 9bdcd40a80e6b993493bd04a510bd0e2a54410cd Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Tue, 14 Jul 2026 23:08:46 +0300 Subject: [PATCH 21/31] Avoid memset() for vectors --- rcc_semantic.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/rcc_semantic.c b/rcc_semantic.c index b17fa0d..f43a002 100644 --- a/rcc_semantic.c +++ b/rcc_semantic.c @@ -9257,7 +9257,9 @@ void c_do_init_expr_start(rcc_ctx *rcc, c_sym *obj, const c_type *type) if (rcc->active_func && !rcc->c_static_data) { ir_ref size = ir_const_size_t(rcc->active_ctx, type->size); ir_ref addr = c_do_alloca(rcc, type->size, c_attr2align(type->attr), 0); - ir_memzero(rcc, addr, size, c_attr2align(type->attr)); + if (type->kind != C_TYPE_VECTOR) { + ir_memzero(rcc, addr, size, c_attr2align(type->attr)); + } c_value_set_rval(&obj->value, type, IR_ADDR, addr); } else { c_dcl d = {.type = type, .flags = C_DCL_DEFINITION, .attr = 0}; From e4b42e307ace72f4cd6dd66ed1bba00722d482f5 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Tue, 14 Jul 2026 23:21:23 +0300 Subject: [PATCH 22/31] Fix type conversion --- rcc_semantic.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/rcc_semantic.c b/rcc_semantic.c index f43a002..7f66d73 100644 --- a/rcc_semantic.c +++ b/rcc_semantic.c @@ -6072,7 +6072,7 @@ static bool c_try_convert_const_int2int(rcc_ctx *rcc, const c_type *type, c_valu return 1; } -static bool c_do_splat(rcc_ctx *rcc, const c_type *type, c_value *val) +static bool c_do_splat(rcc_ctx *rcc, const c_type *type, c_value *val, bool shift) { ir_type t; @@ -6122,7 +6122,19 @@ static bool c_do_splat(rcc_ctx *rcc, const c_type *type, c_value *val) } t = c_type2ir(rcc, type); - c_value_set_rval(val, type, t, ir_SPLAT(t, c_value_ref(rcc, val))); + if (shift) { + /* For shifts: put count into the lower vector element */ + // TODO: may be this should be done in back-end ??? + ir_val v; + ir_ref ref; + + v.u64 = 0; + ref = ir_SPLAT(t, ir_const(rcc->active_ctx, v, IR_VECTOR_BASE_TYPE(t))); + ref = ir_REPLACE(t, ref, ir_const_u8(rcc->active_ctx, 0), c_value_ref(rcc, val)); + c_value_set_rval(val, type, t, ref); + } else { + c_value_set_rval(val, type, t, ir_SPLAT(t, c_value_ref(rcc, val))); + } return 1; } @@ -6246,19 +6258,7 @@ static const c_type *c_common_type(rcc_ctx *rcc, yy_sym sym, c_value *op1, c_val } } } else if (C_IS_TYPE_KIND_SCALAR(t2)) { - if (sym == YY__LESS_LESS || sym == YY__GREATER_GREATER) { - /* For shifts: put count into the lower vector element */ - // TODO: may be this should be done in back-end ??? - ir_val v; - ir_ref ref; - ir_type t = c_type2ir(rcc, op1->type); - - v.u64 = 0; - ref = ir_SPLAT(t, ir_const(rcc->active_ctx, v, IR_VECTOR_BASE_TYPE(t))); - ref = ir_REPLACE(t, ref, ir_const_u8(rcc->active_ctx, 0), c_value_ref(rcc, op2)); - c_value_set_rval(op2, op1->type, t, ref); - return op1->type; - } else if (c_do_splat(rcc, op1->type, op2)) { + if (c_do_splat(rcc, op1->type, op2, sym == YY__LESS_LESS || sym == YY__GREATER_GREATER)) { return op1->type; } } @@ -6269,7 +6269,7 @@ static const c_type *c_common_type(rcc_ctx *rcc, yy_sym sym, c_value *op1, c_val return NULL; } } - if (c_do_splat(rcc, op2->type, op1)) { + if (c_do_splat(rcc, op2->type, op1, 0)) { return op2->type; } } else if (t2 == C_TYPE_FUNC) { From a9b53cbf421cf8093fb89272953407d1c52b0cb2 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Wed, 15 Jul 2026 15:05:48 +0300 Subject: [PATCH 23/31] Improve vector SIMD instruction support - make global arrays 16-byte aligned - make result of vector comparison to be an opaque vector, that can be implicitly casted to the required type --- rcc.c | 12 +++++-- rcc.h | 3 +- rcc_semantic.c | 92 ++++++++++++++++++++++++++++++++++++++++++++------ 3 files changed, 93 insertions(+), 14 deletions(-) diff --git a/rcc.c b/rcc.c index c90e7b2..4ad3c9d 100644 --- a/rcc.c +++ b/rcc.c @@ -597,9 +597,15 @@ static void* c_linker_resolve_sym_name(ir_loader *loader, ir_ctx *ctx, ir_str _n return NULL; } -void *c_linker_allocate_data(rcc_ctx *rcc, c_name name, size_t size, size_t align) +void *c_linker_allocate_data(rcc_ctx *rcc, c_name name, size_t size, size_t align, bool is_array) { - void *data = ir_arena_alloc_aligned(&rcc->c_linker_arena, size, align); + void *data; + + if (is_array && size >= 16 && align < 16) { + /* global array variable of length at least 16 bytes always has alignment of at least 16 byte */ + align = 16; + } + data = ir_arena_alloc_aligned(&rcc->c_linker_arena, size, align); if (UNEXPECTED(!data)) yy_error("not enough memory to allocate data"); if (align < 8) { align = 8; @@ -1146,7 +1152,7 @@ static void rcc_fix_flexible_data(rcc_ctx *rcc) p->sym->value.type = type; p->sym->value.u.optx = IR_OPT(C_VAL_CONST, IR_ADDR); - p->sym->value.u.val.ptr = c_linker_allocate_data(rcc, i, type->size, c_attr2align(type->attr)); + p->sym->value.u.val.ptr = c_linker_allocate_data(rcc, i, type->size, c_attr2align(type->attr), 1); p->sym->is_implemented = 1; //yy_warning_fmt("array \"%s\" assumed to have one element", p->str); // error position ??? diff --git a/rcc.h b/rcc.h index c026643..cf3a79a 100644 --- a/rcc.h +++ b/rcc.h @@ -760,6 +760,7 @@ typedef enum { C_TYPE_INPROGRESS = (1<<1), /* incomplete (not completely defined) struct, union */ C_TYPE_GLOBAL = (1<<2), C_TYPE_IN_FUNC = (1<<3), + C_TYPE_OPAQUE = (1<<4), /* opaque vector */ } c_type_flag; typedef yy_sym c_name; @@ -1304,7 +1305,7 @@ void yy_warning_(rcc_ctx *rcc, uint32_t kind, const char *msg); void yy_warning_fmt_(rcc_ctx *rcc, uint32_t kind, const char *fmt, ...); /* Linker */ -void *c_linker_allocate_data(rcc_ctx *rcc, c_name name, size_t size, size_t align); +void *c_linker_allocate_data(rcc_ctx *rcc, c_name name, size_t size, size_t align, bool is_array); bool c_linker_fix_reloc(rcc_ctx *rcc, c_sym *obj, size_t obj_offset, c_value *val); void c_linker_del_reloc(rcc_ctx *rcc, c_sym *obj, size_t obj_offset); diff --git a/rcc_semantic.c b/rcc_semantic.c index 7f66d73..dafcadd 100644 --- a/rcc_semantic.c +++ b/rcc_semantic.c @@ -916,6 +916,9 @@ static bool c_compatible_types(const c_type *t1, const c_type *t2, bool unqualif if (!c_compatible_types(t1->array.type, t2->array.type, 0, 0)) return 0; } else if (t1->kind == C_TYPE_POINTER) { if (!c_compatible_types(t1->pointer.type, t2->pointer.type, 0, 0)) return 0; + } else if (t1->kind == C_TYPE_VECTOR) { + if (t1->vec.length != t2->vec.length) return 0; + if (!c_compatible_types(t1->vec.type, t2->vec.type, 0, 0)) return 0; } else if (t1->kind == C_TYPE_STRUCT || t1->kind == C_TYPE_UNION) { if (t1->record.tag != t2->record.tag) return 0; if (t1->record.tag && t2->record.tag) return 1; @@ -978,7 +981,7 @@ static void c_do_end_flexible(rcc_ctx *rcc, c_sym *obj, size_t size) IR_ASSERT(IR_IS_EXT_STR(name)); sym = IR_EXT_STR(name); - addr = c_linker_allocate_data(rcc, sym, size, c_attr2align(obj->value.type->attr)); + addr = c_linker_allocate_data(rcc, sym, size, c_attr2align(obj->value.type->attr), 1); memcpy(addr, obj->value.u.val.ptr, size); ir_mem_free(obj->value.u.val.ptr); obj->value.u.val.ptr = addr; @@ -994,7 +997,7 @@ static void c_do_end_flexible(rcc_ctx *rcc, c_sym *obj, size_t size) } } else { addr = c_linker_allocate_data(rcc, obj->value.u.ref, size, - c_attr2align(obj->value.type->attr)); + c_attr2align(obj->value.type->attr), 1); memcpy(addr, obj->value.u.val.ptr, size); ir_mem_free(obj->value.u.val.ptr); obj->value.u.val.ptr = addr; @@ -1119,7 +1122,7 @@ static void c_validate_redeclaration(rcc_ctx *rcc, c_name name, c_dcl *d, c_sym sym->value.u.ref = name; /* keep name in addition to address */ } else { sym->value.u.val.ptr = c_linker_allocate_data(rcc, name, - sym->value.type->size, c_attr2align(sym->value.type->attr)); + sym->value.type->size, c_attr2align(sym->value.type->attr), sym->value.type->kind == C_TYPE_ARRAY); } } } @@ -1284,7 +1287,7 @@ static ir_ref c_create_str_sym(rcc_ctx *rcc, c_value *res) buf[--i] = 's'; name = yy_hash_lookup(rcc, buf + i, sizeof(buf) - 1 - i); - addr = c_linker_allocate_data(rcc, name, size, 8); + addr = c_linker_allocate_data(rcc, name, size, 8, 1); memcpy(addr, str, size); /* Create a global symbol in yy_arena */ @@ -1548,7 +1551,7 @@ c_sym *c_declare(rcc_ctx *rcc, c_name name, c_dcl *d) addr = ir_mem_calloc(1, d->type->size); } else { addr = c_linker_allocate_data(rcc, name, - d->type->size, c_attr2align(d->type->attr)); + d->type->size, c_attr2align(d->type->attr), d->type->kind == C_TYPE_ARRAY); } sym->value.u.optx = IR_OPT(C_VAL_CONST, IR_ADDR); sym->value.u.val.ptr = addr; @@ -1562,7 +1565,7 @@ c_sym *c_declare(rcc_ctx *rcc, c_name name, c_dcl *d) addr = ir_mem_calloc(1, d->type->size); } else { addr = c_linker_allocate_data(rcc, sym_name, - d->type->size, c_attr2align(d->type->attr)); + d->type->size, c_attr2align(d->type->attr), d->type->kind == C_TYPE_ARRAY); } rcc->yy_hash.data[sym_name].sym->value.u.optx = IR_OPT(C_VAL_CONST, IR_ADDR); rcc->yy_hash.data[sym_name].sym->value.u.val.ptr = addr; @@ -4180,6 +4183,47 @@ static ir_ref c_do_store(rcc_ctx *rcc, c_value *addr, c_value *val) } } +static const c_type *c_opaque_vector_type(rcc_ctx *rcc, const c_type *src_type) +{ + c_type *type = ir_arena_alloc(&rcc->c_arena, sizeof(c_type)); + + type->size = src_type->size; + type->kind = C_TYPE_VECTOR; + type->flags = (src_type->flags & ~C_TYPE_GLOBAL) | (rcc->active_scope ? 0 : C_TYPE_GLOBAL) | C_TYPE_OPAQUE; + type->attr = src_type->attr; + type->vec.length = src_type->vec.length; + + if (src_type->vec.type->size == 1) { + type->vec.type = &c_type_i8; + } else if (src_type->vec.type->size == 2) { + type->vec.type = &c_type_i16; + } else if (src_type->vec.type->size == 4) { + type->vec.type = &c_type_i32; + } else if (src_type->vec.type->size == 8) { + type->vec.type = &c_type_i64; + } else { + IR_ASSERT(0); + } + + return type; +} + +static void c_opaque_vector_cast(rcc_ctx *rcc, const c_type *type, c_value *val) +{ + ir_type t = c_type2ir(rcc, type); + +#if 0 + /* Update type of comparison */ + rcc->active_ctx->ir_base[val->u.ref].type = t; + val->type = type; + val->u.type = t; +#else + /* Implicit vector BITCAST */ + c_value_set_rval(val, type, t, ir_BITCAST(t, val->u.ref)); +#endif +} + + /* arg > 0 - means real argument number * arg == 0 - return value * arg == -1 - assign @@ -4299,10 +4343,16 @@ static void c_do_check_cvt(rcc_ctx *rcc, const c_type *type, c_value *val, int32 return; } else if (type->kind == C_TYPE_VECTOR && val->type->kind == C_TYPE_VECTOR - && type->vec.type->kind == val->type->vec.type->kind && type->vec.length == val->type->vec.length) { - /* identicl vector types */ - return; + if (type->vec.type->kind == val->type->vec.type->kind) { + /* identicl vector types */ + return; + } else if (type->size == val->type->size && (val->type->flags & C_TYPE_OPAQUE)) { + c_opaque_vector_cast(rcc, type, val); + return; + } else { + goto incompatible; + } } else { goto incompatible; } @@ -6253,12 +6303,29 @@ static const c_type *c_common_type(rcc_ctx *rcc, yy_sym sym, c_value *op1, c_val } if (t2 == C_TYPE_VECTOR) { if (op1->type->size == op2->type->size) { + if (op1->type->vec.type != op2->type->vec.type) { + if (op2->type->flags & C_TYPE_OPAQUE) { + c_opaque_vector_cast(rcc, op1->type, op2); + } else if (op1->type->flags & C_TYPE_OPAQUE) { + c_opaque_vector_cast(rcc, op2->type, op1); + } + } if (op1->type->vec.type == op2->type->vec.type) { + if ((sym == YY__LESS || sym == YY__LESS_EQUAL || sym == YY__GREATER || sym == YY__GREATER_EQUAL + || sym == YY__EQUAL_EQUAL || sym == YY__BANG_EQUAL) + && !C_IS_TYPE_SIGNED(op1->type->vec.type)) { + return c_opaque_vector_type(rcc, op1->type); + } return op1->type; } } } else if (C_IS_TYPE_KIND_SCALAR(t2)) { if (c_do_splat(rcc, op1->type, op2, sym == YY__LESS_LESS || sym == YY__GREATER_GREATER)) { + if ((sym == YY__LESS || sym == YY__LESS_EQUAL || sym == YY__GREATER || sym == YY__GREATER_EQUAL + || sym == YY__EQUAL_EQUAL || sym == YY__BANG_EQUAL) + && !C_IS_TYPE_SIGNED(op1->type->vec.type)) { + return c_opaque_vector_type(rcc, op1->type); + } return op1->type; } } @@ -6270,6 +6337,11 @@ static const c_type *c_common_type(rcc_ctx *rcc, yy_sym sym, c_value *op1, c_val } } if (c_do_splat(rcc, op2->type, op1, 0)) { + if ((sym == YY__LESS || sym == YY__LESS_EQUAL || sym == YY__GREATER || sym == YY__GREATER_EQUAL + || sym == YY__EQUAL_EQUAL || sym == YY__BANG_EQUAL) + && !C_IS_TYPE_SIGNED(op2->type->vec.type)) { + return c_opaque_vector_type(rcc, op2->type); + } return op2->type; } } else if (t2 == C_TYPE_FUNC) { @@ -9271,7 +9343,7 @@ void c_do_init_expr_start(rcc_ctx *rcc, c_sym *obj, const c_type *type) obj->tmp_data = 1; addr = ir_mem_calloc(1, type->size); } else { - addr = c_linker_allocate_data(rcc, 0, type->size, c_attr2align(type->attr)); + addr = c_linker_allocate_data(rcc, 0, type->size, c_attr2align(type->attr), type->kind == C_TYPE_ARRAY); } rcc->yy_hash.data[sym_name].sym->value.u.optx = IR_OPT(C_VAL_CONST, IR_ADDR); From 534a16b597b72227fed53fc0fae6e8f1e851fe6a Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Wed, 15 Jul 2026 22:17:40 +0300 Subject: [PATCH 24/31] Fix IR vector types encoding --- rcc_semantic.c | 4 +- tests/vector/shuffle-001.test | 158 ++++++++++++++++++++++++++++++++++ 2 files changed, 160 insertions(+), 2 deletions(-) create mode 100644 tests/vector/shuffle-001.test diff --git a/rcc_semantic.c b/rcc_semantic.c index dafcadd..73675c6 100644 --- a/rcc_semantic.c +++ b/rcc_semantic.c @@ -5283,7 +5283,6 @@ void c_do_builtin(rcc_ctx *rcc, c_value *val, c_name name, int32_t num_args, c_v op3 = c_value_ref(rcc, &args[2]); } - t = IR_MAKE_VECTOR_TYPE(c_type2ir(rcc, args[0].type->vec.type), len); if ((uint32_t)args[0].type->vec.length == len) { type = (c_type*)args[0].type; } else { @@ -5295,6 +5294,7 @@ void c_do_builtin(rcc_ctx *rcc, c_value *val, c_name name, int32_t num_args, c_v type->vec.type = args[0].type->vec.type; type->vec.length = len; } + t = c_type2ir(rcc, type); c_value_set_rval(val, type, t, ir_SHUFFLE(t, op1, op2, op3)); } else if (name == YY___BUILTIN_SHUFFLEVECTOR) { @@ -5328,7 +5328,6 @@ void c_do_builtin(rcc_ctx *rcc, c_value *val, c_name name, int32_t num_args, c_v ptr++; } - t = IR_MAKE_VECTOR_TYPE(c_type2ir(rcc, args[0].type->vec.type), len); if ((uint32_t)args[0].type->vec.length == len) { type = (c_type*)args[0].type; } else { @@ -5340,6 +5339,7 @@ void c_do_builtin(rcc_ctx *rcc, c_value *val, c_name name, int32_t num_args, c_v type->vec.type = args[0].type->vec.type; type->vec.length = len; } + t = c_type2ir(rcc, type); c_value_set_rval(val, type, t, ir_SHUFFLE(t, c_value_ref(rcc, &args[0]), c_value_ref(rcc, &args[1]), ref)); diff --git a/tests/vector/shuffle-001.test b/tests/vector/shuffle-001.test new file mode 100644 index 0000000..4374a66 --- /dev/null +++ b/tests/vector/shuffle-001.test @@ -0,0 +1,158 @@ +--TEST-- +SHUFFLE.001: 128-bit vectors SSE2 variable mask +--TARGET-- +!aarch64 +--ARGS-- +-mno-sse4 -mno-avx2 --run +--CODE-- +#define N 16 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef double __attribute__((__vector_size__(N))) v_d; +typedef float __attribute__((__vector_size__(N))) v_f; +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_d __attribute__((noinline)) test_v_d(v_d v, v_i64 m) +{ + return __builtin_shuffle(v, m); +} + +v_f __attribute__((noinline)) test_v_f(v_f v, v_i32 m) +{ + return __builtin_shuffle(v, m); +} + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, v_i64 m) +{ + return __builtin_shuffle(v, m); +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, v_i64 m) +{ + return __builtin_shuffle(v, m); +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, v_i32 m) +{ + return __builtin_shuffle(v, m); +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, v_i32 m) +{ + return __builtin_shuffle(v, m); +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, v_i16 m) +{ + return __builtin_shuffle(v, m); +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, v_i16 m) +{ + return __builtin_shuffle(v, m); +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, v_i8 m) +{ + return __builtin_shuffle(v, m); +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, v_i8 m) +{ + return __builtin_shuffle(v, m); +} + +int main() +{ + { + v_d x = {1.1, 2.2}; + x = test_v_d(x, (v_i64){1, 0}); + printf("%g %g\n", x[0], x[1]); + } + + { + v_f x = {1.1f, 2.2f}; + x = test_v_f(x, (v_i32){1, 0}); + printf("%g %g\n", x[0], x[1]); + } + + { + v_i64 x = {1, 2}; + x = test_v_i64(x, (v_i64){1, 0}); + printf("%lld %lld\n", x[0], x[1]); + } + + { + v_u64 x = {1, 2}; + x = test_v_u64(x, (v_i64){1, 0}); + printf("%lld %ld\n", x[0], x[1]); + } + + { + v_i32 x = {1,2,3,4}; + x = test_v_i32(x, (v_i32){1, 2, 3, 0}); + printf("%d %d %d %d\n", x[0], x[1], x[2], x[3]); + } + + { + v_u32 x = {1,2,3,4}; + x = test_v_u32(x, (v_i32){1, 2, 3, 0}); + printf("%d %d %d %d\n", x[0], x[1], x[2], x[3]); + } + + { + v_i16 x = {1,2,3,4,5,6,7,8}; + x = test_v_i16(x, (v_i16){1,2,3,4,5,6,7,0}); + printf("%d %d %d %d %d %d %d %d\n", x[0], x[1], x[2], x[3], x[4], x[5], x[6], x[7]); + } + + { + v_u16 x = {1,2,3,4,5,6,7,8}; + x = test_v_u16(x, (v_i16){1,2,3,4,5,6,7,0}); + printf("%d %d %d %d %d %d %d %d\n", x[0], x[1], x[2], x[3], x[4], x[5], x[6], x[7]); + } + + { + v_i8 x = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}; + x = test_v_i8(x, (v_i8){1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,0}); + printf("%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d\n", + x[0], x[1], x[2], x[3], x[4], x[5], x[6], x[7], x[8], x[9], x[10], x[11], x[12], x[13], x[14], x[15]); + } + + { + v_u8 x = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}; + x = test_v_u8(x, (v_i8){1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,0}); + printf("%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d\n", + x[0], x[1], x[2], x[3], x[4], x[5], x[6], x[7], x[8], x[9], x[10], x[11], x[12], x[13], x[14], x[15]); + } + + return 0; +} +--EXPECT-- +2.2 1.1 +2.2 1.1 +2 1 +2 1 +2 3 4 1 +2 3 4 1 +2 3 4 5 6 7 8 1 +2 3 4 5 6 7 8 1 +2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 1 +2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 1 From c37efcbb11b042cf6aa50ff07919976da87b8976 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Thu, 16 Jul 2026 00:01:43 +0300 Subject: [PATCH 25/31] Update SHUFFLE tests --- tests/vector/shuffle-001.test | 8 +- tests/vector/shuffle-002.test | 158 ++++++++++++++++++++++++++++++++++ 2 files changed, 162 insertions(+), 4 deletions(-) create mode 100644 tests/vector/shuffle-002.test diff --git a/tests/vector/shuffle-001.test b/tests/vector/shuffle-001.test index 4374a66..f88775b 100644 --- a/tests/vector/shuffle-001.test +++ b/tests/vector/shuffle-001.test @@ -88,9 +88,9 @@ int main() } { - v_f x = {1.1f, 2.2f}; - x = test_v_f(x, (v_i32){1, 0}); - printf("%g %g\n", x[0], x[1]); + v_f x = {1.1f, 2.2f, 3.3f, 4.4f}; + x = test_v_f(x, (v_i32){1, 2, 3, 0}); + printf("%g %g %g %g\n", x[0], x[1], x[2], x[3]); } { @@ -147,7 +147,7 @@ int main() } --EXPECT-- 2.2 1.1 -2.2 1.1 +2.2 3.3 4.4 1.1 2 1 2 1 2 3 4 1 diff --git a/tests/vector/shuffle-002.test b/tests/vector/shuffle-002.test new file mode 100644 index 0000000..9541d75 --- /dev/null +++ b/tests/vector/shuffle-002.test @@ -0,0 +1,158 @@ +--TEST-- +SHUFFLE.002: 128-bit vectors SSE2 constant mask +--TARGET-- +!aarch64 +--ARGS-- +-mno-sse4 -mno-avx2 --run +--CODE-- +#define N 16 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef double __attribute__((__vector_size__(N))) v_d; +typedef float __attribute__((__vector_size__(N))) v_f; +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_d __attribute__((noinline)) test_v_d(v_d v) +{ + return __builtin_shufflevector(v, v, 1, 0); +} + +v_f __attribute__((noinline)) test_v_f(v_f v) +{ + return __builtin_shufflevector(v, v, 1, 2, 3, 0); +} + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v) +{ + return __builtin_shufflevector(v, v, 1, 0); +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v) +{ + return __builtin_shufflevector(v, v, 1, 0); +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v) +{ + return __builtin_shufflevector(v, v, 1, 2, 3, 0); +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v) +{ + return __builtin_shufflevector(v, v, 1, 2, 3, 0); +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v) +{ + return __builtin_shufflevector(v, v, 1,2,3,4,5,6,7,0); +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v) +{ + return __builtin_shufflevector(v, v, 1,2,3,4,5,6,7,0); +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v) +{ + return __builtin_shufflevector(v, v, 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,0); +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v) +{ + return __builtin_shufflevector(v, v, 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,0); +} + +int main() +{ + { + v_d x = {1.1, 2.2}; + x = test_v_d(x); + printf("%g %g\n", x[0], x[1]); + } + + { + v_f x = {1.1f, 2.2f, 3.3f, 4.4f}; + x = test_v_f(x); + printf("%g %g %g %g\n", x[0], x[1], x[2], x[3]); + } + + { + v_i64 x = {1, 2}; + x = test_v_i64(x); + printf("%lld %lld\n", x[0], x[1]); + } + + { + v_u64 x = {1, 2}; + x = test_v_u64(x); + printf("%lld %ld\n", x[0], x[1]); + } + + { + v_i32 x = {1,2,3,4}; + x = test_v_i32(x); + printf("%d %d %d %d\n", x[0], x[1], x[2], x[3]); + } + + { + v_u32 x = {1,2,3,4}; + x = test_v_u32(x); + printf("%d %d %d %d\n", x[0], x[1], x[2], x[3]); + } + + { + v_i16 x = {1,2,3,4,5,6,7,8}; + x = test_v_i16(x); + printf("%d %d %d %d %d %d %d %d\n", x[0], x[1], x[2], x[3], x[4], x[5], x[6], x[7]); + } + + { + v_u16 x = {1,2,3,4,5,6,7,8}; + x = test_v_u16(x); + printf("%d %d %d %d %d %d %d %d\n", x[0], x[1], x[2], x[3], x[4], x[5], x[6], x[7]); + } + + { + v_i8 x = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}; + x = test_v_i8(x); + printf("%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d\n", + x[0], x[1], x[2], x[3], x[4], x[5], x[6], x[7], x[8], x[9], x[10], x[11], x[12], x[13], x[14], x[15]); + } + + { + v_u8 x = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}; + x = test_v_u8(x); + printf("%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d\n", + x[0], x[1], x[2], x[3], x[4], x[5], x[6], x[7], x[8], x[9], x[10], x[11], x[12], x[13], x[14], x[15]); + } + + return 0; +} +--EXPECT-- +2.2 1.1 +2.2 3.3 4.4 1.1 +2 1 +2 1 +2 3 4 1 +2 3 4 1 +2 3 4 5 6 7 8 1 +2 3 4 5 6 7 8 1 +2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 1 +2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 1 From 29c084eddbb55cc533b5a5f389381f08492270b3 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Thu, 16 Jul 2026 21:45:42 +0300 Subject: [PATCH 26/31] Construct SHL/SHR/SAR with vector and scalar operand (without SPLAT for the second) --- rcc_semantic.c | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/rcc_semantic.c b/rcc_semantic.c index 73675c6..91ee940 100644 --- a/rcc_semantic.c +++ b/rcc_semantic.c @@ -6122,7 +6122,7 @@ static bool c_try_convert_const_int2int(rcc_ctx *rcc, const c_type *type, c_valu return 1; } -static bool c_do_splat(rcc_ctx *rcc, const c_type *type, c_value *val, bool shift) +static bool c_do_splat(rcc_ctx *rcc, const c_type *type, c_value *val) { ir_type t; @@ -6172,19 +6172,7 @@ static bool c_do_splat(rcc_ctx *rcc, const c_type *type, c_value *val, bool shif } t = c_type2ir(rcc, type); - if (shift) { - /* For shifts: put count into the lower vector element */ - // TODO: may be this should be done in back-end ??? - ir_val v; - ir_ref ref; - - v.u64 = 0; - ref = ir_SPLAT(t, ir_const(rcc->active_ctx, v, IR_VECTOR_BASE_TYPE(t))); - ref = ir_REPLACE(t, ref, ir_const_u8(rcc->active_ctx, 0), c_value_ref(rcc, val)); - c_value_set_rval(val, type, t, ref); - } else { - c_value_set_rval(val, type, t, ir_SPLAT(t, c_value_ref(rcc, val))); - } + c_value_set_rval(val, type, t, ir_SPLAT(t, c_value_ref(rcc, val))); return 1; } @@ -6320,7 +6308,10 @@ static const c_type *c_common_type(rcc_ctx *rcc, yy_sym sym, c_value *op1, c_val } } } else if (C_IS_TYPE_KIND_SCALAR(t2)) { - if (c_do_splat(rcc, op1->type, op2, sym == YY__LESS_LESS || sym == YY__GREATER_GREATER)) { + if (sym == YY__LESS_LESS || sym == YY__GREATER_GREATER) { + if (!C_IS_TYPE_KIND_INT(t2)) return NULL; + return op1->type; + } else if (c_do_splat(rcc, op1->type, op2)) { if ((sym == YY__LESS || sym == YY__LESS_EQUAL || sym == YY__GREATER || sym == YY__GREATER_EQUAL || sym == YY__EQUAL_EQUAL || sym == YY__BANG_EQUAL) && !C_IS_TYPE_SIGNED(op1->type->vec.type)) { @@ -6336,7 +6327,7 @@ static const c_type *c_common_type(rcc_ctx *rcc, yy_sym sym, c_value *op1, c_val return NULL; } } - if (c_do_splat(rcc, op2->type, op1, 0)) { + if (c_do_splat(rcc, op2->type, op1)) { if ((sym == YY__LESS || sym == YY__LESS_EQUAL || sym == YY__GREATER || sym == YY__GREATER_EQUAL || sym == YY__EQUAL_EQUAL || sym == YY__BANG_EQUAL) && !C_IS_TYPE_SIGNED(op2->type->vec.type)) { @@ -6793,7 +6784,7 @@ static void c_do_mod(rcc_ctx *rcc, const c_type *type, c_value *op1, c_value *op static void c_do_shl(rcc_ctx *rcc, const c_type *type, c_value *op1, c_value *op2) { - if (c_value_is_const(op1) && c_value_is_const(op2)) { + if (c_value_is_const(op1) && c_value_is_const(op2) && op1->type->kind != C_TYPE_VECTOR) { ir_val val; uint32_t mask = (op2->type->size == 8) ? 63 : 31; @@ -6818,7 +6809,7 @@ static void c_do_shl(rcc_ctx *rcc, const c_type *type, c_value *op1, c_value *op static void c_do_shr(rcc_ctx *rcc, const c_type *type, c_value *op1, c_value *op2) { - if (c_value_is_const(op1) && c_value_is_const(op2)) { + if (c_value_is_const(op1) && c_value_is_const(op2) && op1->type->kind != C_TYPE_VECTOR) { ir_val val; uint32_t mask = (op2->type->size == 8) ? 63 : 31; From 25f4a525ccba356f4871f539fa156ba9944d8225 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Thu, 16 Jul 2026 21:46:31 +0300 Subject: [PATCH 27/31] Add more tests --- tests/vector/convert-fp2fp-001.test | 41 +++++++ tests/vector/convert-sext-001.test | 107 ++++++++++++++++++ tests/vector/convert-zext-001.test | 107 ++++++++++++++++++ tests/vector/div-001.test | 167 ++++++++++++++++++++++++++++ tests/vector/mod-001.test | 141 +++++++++++++++++++++++ tests/vector/mul-001.test | 167 ++++++++++++++++++++++++++++ tests/vector/shl-001.test | 139 +++++++++++++++++++++++ tests/vector/shr-001.test | 139 +++++++++++++++++++++++ 8 files changed, 1008 insertions(+) create mode 100644 tests/vector/convert-fp2fp-001.test create mode 100644 tests/vector/convert-sext-001.test create mode 100644 tests/vector/convert-zext-001.test create mode 100644 tests/vector/div-001.test create mode 100644 tests/vector/mod-001.test create mode 100644 tests/vector/mul-001.test create mode 100644 tests/vector/shl-001.test create mode 100644 tests/vector/shr-001.test diff --git a/tests/vector/convert-fp2fp-001.test b/tests/vector/convert-fp2fp-001.test new file mode 100644 index 0000000..43df1a9 --- /dev/null +++ b/tests/vector/convert-fp2fp-001.test @@ -0,0 +1,41 @@ +--TEST-- +CONVERT.FP2FP.001: 128-bit vectors SSE2 +--TARGET-- +!aarch64 +--ARGS-- +-mno-sse4 -mno-avx2 --run +--CODE-- +int printf(const char *, ...); + +typedef double __attribute__((__vector_size__(16))) v_2d; +typedef float __attribute__((__vector_size__(8))) v_4f; + +v_4f __attribute__((noinline)) test_d_f(v_2d v) +{ + return __builtin_convertvector(v, v_4f); +} + +v_2d __attribute__((noinline)) test_f_d(v_4f v) +{ + return __builtin_convertvector(v, v_2d); +} + +int main() +{ + { + v_2d x = {1.1, 2.2}; + v_4f y = test_d_f(x); + printf("%g %g\n", y[0], y[1]); + } + + { + v_4f x = {1.1f, 2.2f}; + v_2d y = test_f_d(x); + printf("%g %g\n", y[0], y[1]); + } + + return 0; +} +--EXPECT-- +1.1 2.2 +1.1 2.2 diff --git a/tests/vector/convert-sext-001.test b/tests/vector/convert-sext-001.test new file mode 100644 index 0000000..0b73d29 --- /dev/null +++ b/tests/vector/convert-sext-001.test @@ -0,0 +1,107 @@ +--TEST-- +CONVERT.SEXT.001: 128-bit vectors SSE2 +--TARGET-- +!aarch64 +--ARGS-- +-mno-sse4 -mno-avx2 --run +--CODE-- +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef i64 __attribute__((__vector_size__(16))) v_2i64; +typedef i32 __attribute__((__vector_size__(8))) v_2i32; +typedef i16 __attribute__((__vector_size__(4))) v_2i16; +typedef i8 __attribute__((__vector_size__(2))) v_2i8; + +typedef i32 __attribute__((__vector_size__(16))) v_4i32; +typedef i16 __attribute__((__vector_size__(8))) v_4i16; +typedef i8 __attribute__((__vector_size__(4))) v_4i8; + +typedef i16 __attribute__((__vector_size__(16))) v_8i16; +typedef i8 __attribute__((__vector_size__(8))) v_8i8; + +v_2i64 __attribute__((noinline)) test_i32_i64(v_2i32 v) +{ + return __builtin_convertvector(v, v_2i64); +} + +v_2i64 __attribute__((noinline)) test_i16_i64(v_2i16 v) +{ + return __builtin_convertvector(v, v_2i64); +} + +v_2i64 __attribute__((noinline)) test_i8_i64(v_2i8 v) +{ + return __builtin_convertvector(v, v_2i64); +} + +v_4i32 __attribute__((noinline)) test_i16_i32(v_4i16 v) +{ + return __builtin_convertvector(v, v_4i32); +} + +v_4i32 __attribute__((noinline)) test_i8_i32(v_4i8 v) +{ + return __builtin_convertvector(v, v_4i32); +} + +v_8i16 __attribute__((noinline)) test_i8_i16(v_8i8 v) +{ + return __builtin_convertvector(v, v_8i16); +} + +int main() +{ + { + v_8i8 x = {1, 2, 3, 4, 5, 6, 7, -8}; + v_8i16 y = test_i8_i16(x); + printf("%d %d %d %d %d %d %d %d\n", y[0], y[1], y[2], y[3], y[4], y[5], y[6], y[7]); + } + + { + v_4i8 x = {1, 2, 3, -4}; + v_4i32 y = test_i8_i32(x); + printf("%d %d %d %d\n", y[0], y[1], y[2], y[3]); + } + + { + v_4i16 x = {1, 2, 3, -4}; + v_4i32 y = test_i16_i32(x); + printf("%d %d %d %d\n", y[0], y[1], y[2], y[3]); + } + + { + v_2i8 x = {1, -2}; + v_2i64 y = test_i8_i64(x); + printf("%lld %lld\n", y[0], y[1]); + } + + { + v_2i16 x = {1, -2}; + v_2i64 y = test_i16_i64(x); + printf("%lld %lld\n", y[0], y[1]); + } + + { + v_2i32 x = {1, -2}; + v_2i64 y = test_i32_i64(x); + printf("%lld %lld\n", y[0], y[1]); + } + + return 0; +} +--EXPECT-- +1 2 3 4 5 6 7 -8 +1 2 3 -4 +1 2 3 -4 +1 -2 +1 -2 +1 -2 diff --git a/tests/vector/convert-zext-001.test b/tests/vector/convert-zext-001.test new file mode 100644 index 0000000..1e52b7e --- /dev/null +++ b/tests/vector/convert-zext-001.test @@ -0,0 +1,107 @@ +--TEST-- +CONVERT.ZEXT.001: 128-bit vectors SSE2 +--TARGET-- +!aarch64 +--ARGS-- +-mno-sse4 -mno-avx2 --run +--CODE-- +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef u64 __attribute__((__vector_size__(16))) v_2u64; +typedef u32 __attribute__((__vector_size__(8))) v_2u32; +typedef u16 __attribute__((__vector_size__(4))) v_2u16; +typedef u8 __attribute__((__vector_size__(2))) v_2u8; + +typedef u32 __attribute__((__vector_size__(16))) v_4u32; +typedef u16 __attribute__((__vector_size__(8))) v_4u16; +typedef u8 __attribute__((__vector_size__(4))) v_4u8; + +typedef u16 __attribute__((__vector_size__(16))) v_8u16; +typedef u8 __attribute__((__vector_size__(8))) v_8u8; + +v_2u64 __attribute__((noinline)) test_u32_u64(v_2u32 v) +{ + return __builtin_convertvector(v, v_2u64); +} + +v_2u64 __attribute__((noinline)) test_u16_u64(v_2u16 v) +{ + return __builtin_convertvector(v, v_2u64); +} + +v_2u64 __attribute__((noinline)) test_u8_u64(v_2u8 v) +{ + return __builtin_convertvector(v, v_2u64); +} + +v_4u32 __attribute__((noinline)) test_u16_u32(v_4u16 v) +{ + return __builtin_convertvector(v, v_4u32); +} + +v_4u32 __attribute__((noinline)) test_u8_u32(v_4u8 v) +{ + return __builtin_convertvector(v, v_4u32); +} + +v_8u16 __attribute__((noinline)) test_u8_u16(v_8u8 v) +{ + return __builtin_convertvector(v, v_8u16); +} + +int main() +{ + { + v_8u8 x = {1, 2, 3, 4, 5, 6, 7, -8}; + v_8u16 y = test_u8_u16(x); + printf("%u %u %u %u %u %u %u %u\n", y[0], y[1], y[2], y[3], y[4], y[5], y[6], y[7]); + } + + { + v_4u8 x = {1, 2, 3, -4}; + v_4u32 y = test_u8_u32(x); + printf("%u %u %u %u\n", y[0], y[1], y[2], y[3]); + } + + { + v_4u16 x = {1, 2, 3, -4}; + v_4u32 y = test_u16_u32(x); + printf("%u %u %u %u\n", y[0], y[1], y[2], y[3]); + } + + { + v_2u8 x = {1, -2}; + v_2u64 y = test_u8_u64(x); + printf("%llu %llu\n", y[0], y[1]); + } + + { + v_2u16 x = {1, -2}; + v_2u64 y = test_u16_u64(x); + printf("%llu %llu\n", y[0], y[1]); + } + + { + v_2u32 x = {1, -2}; + v_2u64 y = test_u32_u64(x); + printf("%llu %llu\n", y[0], y[1]); + } + + return 0; +} +--EXPECT-- +1 2 3 4 5 6 7 248 +1 2 3 252 +1 2 3 65532 +1 254 +1 65534 +1 4294967294 diff --git a/tests/vector/div-001.test b/tests/vector/div-001.test new file mode 100644 index 0000000..aab8dfe --- /dev/null +++ b/tests/vector/div-001.test @@ -0,0 +1,167 @@ +--TEST-- +DIV.001: 128-bit vectors SSE2 +--TARGET-- +!aarch64 +--ARGS-- +-mno-sse4 -mno-avx2 --run +--CODE-- +#define N 16 +#define I 1 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef double __attribute__((__vector_size__(N))) v_d; +typedef float __attribute__((__vector_size__(N))) v_f; +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_d __attribute__((noinline)) test_v_d(v_d v, double x) +{ + v = v / x; + return v; +} + +v_f __attribute__((noinline)) test_v_f(v_f v, float x) +{ + v = v / x; + return v; +} + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x) +{ + v = v / x; + return v; +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x) +{ + v = v / x; + return v; +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x) +{ + v = v / x; + return v; +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x) +{ + v = v / x; + return v; +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x) +{ + v = v / x; + return v; +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x) +{ + v = v / x; + return v; +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x) +{ + v = v / x; + return v; +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x) +{ + v = v / x; + return v; +} + +int main() +{ + { + v_d x = {42.42, 42.42}; + x = test_v_d(x, 3); + printf("%g\n", x[I]); + } + + { + v_f x = {42.42, 42.42, 42.42, 42.42}; + x = test_v_f(x, 3); + printf("%g\n", x[I]); + } + + { + v_i64 x = {42, 42}; + x = test_v_i64(x, 3); + printf("%lld\n", x[I]); + } + + { + v_u64 x = {42, 42}; + x = test_v_u64(x, 3); + printf("%lld\n", x[I]); + } + + { + v_i32 x = {42, 42, 42, 42}; + x = test_v_i32(x, 3); + printf("%d\n", x[I]); + } + + { + v_u32 x = {42, 42, 42, 42}; + x = test_v_u32(x, 3); + printf("%d\n", x[I]); + } + + { + v_i16 x = {42, 42, 42, 42, 42, 42, 42, 42}; + x = test_v_i16(x, 3); + printf("%d\n", x[I]); + } + + { + v_u16 x = {42, 42, 42, 42, 42, 42, 42, 42}; + x = test_v_u16(x, 3); + printf("%d\n", x[I]); + } + + { + v_i8 x = {42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42}; + x = test_v_i8(x, 3); + printf("%d\n", x[I]); + } + + { + v_u8 x = {42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42}; + x = test_v_u8(x, 3); + printf("%d\n", x[I]); + } + + return 0; +} +--EXPECT-- +14.14 +14.14 +14 +14 +14 +14 +14 +14 +14 +14 diff --git a/tests/vector/mod-001.test b/tests/vector/mod-001.test new file mode 100644 index 0000000..aed5016 --- /dev/null +++ b/tests/vector/mod-001.test @@ -0,0 +1,141 @@ +--TEST-- +MOD.001: 128-bit vectors SSE2 +--TARGET-- +!aarch64 +--ARGS-- +-mno-sse4 -mno-avx2 --run +--CODE-- +#define N 16 +#define I 1 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef double __attribute__((__vector_size__(N))) v_d; +typedef float __attribute__((__vector_size__(N))) v_f; +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x) +{ + v = v % x; + return v; +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x) +{ + v = v % x; + return v; +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x) +{ + v = v % x; + return v; +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x) +{ + v = v % x; + return v; +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x) +{ + v = v % x; + return v; +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x) +{ + v = v % x; + return v; +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x) +{ + v = v % x; + return v; +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x) +{ + v = v % x; + return v; +} + +int main() +{ + { + v_i64 x = {42, 42}; + x = test_v_i64(x, 13); + printf("%lld\n", x[I]); + } + + { + v_u64 x = {42, 42}; + x = test_v_u64(x, 13); + printf("%lld\n", x[I]); + } + + { + v_i32 x = {42, 42, 42, 42}; + x = test_v_i32(x, 13); + printf("%d\n", x[I]); + } + + { + v_u32 x = {42, 42, 42, 42}; + x = test_v_u32(x, 13); + printf("%d\n", x[I]); + } + + { + v_i16 x = {42, 42, 42, 42, 42, 42, 42, 42}; + x = test_v_i16(x, 13); + printf("%d\n", x[I]); + } + + { + v_u16 x = {42, 42, 42, 42, 42, 42, 42, 42}; + x = test_v_u16(x, 13); + printf("%d\n", x[I]); + } + + { + v_i8 x = {42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42}; + x = test_v_i8(x, 13); + printf("%d\n", x[I]); + } + + { + v_u8 x = {42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42}; + x = test_v_u8(x, 13); + printf("%d\n", x[I]); + } + + return 0; +} +--EXPECT-- +3 +3 +3 +3 +3 +3 +3 +3 diff --git a/tests/vector/mul-001.test b/tests/vector/mul-001.test new file mode 100644 index 0000000..bf13ee2 --- /dev/null +++ b/tests/vector/mul-001.test @@ -0,0 +1,167 @@ +--TEST-- +MUL.001: 128-bit vectors SSE2 +--TARGET-- +!aarch64 +--ARGS-- +-mno-sse4 -mno-avx2 --run +--CODE-- +#define N 16 +#define I 1 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef double __attribute__((__vector_size__(N))) v_d; +typedef float __attribute__((__vector_size__(N))) v_f; +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_d __attribute__((noinline)) test_v_d(v_d v, double x) +{ + v = v * x; + return v; +} + +v_f __attribute__((noinline)) test_v_f(v_f v, float x) +{ + v = v * x; + return v; +} + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x) +{ + v = v * x; + return v; +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x) +{ + v = v * x; + return v; +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x) +{ + v = v * x; + return v; +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x) +{ + v = v * x; + return v; +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x) +{ + v = v * x; + return v; +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x) +{ + v = v * x; + return v; +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x) +{ + v = v * x; + return v; +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x) +{ + v = v * x; + return v; +} + +int main() +{ + { + v_d x = {42.42, 42.42}; + x = test_v_d(x, 3); + printf("%g\n", x[I]); + } + + { + v_f x = {42.42, 42.42, 42.42, 42.42}; + x = test_v_f(x, 3); + printf("%g\n", x[I]); + } + + { + v_i64 x = {42, 42}; + x = test_v_i64(x, 3); + printf("%lld\n", x[I]); + } + + { + v_u64 x = {42, 42}; + x = test_v_u64(x, 3); + printf("%lld\n", x[I]); + } + + { + v_i32 x = {42, 42, 42, 42}; + x = test_v_i32(x, 3); + printf("%d\n", x[I]); + } + + { + v_u32 x = {42, 42, 42, 42}; + x = test_v_u32(x, 3); + printf("%d\n", x[I]); + } + + { + v_i16 x = {42, 42, 42, 42, 42, 42, 42, 42}; + x = test_v_i16(x, 3); + printf("%d\n", x[I]); + } + + { + v_u16 x = {42, 42, 42, 42, 42, 42, 42, 42}; + x = test_v_u16(x, 3); + printf("%d\n", x[I]); + } + + { + v_i8 x = {42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42}; + x = test_v_i8(x, 3); + printf("%d\n", x[I]); + } + + { + v_u8 x = {42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42}; + x = test_v_u8(x, 3); + printf("%d\n", x[I]); + } + + return 0; +} +--EXPECT-- +127.26 +127.26 +126 +126 +126 +126 +126 +126 +126 +126 diff --git a/tests/vector/shl-001.test b/tests/vector/shl-001.test new file mode 100644 index 0000000..fa78898 --- /dev/null +++ b/tests/vector/shl-001.test @@ -0,0 +1,139 @@ +--TEST-- +SHL.001: 128-bit vectors SSE2 +--TARGET-- +!aarch64 +--ARGS-- +-mno-sse4 -mno-avx2 --run +--CODE-- +#define N 16 +#define I 1 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x) +{ + v = v << x; + return v; +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x) +{ + v = v << x; + return v; +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x) +{ + v = v << x; + return v; +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x) +{ + v = v << x; + return v; +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x) +{ + v = v << x; + return v; +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x) +{ + v = v << x; + return v; +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x) +{ + v = v << x; + return v; +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x) +{ + v = v << x; + return v; +} + +int main() +{ + { + v_i64 x = {42, 42}; + x = test_v_i64(x, 2); + printf("%lld\n", x[I]); + } + + { + v_u64 x = {42, 42}; + x = test_v_u64(x, 2); + printf("%lld\n", x[I]); + } + + { + v_i32 x = {42, 42, 42, 42}; + x = test_v_i32(x, 2); + printf("%d\n", x[I]); + } + + { + v_u32 x = {42, 42, 42, 42}; + x = test_v_u32(x, 2); + printf("%d\n", x[I]); + } + + { + v_i16 x = {42, 42, 42, 42, 42, 42, 42, 42}; + x = test_v_i16(x, 2); + printf("%d\n", x[I]); + } + + { + v_u16 x = {42, 42, 42, 42, 42, 42, 42, 42}; + x = test_v_u16(x, 2); + printf("%d\n", x[I]); + } + + { + v_i8 x = {42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42}; + x = test_v_i8(x, 2); + printf("%d\n", (u8)x[I]); + } + + { + v_u8 x = {42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42}; + x = test_v_u8(x, 2); + printf("%d\n", x[I]); + } + + return 0; +} +--EXPECT-- +168 +168 +168 +168 +168 +168 +168 +168 diff --git a/tests/vector/shr-001.test b/tests/vector/shr-001.test new file mode 100644 index 0000000..ecf04ff --- /dev/null +++ b/tests/vector/shr-001.test @@ -0,0 +1,139 @@ +--TEST-- +SHR.001: 128-bit vectors SSE2 +--TARGET-- +!aarch64 +--ARGS-- +-mno-sse4 -mno-avx2 --run +--CODE-- +#define N 16 +#define I 1 + +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef i64 __attribute__((__vector_size__(N))) v_i64; +typedef u64 __attribute__((__vector_size__(N))) v_u64; +typedef i32 __attribute__((__vector_size__(N))) v_i32; +typedef u32 __attribute__((__vector_size__(N))) v_u32; +typedef i16 __attribute__((__vector_size__(N))) v_i16; +typedef u16 __attribute__((__vector_size__(N))) v_u16; +typedef i8 __attribute__((__vector_size__(N))) v_i8; +typedef u8 __attribute__((__vector_size__(N))) v_u8; + +v_i64 __attribute__((noinline)) test_v_i64(v_i64 v, i64 x) +{ + v = v >> x; + return v; +} + +v_u64 __attribute__((noinline)) test_v_u64(v_u64 v, u64 x) +{ + v = v >> x; + return v; +} + +v_i32 __attribute__((noinline)) test_v_i32(v_i32 v, i32 x) +{ + v = v >> x; + return v; +} + +v_u32 __attribute__((noinline)) test_v_u32(v_u32 v, u32 x) +{ + v = v >> x; + return v; +} + +v_i16 __attribute__((noinline)) test_v_i16(v_i16 v, i16 x) +{ + v = v >> x; + return v; +} + +v_u16 __attribute__((noinline)) test_v_u16(v_u16 v, u16 x) +{ + v = v >> x; + return v; +} + +v_i8 __attribute__((noinline)) test_v_i8(v_i8 v, i8 x) +{ + v = v >> x; + return v; +} + +v_u8 __attribute__((noinline)) test_v_u8(v_u8 v, u8 x) +{ + v = v >> x; + return v; +} + +int main() +{ + { + v_i64 x = {42, 42}; + x = test_v_i64(x, 2); + printf("%lld\n", x[I]); + } + + { + v_u64 x = {42, 42}; + x = test_v_u64(x, 2); + printf("%lld\n", x[I]); + } + + { + v_i32 x = {42, 42, 42, 42}; + x = test_v_i32(x, 2); + printf("%d\n", x[I]); + } + + { + v_u32 x = {42, 42, 42, 42}; + x = test_v_u32(x, 2); + printf("%d\n", x[I]); + } + + { + v_i16 x = {42, 42, 42, 42, 42, 42, 42, 42}; + x = test_v_i16(x, 2); + printf("%d\n", x[I]); + } + + { + v_u16 x = {42, 42, 42, 42, 42, 42, 42, 42}; + x = test_v_u16(x, 2); + printf("%d\n", x[I]); + } + + { + v_i8 x = {42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42}; + x = test_v_i8(x, 2); + printf("%d\n", x[I]); + } + + { + v_u8 x = {42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42}; + x = test_v_u8(x, 2); + printf("%d\n", x[I]); + } + + return 0; +} +--EXPECT-- +10 +10 +10 +10 +10 +10 +10 +10 From f4b9df7bc5e3fa7e8542bebbe110b9c449a01f77 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Tue, 21 Jul 2026 14:39:50 +0300 Subject: [PATCH 28/31] Run test suite for SIMD branch --- .github/workflows/push.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 5918ab5..b23afcc 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -30,6 +30,7 @@ jobs: uses: actions/checkout@v5 with: repository: dstogov/ir + branch: simd path: ir - name: make ir run: | @@ -73,6 +74,7 @@ jobs: uses: actions/checkout@v5 with: repository: dstogov/ir + branch: simd path: ir - name: make ir run: | @@ -103,6 +105,7 @@ jobs: uses: actions/checkout@v5 with: repository: dstogov/ir + branch: simd path: ir - name: make ir run: | @@ -128,6 +131,7 @@ jobs: uses: actions/checkout@v5 with: repository: dstogov/ir + branch: simd path: ir - name: Prepare env shell: powershell From 6765623a209a2944def05973f3e0d0b997726fc4 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Tue, 21 Jul 2026 14:45:14 +0300 Subject: [PATCH 29/31] Run test suite for SIMD branch --- .github/workflows/push.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index b23afcc..e5c9280 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -30,7 +30,7 @@ jobs: uses: actions/checkout@v5 with: repository: dstogov/ir - branch: simd + ref: simd path: ir - name: make ir run: | @@ -74,7 +74,7 @@ jobs: uses: actions/checkout@v5 with: repository: dstogov/ir - branch: simd + ref: simd path: ir - name: make ir run: | @@ -105,7 +105,7 @@ jobs: uses: actions/checkout@v5 with: repository: dstogov/ir - branch: simd + ref: simd path: ir - name: make ir run: | @@ -131,7 +131,7 @@ jobs: uses: actions/checkout@v5 with: repository: dstogov/ir - branch: simd + ref: simd path: ir - name: Prepare env shell: powershell From 82310c36fdc7014f56d31641237f10a56efe38ec Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Thu, 23 Jul 2026 23:10:28 +0300 Subject: [PATCH 30/31] Add vector truncation tests --- tests/vector/convert-trunc-001.test | 107 +++++++++++++++++++++++++++ tests/vector/convert-trunc-002.test | 107 +++++++++++++++++++++++++++ tests/vector/convert-trunc-003.test | 109 ++++++++++++++++++++++++++++ 3 files changed, 323 insertions(+) create mode 100644 tests/vector/convert-trunc-001.test create mode 100644 tests/vector/convert-trunc-002.test create mode 100644 tests/vector/convert-trunc-003.test diff --git a/tests/vector/convert-trunc-001.test b/tests/vector/convert-trunc-001.test new file mode 100644 index 0000000..90a39ad --- /dev/null +++ b/tests/vector/convert-trunc-001.test @@ -0,0 +1,107 @@ +--TEST-- +CONVERT.TRUNC.001: 128-bit vectors SSE2 +--TARGET-- +!aarch64 +--ARGS-- +-mno-sse4 -mno-avx2 --run +--CODE-- +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef i64 __attribute__((__vector_size__(16))) v_2i64; +typedef i32 __attribute__((__vector_size__(8))) v_2i32; +typedef i16 __attribute__((__vector_size__(4))) v_2i16; +typedef i8 __attribute__((__vector_size__(2))) v_2i8; + +typedef i32 __attribute__((__vector_size__(16))) v_4i32; +typedef i16 __attribute__((__vector_size__(8))) v_4i16; +typedef i8 __attribute__((__vector_size__(4))) v_4i8; + +typedef i16 __attribute__((__vector_size__(16))) v_8i16; +typedef i8 __attribute__((__vector_size__(8))) v_8i8; + +v_2i32 __attribute__((noinline)) test_i64_i32(v_2i64 v) +{ + return __builtin_convertvector(v, v_2i32); +} + +v_2i16 __attribute__((noinline)) test_i64_i16(v_2i64 v) +{ + return __builtin_convertvector(v, v_2i16); +} + +v_2i8 __attribute__((noinline)) test_i64_i8(v_2i64 v) +{ + return __builtin_convertvector(v, v_2i8); +} + +v_4i16 __attribute__((noinline)) test_i32_i16(v_4i32 v) +{ + return __builtin_convertvector(v, v_4i16); +} + +v_4i8 __attribute__((noinline)) test_i32_i8(v_4i32 v) +{ + return __builtin_convertvector(v, v_4i8); +} + +v_8i8 __attribute__((noinline)) test_i16_i8(v_8i16 v) +{ + return __builtin_convertvector(v, v_8i8); +} + +int main() +{ + { + v_2i64 x = {1, 2}; + v_2i32 y = test_i64_i32(x); + printf("%d %d\n", y[0], y[1]); + } + + { + v_2i64 x = {1, 2}; + v_2i16 y = test_i64_i16(x); + printf("%d %d\n", y[0], y[1]); + } + + { + v_2i64 x = {1, 2}; + v_2i8 y = test_i64_i8(x); + printf("%d %d\n", y[0], y[1]); + } + + { + v_4i32 x = {1, 2, 3, 4}; + v_4i16 y = test_i32_i16(x); + printf("%d %d %d %d\n", y[0], y[1], y[2], y[3]); + } + + { + v_4i32 x = {1, 2, 3, 4}; + v_4i8 y = test_i32_i8(x); + printf("%d %d %d %d\n", y[0], y[1], y[2], y[3]); + } + + { + v_8i16 x = {1, 2, 3, 4, 5, 6, 7, 8}; + v_8i8 y = test_i16_i8(x); + printf("%d %d %d %d %d %d %d %d\n", y[0], y[1], y[2], y[3], y[4], y[5], y[6], y[7]); + } + + return 0; +} +--EXPECT-- +1 2 +1 2 +1 2 +1 2 3 4 +1 2 3 4 +1 2 3 4 5 6 7 8 diff --git a/tests/vector/convert-trunc-002.test b/tests/vector/convert-trunc-002.test new file mode 100644 index 0000000..69d7df2 --- /dev/null +++ b/tests/vector/convert-trunc-002.test @@ -0,0 +1,107 @@ +--TEST-- +CONVERT.TRUNC.002: 128-bit vectors SSE2+SSE4 +--TARGET-- +!aarch64 +--ARGS-- +-msse4 -mno-avx2 --run +--CODE-- +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef i64 __attribute__((__vector_size__(16))) v_2i64; +typedef i32 __attribute__((__vector_size__(8))) v_2i32; +typedef i16 __attribute__((__vector_size__(4))) v_2i16; +typedef i8 __attribute__((__vector_size__(2))) v_2i8; + +typedef i32 __attribute__((__vector_size__(16))) v_4i32; +typedef i16 __attribute__((__vector_size__(8))) v_4i16; +typedef i8 __attribute__((__vector_size__(4))) v_4i8; + +typedef i16 __attribute__((__vector_size__(16))) v_8i16; +typedef i8 __attribute__((__vector_size__(8))) v_8i8; + +v_2i32 __attribute__((noinline)) test_i64_i32(v_2i64 v) +{ + return __builtin_convertvector(v, v_2i32); +} + +v_2i16 __attribute__((noinline)) test_i64_i16(v_2i64 v) +{ + return __builtin_convertvector(v, v_2i16); +} + +v_2i8 __attribute__((noinline)) test_i64_i8(v_2i64 v) +{ + return __builtin_convertvector(v, v_2i8); +} + +v_4i16 __attribute__((noinline)) test_i32_i16(v_4i32 v) +{ + return __builtin_convertvector(v, v_4i16); +} + +v_4i8 __attribute__((noinline)) test_i32_i8(v_4i32 v) +{ + return __builtin_convertvector(v, v_4i8); +} + +v_8i8 __attribute__((noinline)) test_i16_i8(v_8i16 v) +{ + return __builtin_convertvector(v, v_8i8); +} + +int main() +{ + { + v_2i64 x = {1, 2}; + v_2i32 y = test_i64_i32(x); + printf("%d %d\n", y[0], y[1]); + } + + { + v_2i64 x = {1, 2}; + v_2i16 y = test_i64_i16(x); + printf("%d %d\n", y[0], y[1]); + } + + { + v_2i64 x = {1, 2}; + v_2i8 y = test_i64_i8(x); + printf("%d %d\n", y[0], y[1]); + } + + { + v_4i32 x = {1, 2, 3, 4}; + v_4i16 y = test_i32_i16(x); + printf("%d %d %d %d\n", y[0], y[1], y[2], y[3]); + } + + { + v_4i32 x = {1, 2, 3, 4}; + v_4i8 y = test_i32_i8(x); + printf("%d %d %d %d\n", y[0], y[1], y[2], y[3]); + } + + { + v_8i16 x = {1, 2, 3, 4, 5, 6, 7, 8}; + v_8i8 y = test_i16_i8(x); + printf("%d %d %d %d %d %d %d %d\n", y[0], y[1], y[2], y[3], y[4], y[5], y[6], y[7]); + } + + return 0; +} +--EXPECT-- +1 2 +1 2 +1 2 +1 2 3 4 +1 2 3 4 +1 2 3 4 5 6 7 8 diff --git a/tests/vector/convert-trunc-003.test b/tests/vector/convert-trunc-003.test new file mode 100644 index 0000000..f167487 --- /dev/null +++ b/tests/vector/convert-trunc-003.test @@ -0,0 +1,109 @@ +--TEST-- +CONVERT.TRUNC.003: 256-bit vectors AVX +--TARGET-- +!aarch64 +--ARGS-- +-mavx --run +--CODE-- +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef i64 __attribute__((__vector_size__(32))) v_4i64; +typedef i32 __attribute__((__vector_size__(16))) v_4i32; +typedef i16 __attribute__((__vector_size__(8))) v_4i16; +typedef i8 __attribute__((__vector_size__(4))) v_4i8; + +typedef i32 __attribute__((__vector_size__(32))) v_8i32; +typedef i16 __attribute__((__vector_size__(16))) v_8i16; +typedef i8 __attribute__((__vector_size__(8))) v_8i8; + +typedef i16 __attribute__((__vector_size__(32))) v_16i16; +typedef i8 __attribute__((__vector_size__(16))) v_16i8; + +v_4i32 __attribute__((noinline)) test_i64_i32(v_4i64 v) +{ + return __builtin_convertvector(v, v_4i32); +} + +v_4i16 __attribute__((noinline)) test_i64_i16(v_4i64 v) +{ + return __builtin_convertvector(v, v_4i16); +} + +v_4i8 __attribute__((noinline)) test_i64_i8(v_4i64 v) +{ + return __builtin_convertvector(v, v_4i8); +} + +v_8i16 __attribute__((noinline)) test_i32_i16(v_8i32 v) +{ + return __builtin_convertvector(v, v_8i16); +} + +v_8i8 __attribute__((noinline)) test_i32_i8(v_8i32 v) +{ + return __builtin_convertvector(v, v_8i8); +} + +v_16i8 __attribute__((noinline)) test_i16_i8(v_16i16 v) +{ + return __builtin_convertvector(v, v_16i8); +} + +int main() +{ + { + v_4i64 x = {1, 2, 3, 4}; + v_4i32 y = test_i64_i32(x); + printf("%d %d %d %d\n", y[0], y[1], y[2], y[3]); + } + + { + v_4i64 x = {1, 2, 3, 4}; + v_4i16 y = test_i64_i16(x); + printf("%d %d %d %d\n", y[0], y[1], y[2], y[3]); + } + + { + v_4i64 x = {1, 2, 3, 4}; + v_4i8 y = test_i64_i8(x); + printf("%d %d %d %d\n", y[0], y[1], y[2], y[3]); + } + + { + v_8i32 x = {1, 2, 3, 4, 5, 6, 7, 8}; + v_8i16 y = test_i32_i16(x); + printf("%d %d %d %d %d %d %d %d\n", y[0], y[1], y[2], y[3], y[4], y[5], y[6], y[7]); + } + + { + v_8i32 x = {1, 2, 3, 4, 5, 6, 7, 8}; + v_8i8 y = test_i32_i8(x); + printf("%d %d %d %d %d %d %d %d\n", y[0], y[1], y[2], y[3], y[4], y[5], y[6], y[7]); + } + + { + v_16i16 x = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}; + v_16i8 y = test_i16_i8(x); + printf("%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d\n", + y[0], y[1], y[2], y[3], y[4], y[5], y[6], y[7], + y[8], y[9], y[10], y[11], y[12], y[13], y[14], y[15]); + } + + return 0; +} +--EXPECT-- +1 2 3 4 +1 2 3 4 +1 2 3 4 +1 2 3 4 5 6 7 8 +1 2 3 4 5 6 7 8 +1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 From cb30826d517f531c98a26e5c6aa09644ca4de686 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Fri, 24 Jul 2026 08:51:38 +0300 Subject: [PATCH 31/31] Add AVX tests --- tests/vector/convert-fp2fp-002.test | 41 +++++++++++ tests/vector/convert-sext-002.test | 109 ++++++++++++++++++++++++++++ tests/vector/convert-zext-002.test | 109 ++++++++++++++++++++++++++++ tests/vector/shuffle-001.test | 2 +- tests/vector/shuffle-002.test | 2 +- 5 files changed, 261 insertions(+), 2 deletions(-) create mode 100644 tests/vector/convert-fp2fp-002.test create mode 100644 tests/vector/convert-sext-002.test create mode 100644 tests/vector/convert-zext-002.test diff --git a/tests/vector/convert-fp2fp-002.test b/tests/vector/convert-fp2fp-002.test new file mode 100644 index 0000000..6ecb2f2 --- /dev/null +++ b/tests/vector/convert-fp2fp-002.test @@ -0,0 +1,41 @@ +--TEST-- +CONVERT.FP2FP.001: 256-bit vectors AVX +--TARGET-- +!aarch64 +--ARGS-- +-mavx --run +--CODE-- +int printf(const char *, ...); + +typedef double __attribute__((__vector_size__(32))) v_d; +typedef float __attribute__((__vector_size__(16))) v_f; + +v_f __attribute__((noinline)) test_d_f(v_d v) +{ + return __builtin_convertvector(v, v_f); +} + +v_d __attribute__((noinline)) test_f_d(v_f v) +{ + return __builtin_convertvector(v, v_d); +} + +int main() +{ + { + v_d x = {1.1, 2.2, 3.3, 4.4}; + v_f y = test_d_f(x); + printf("%g %g %g %g\n", y[0], y[1], y[2], y[3]); + } + + { + v_f x = {1.1f, 2.2f, 3.3f, 4.4f}; + v_d y = test_f_d(x); + printf("%g %g %g %g\n", y[0], y[1], y[2], y[3]); + } + + return 0; +} +--EXPECT-- +1.1 2.2 3.3 4.4 +1.1 2.2 3.3 4.4 diff --git a/tests/vector/convert-sext-002.test b/tests/vector/convert-sext-002.test new file mode 100644 index 0000000..5fd103f --- /dev/null +++ b/tests/vector/convert-sext-002.test @@ -0,0 +1,109 @@ +--TEST-- +CONVERT.SEXT.002: 256-bit vectors AVX +--TARGET-- +!aarch64 +--ARGS-- +-mavx --run +--CODE-- +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef i64 __attribute__((__vector_size__(32))) v_4i64; +typedef i32 __attribute__((__vector_size__(16))) v_4i32; +typedef i16 __attribute__((__vector_size__(8))) v_4i16; +typedef i8 __attribute__((__vector_size__(4))) v_4i8; + +typedef i32 __attribute__((__vector_size__(32))) v_8i32; +typedef i16 __attribute__((__vector_size__(16))) v_8i16; +typedef i8 __attribute__((__vector_size__(8))) v_8i8; + +typedef i16 __attribute__((__vector_size__(32))) v_16i16; +typedef i8 __attribute__((__vector_size__(16))) v_16i8; + +v_4i64 __attribute__((noinline)) test_i32_i64(v_4i32 v) +{ + return __builtin_convertvector(v, v_4i64); +} + +v_4i64 __attribute__((noinline)) test_i16_i64(v_4i16 v) +{ + return __builtin_convertvector(v, v_4i64); +} + +v_4i64 __attribute__((noinline)) test_i8_i64(v_4i8 v) +{ + return __builtin_convertvector(v, v_4i64); +} + +v_8i32 __attribute__((noinline)) test_i16_i32(v_8i16 v) +{ + return __builtin_convertvector(v, v_8i32); +} + +v_8i32 __attribute__((noinline)) test_i8_i32(v_8i8 v) +{ + return __builtin_convertvector(v, v_8i32); +} + +v_16i16 __attribute__((noinline)) test_i8_i16(v_16i8 v) +{ + return __builtin_convertvector(v, v_16i16); +} + +int main() +{ + { + v_16i8 x = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, -8}; + v_16i16 y = test_i8_i16(x); + printf("%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d\n", + y[0], y[1], y[2], y[3], y[4], y[5], y[6], y[7], + y[8], y[9], y[10], y[11], y[12], y[13], y[14], y[15]); + } + + { + v_8i8 x = {1, 2, 3, 4, 5, 6, 7, -4}; + v_8i32 y = test_i8_i32(x); + printf("%d %d %d %d %d %d %d %d\n", y[0], y[1], y[2], y[3], y[4], y[5], y[6], y[7]); + } + + { + v_8i16 x = {1, 2, 3, 4, 5, 6, 7, -4}; + v_8i32 y = test_i16_i32(x); + printf("%d %d %d %d %d %d %d %d\n", y[0], y[1], y[2], y[3], y[4], y[5], y[6], y[7]); + } + + { + v_4i8 x = {1, 2, 3, -2}; + v_4i64 y = test_i8_i64(x); + printf("%lld %lld %lld %lld\n", y[0], y[1], y[2], y[3]); + } + + { + v_4i16 x = {1, 2, 3, -2}; + v_4i64 y = test_i16_i64(x); + printf("%lld %lld %lld %lld\n", y[0], y[1], y[2], y[3]); + } + + { + v_4i32 x = {1, 2, 3, -2}; + v_4i64 y = test_i32_i64(x); + printf("%lld %lld %lld %lld\n", y[0], y[1], y[2], y[3]); + } + + return 0; +} +--EXPECT-- +1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 -8 +1 2 3 4 5 6 7 -4 +1 2 3 4 5 6 7 -4 +1 2 3 -2 +1 2 3 -2 +1 2 3 -2 diff --git a/tests/vector/convert-zext-002.test b/tests/vector/convert-zext-002.test new file mode 100644 index 0000000..0b5b139 --- /dev/null +++ b/tests/vector/convert-zext-002.test @@ -0,0 +1,109 @@ +--TEST-- +CONVERT.ZEXT.002: 256-bit vectors AVX +--TARGET-- +!aarch64 +--ARGS-- +-mavx --run +--CODE-- +int printf(const char *, ...); + +typedef long long i64; +typedef unsigned long long u64; +typedef int i32; +typedef unsigned int u32; +typedef short i16; +typedef unsigned short u16; +typedef char i8; +typedef unsigned char u8; + +typedef u64 __attribute__((__vector_size__(32))) v_4u64; +typedef u32 __attribute__((__vector_size__(16))) v_4u32; +typedef u16 __attribute__((__vector_size__(8))) v_4u16; +typedef u8 __attribute__((__vector_size__(4))) v_4u8; + +typedef u32 __attribute__((__vector_size__(32))) v_8u32; +typedef u16 __attribute__((__vector_size__(16))) v_8u16; +typedef u8 __attribute__((__vector_size__(8))) v_8u8; + +typedef u16 __attribute__((__vector_size__(32))) v_16u16; +typedef u8 __attribute__((__vector_size__(16))) v_16u8; + +v_4u64 __attribute__((noinline)) test_u32_u64(v_4u32 v) +{ + return __builtin_convertvector(v, v_4u64); +} + +v_4u64 __attribute__((noinline)) test_u16_u64(v_4u16 v) +{ + return __builtin_convertvector(v, v_4u64); +} + +v_4u64 __attribute__((noinline)) test_u8_u64(v_4u8 v) +{ + return __builtin_convertvector(v, v_4u64); +} + +v_8u32 __attribute__((noinline)) test_u16_u32(v_8u16 v) +{ + return __builtin_convertvector(v, v_8u32); +} + +v_8u32 __attribute__((noinline)) test_u8_u32(v_8u8 v) +{ + return __builtin_convertvector(v, v_8u32); +} + +v_16u16 __attribute__((noinline)) test_u8_u16(v_16u8 v) +{ + return __builtin_convertvector(v, v_16u16); +} + +int main() +{ + { + v_16u8 x = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, -8}; + v_16u16 y = test_u8_u16(x); + printf("%u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u\n", + y[0], y[1], y[2], y[3], y[4], y[5], y[6], y[7], + y[8], y[9], y[10], y[11], y[12], y[13], y[14], y[15]); + } + + { + v_8u8 x = {1, 2, 3, 4, 5, 6, 7, -4}; + v_8u32 y = test_u8_u32(x); + printf("%u %u %u %u %u %u %u %u\n", y[0], y[1], y[2], y[3], y[4], y[5], y[6], y[7]); + } + + { + v_8u16 x = {1, 2, 3, 4, 5, 6, 7, -4}; + v_8u32 y = test_u16_u32(x); + printf("%u %u %u %u %u %u %u %u\n", y[0], y[1], y[2], y[3], y[4], y[5], y[6], y[7]); + } + + { + v_4u8 x = {1, 2, 3, -2}; + v_4u64 y = test_u8_u64(x); + printf("%llu %llu %llu %llu\n", y[0], y[1], y[2], y[3]); + } + + { + v_4u16 x = {1, 2, 3, -2}; + v_4u64 y = test_u16_u64(x); + printf("%llu %llu %llu %llu\n", y[0], y[1], y[2], y[3]); + } + + { + v_4u32 x = {1, 2, 3, -2}; + v_4u64 y = test_u32_u64(x); + printf("%llu %llu %llu %llu\n", y[0], y[1], y[2], y[3]); + } + + return 0; +} +--EXPECT-- +1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 248 +1 2 3 4 5 6 7 252 +1 2 3 4 5 6 7 65532 +1 2 3 254 +1 2 3 65534 +1 2 3 4294967294 diff --git a/tests/vector/shuffle-001.test b/tests/vector/shuffle-001.test index f88775b..4343efa 100644 --- a/tests/vector/shuffle-001.test +++ b/tests/vector/shuffle-001.test @@ -102,7 +102,7 @@ int main() { v_u64 x = {1, 2}; x = test_v_u64(x, (v_i64){1, 0}); - printf("%lld %ld\n", x[0], x[1]); + printf("%lld %lld\n", x[0], x[1]); } { diff --git a/tests/vector/shuffle-002.test b/tests/vector/shuffle-002.test index 9541d75..7d617c2 100644 --- a/tests/vector/shuffle-002.test +++ b/tests/vector/shuffle-002.test @@ -102,7 +102,7 @@ int main() { v_u64 x = {1, 2}; x = test_v_u64(x); - printf("%lld %ld\n", x[0], x[1]); + printf("%lld %lld\n", x[0], x[1]); } {