Files
c3c/test/test_suite/builtins/int_to_mask.c3t
Christoffer Lerno f3b71ed7eb - $$MASK_TO_INT and $$INT_TO_MASK to create bool masks from integers and back.
- Fix bug when creating bool vectors in certain cases.
2025-12-25 20:55:11 +01:00

39 lines
1.0 KiB
Plaintext

// #target: macos-x64
module test;
fn void test()
{
bool[<8>] x = $$int_to_mask(0b1111000, 8);
bool[<32>] y = $$int_to_mask(0b1111000, 32);
}
fn void test2()
{
char x = $$mask_to_int((bool[<8>]){ false, false, false, false, true, true, true, false });
short x2 = $$mask_to_int((bool[<15>]){});
uint128 y = $$mask_to_int((bool[<128>]){});
}
/* #expect: test.ll
define void @test.test() #0 {
entry:
%x = alloca <8 x i8>, align 8
%y = alloca <32 x i8>, align 32
%0 = sext <8 x i1> bitcast (<1 x i8> splat (i8 120) to <8 x i1>) to <8 x i8>
store <8 x i8> %0, ptr %x, align 8
%1 = sext <32 x i1> bitcast (<1 x i32> splat (i32 120) to <32 x i1>) to <32 x i8>
store <32 x i8> %1, ptr %y, align 32
ret void
}
define void @test.test2() #0 {
entry:
%x = alloca i8, align 1
%x2 = alloca i16, align 2
%y = alloca i128, align 16
store i8 bitcast (<8 x i1> <i1 false, i1 false, i1 false, i1 false, i1 true, i1 true, i1 true, i1 false> to i8), ptr %x, align 1
store i16 0, ptr %x2, align 2
store i128 0, ptr %y, align 16
ret void
}