mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Fix vector float -> bool conversion.
This commit is contained in:
@@ -53,6 +53,7 @@
|
||||
- $vasplat was allowed inside of a function when passed as an argument to a function.
|
||||
- Prohibit raw vaargs in regular functions with a function body.
|
||||
- Assert on certain slice to slice casts. #1768.
|
||||
- Fix vector float -> bool conversion.
|
||||
|
||||
### Stdlib changes
|
||||
- Increase BitWriter.write_bits limit up to 32 bits.
|
||||
|
||||
@@ -551,7 +551,6 @@ typedef enum
|
||||
CAST_ERPTR,
|
||||
CAST_ERROR,
|
||||
CAST_EUER,
|
||||
CAST_FPBOOL,
|
||||
CAST_FPFP,
|
||||
CAST_FPINT,
|
||||
CAST_INTBOOL,
|
||||
|
||||
@@ -360,7 +360,6 @@ static inline bool expr_cast_is_runtime_const(Expr *expr)
|
||||
case CAST_PTRBOOL:
|
||||
case CAST_BOOLFP:
|
||||
case CAST_BOOLBOOL:
|
||||
case CAST_FPBOOL:
|
||||
case CAST_INTBOOL:
|
||||
case CAST_FPFP:
|
||||
case CAST_FPINT:
|
||||
|
||||
@@ -1471,11 +1471,6 @@ void llvm_emit_cast(GenContext *c, CastKind cast_kind, Expr *expr, BEValue *valu
|
||||
value->value = LLVMBuildIsNotNull(c->builder, value->value, "ptrbool");
|
||||
value->kind = BE_BOOLEAN;
|
||||
break;
|
||||
case CAST_FPBOOL:
|
||||
llvm_value_rvalue(c, value);
|
||||
value->value = LLVMBuildFCmp(c->builder, LLVMRealUNE, value->value, llvm_get_zero(c, from_type), "fpbool");
|
||||
value->kind = BE_BOOLEAN;
|
||||
break;
|
||||
case CAST_BOOLBOOL:
|
||||
value->value = LLVMBuildTrunc(c->builder, value->value, c->bool_type, "boolbool");
|
||||
value->kind = BE_BOOLEAN;
|
||||
|
||||
@@ -1717,8 +1717,14 @@ static void cast_vec_to_vec(SemaContext *context, Expr *expr, Type *to_type)
|
||||
insert_runtime_cast(expr, CAST_FPFP, to_type);
|
||||
return;
|
||||
case TYPE_BOOL:
|
||||
insert_runtime_cast(expr, CAST_FPBOOL, to_type);
|
||||
{
|
||||
Expr *left = expr_copy(expr);
|
||||
Expr *right = expr_new_expr(EXPR_CONST, expr);
|
||||
expr_rewrite_to_const_zero(right, left->type);
|
||||
expr_rewrite_to_binary(expr, left, right, BINARYOP_VEC_NE);
|
||||
expr->type = to_type;
|
||||
return;
|
||||
}
|
||||
case ALL_INTS:
|
||||
insert_runtime_cast(expr, CAST_FPINT, to_type);
|
||||
return;
|
||||
|
||||
@@ -37,6 +37,8 @@ fn void! test_conv() @test
|
||||
|
||||
fn void! testf() @test
|
||||
{
|
||||
float[<4>] x = { 4, 0, -1, 33 };
|
||||
assert({ true, false, true, true} == (bool[<4>])x);
|
||||
float[<4>] y = { 1, 2, 3, 4 };
|
||||
float[<4>] z = { 2, 2, 2, -100 };
|
||||
float[<4>] w = y + z;
|
||||
|
||||
Reference in New Issue
Block a user