mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
31 lines
1.3 KiB
Plaintext
31 lines
1.3 KiB
Plaintext
// #target: macos-x64
|
|
module foo;
|
|
|
|
fn void main()
|
|
{
|
|
int[5] a = { 1, 2, 3, 4, 5 };
|
|
void*[<2>] x = { &a[0], &a[4] };
|
|
int*[<2>] y = x;
|
|
int[<2>] result = mem::@gather_aligned(y, (bool[<2>]) { true, false }, (int[<2>]){ 10, 20 }, 4);
|
|
assert(result == { 1, 20});
|
|
result = mem::gather(y, (bool[<2>]) { true, false }, (int[<2>]){ 10, 20 });
|
|
assert(result == { 1, 20});
|
|
mem::@scatter_aligned(y, (int[<2>]){ 66, 77 }, (bool[<2>]) { false, true } , 4);
|
|
assert(a == (int[5]){ 1, 2, 3, 4, 77});
|
|
mem::scatter(y, (int[<2>]){ 88, 99 }, (bool[<2>]) { true, false });
|
|
assert(a == (int[5]){ 88, 2, 3, 4, 77});
|
|
}
|
|
|
|
/* #expect: foo.ll
|
|
|
|
%4 = load <2 x ptr>, ptr %ptrvec, align 16
|
|
%5 = call <2 x i32> @llvm.masked.gather.v2i32.v2p0(<2 x ptr> %4, i32 4, <2 x i1> <i1 true, i1 false>, <2 x i32> <i32 10, i32 20>)
|
|
|
|
%9 = load <2 x ptr>, ptr %ptrvec1, align 16
|
|
%10 = call <2 x i32> @llvm.masked.gather.v2i32.v2p0(<2 x ptr> %9, i32 4, <2 x i1> <i1 true, i1 false>, <2 x i32> <i32 10, i32 20>)
|
|
|
|
%14 = load <2 x ptr>, ptr %ptrvec3, align 16
|
|
call void @llvm.masked.scatter.v2i32.v2p0(<2 x i32> <i32 66, i32 77>, <2 x ptr> %14, i32 4, <2 x i1> <i1 false, i1 true>)
|
|
%16 = load <2 x ptr>, ptr %ptrvec5, align 16
|
|
call void @llvm.masked.scatter.v2i32.v2p0(<2 x i32> <i32 88, i32 99>, <2 x ptr> %16, i32 4, <2 x i1> <i1 true, i1 false>)
|