mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 03:51:18 +00:00
* Optimize vector load / store. Fixes to alignment. Support typedef with `@simd` and `@align` #2543. Update vector ABI #2542 * Fix alignment issue with indirect arguments.
37 lines
961 B
Plaintext
37 lines
961 B
Plaintext
// #target: macos-x64
|
|
module test;
|
|
typedef Float2 = float[<2>] @simd;
|
|
union Rect
|
|
{
|
|
struct { Float2 min, max; }
|
|
}
|
|
|
|
fn Rect test_rect(Float2 max)
|
|
{
|
|
Rect rect = { .max = max };
|
|
assert(rect.min == {});
|
|
return rect;
|
|
}
|
|
|
|
/* #expect: test.ll
|
|
|
|
%Rect = type { %.anon }
|
|
%.anon = type { <2 x float>, <2 x float> }
|
|
|
|
define { double, double } @test.test_rect(double %0) #0 {
|
|
entry:
|
|
%max = alloca <2 x float>, align 8
|
|
%rect = alloca %Rect, align 8
|
|
store double %0, ptr %max, align 8
|
|
call void @llvm.memset.p0.i64(ptr align 8 %rect, i8 0, i64 16, i1 false)
|
|
%ptradd = getelementptr inbounds i8, ptr %rect, i64 8
|
|
%1 = load <2 x float>, ptr %max, align 8
|
|
store <2 x float> %1, ptr %ptradd, align 8
|
|
%2 = load <2 x float>, ptr %rect, align 8
|
|
%eq = fcmp oeq <2 x float> %2, zeroinitializer
|
|
%3 = call i1 @llvm.vector.reduce.and.v2i1(<2 x i1> %eq)
|
|
call void @llvm.assume(i1 %3)
|
|
%4 = load { double, double }, ptr %rect, align 8
|
|
ret { double, double } %4
|
|
}
|