Files
c3c/test/test_suite/vector/vector_ops2.c3t
2023-02-20 17:48:47 +01:00

55 lines
1.6 KiB
C

// #target: macos-x64
// #safe: yes
module test;
import libc;
fn void testf()
{
float[<4>] y = { 1, 2, 3, 4 };
float[<4>] z = { 2, 2, 2, -100 };
float[<4>] w = y + z;
w = y / z;
}
fn void testi()
{
int[<4>] y = { 1, 2, 3, 4 };
int[<4>] z = { 2, 2, 2, -100 };
int[<4>] w = y / z;
w = z >> y;
w = z << y;
}
/* #expect: test.ll
; Function Attrs: nounwind
define void @test.testf() #0 {
entry:
%y = alloca <4 x float>, align 16
%z = alloca <4 x float>, align 16
%w = alloca <4 x float>, align 16
store <4 x float> <float 1.000000e+00, float 2.000000e+00, float 3.000000e+00, float 4.000000e+00>, ptr %y, align 16
store <4 x float> <float 2.000000e+00, float 2.000000e+00, float 2.000000e+00, float -1.000000e+02>, ptr %z, align 16
%0 = load <4 x float>, ptr %y, align 16
%1 = load <4 x float>, ptr %z, align 16
%fadd = fadd <4 x float> %0, %1
store <4 x float> %fadd, ptr %w, align 16
%2 = load <4 x float>, ptr %y, align 16
%3 = load <4 x float>, ptr %z, align 16
%4 = call <4 x float> @llvm.fabs.v4f32(<4 x float> %3)
%5 = call float @llvm.vector.reduce.fmin.v4f32(<4 x float> %4)
%zero = fcmp ueq float %5, 0.000000e+00
br i1 %zero, label %panic, label %checkok
panic: ; preds = %entry
%6 = load ptr, ptr @std.core.builtin.panic, align 8
call void %6(ptr @.panic_msg, i64 17, ptr @.file, i64 14, ptr @.func, i64 5, i32 9)
br label %checkok
checkok: ; preds = %panic, %entry
%fdiv = fdiv <4 x float> %2, %3
store <4 x float> %fdiv, ptr %w, align 16
ret void
}