mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 03:51:18 +00:00
Issue when scalar expanding a boolean from a conditional to a bool vector #1954.
This commit is contained in:
@@ -67,6 +67,7 @@
|
||||
- Fix issue where compiling both for asm and object file would corrupt the obj file output.
|
||||
- Fix `poll` and `POLL_FOREVER`.
|
||||
- Missing end padding when including a packed struct #1966.
|
||||
- Issue when scalar expanding a boolean from a conditional to a bool vector #1954.
|
||||
|
||||
### Stdlib changes
|
||||
- Added '%h' and '%H' for printing out binary data in hexadecimal using the formatter.
|
||||
|
||||
@@ -6863,13 +6863,13 @@ void llvm_emit_enum_from_ord(GenContext *c, BEValue *value, Expr *expr)
|
||||
void llvm_emit_scalar_to_vector(GenContext *c, BEValue *value, Expr *expr)
|
||||
{
|
||||
llvm_emit_expr(c, value, expr->inner_expr);
|
||||
llvm_value_rvalue(c, value);
|
||||
LLVMValueRef val = llvm_load_value_store(c, value);
|
||||
LLVMTypeRef type = llvm_get_type(c, expr->type);
|
||||
unsigned elements = LLVMGetVectorSize(type);
|
||||
LLVMValueRef res = LLVMGetUndef(type);
|
||||
for (unsigned i = 0; i < elements; i++)
|
||||
{
|
||||
res = LLVMBuildInsertElement(c->builder, res, value->value, llvm_const_int(c, type_usz, i), "");
|
||||
res = LLVMBuildInsertElement(c->builder, res, val, llvm_const_int(c, type_usz, i), "");
|
||||
}
|
||||
llvm_value_set(value, res, expr->type);
|
||||
}
|
||||
|
||||
31
test/test_suite/vector/vector_from_i1.c3t
Normal file
31
test/test_suite/vector/vector_from_i1.c3t
Normal file
@@ -0,0 +1,31 @@
|
||||
// #target: macos-x64
|
||||
module test;
|
||||
import std;
|
||||
|
||||
// issue 1954
|
||||
macro splat($Type, x)
|
||||
{
|
||||
return $Type {x,x,x,x};
|
||||
}
|
||||
|
||||
fn void main()
|
||||
{
|
||||
int[<4>] v1 = splat(int[<4>], 2);
|
||||
int[<4>] v2 = splat(int[<4>], 1);
|
||||
bool[<4>] vb = (v1 == v2);
|
||||
}
|
||||
|
||||
/* #expect: test.ll
|
||||
|
||||
store <4 x i32> <i32 2, i32 2, i32 2, i32 2>, ptr %v1, align 16
|
||||
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, ptr %v2, align 16
|
||||
%0 = load <4 x i32>, ptr %v1, align 16
|
||||
%1 = load <4 x i32>, ptr %v2, align 16
|
||||
%eq = icmp eq <4 x i32> %0, %1
|
||||
%2 = call i1 @llvm.vector.reduce.and.v4i1(<4 x i1> %eq)
|
||||
%3 = zext i1 %2 to i8
|
||||
%4 = insertelement <4 x i8> undef, i8 %3, i64 0
|
||||
%5 = insertelement <4 x i8> %4, i8 %3, i64 1
|
||||
%6 = insertelement <4 x i8> %5, i8 %3, i64 2
|
||||
%7 = insertelement <4 x i8> %6, i8 %3, i64 3
|
||||
store <4 x i8> %7, ptr %vb, align 4
|
||||
Reference in New Issue
Block a user