mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
391 lines
14 KiB
C
391 lines
14 KiB
C
// #target: macos-x64
|
|
module test;
|
|
|
|
extern fn void get(double[2]*);
|
|
extern fn void get2(int[2]*);
|
|
extern fn void get3(bool[2]*);
|
|
|
|
fn void test()
|
|
{
|
|
double[2] a @noinit;
|
|
double[2] b @noinit;
|
|
get(&a);
|
|
get(&b);
|
|
bool x = a == b;
|
|
bool y = a != b;
|
|
|
|
int[2] a2 @noinit;
|
|
int[2] b2 @noinit;
|
|
get2(&a2);
|
|
get2(&b2);
|
|
bool x2 = a2 == b2;
|
|
bool y2 = a2 != b2;
|
|
|
|
bool[2] a3 @noinit;
|
|
bool[2] b3 @noinit;
|
|
get3(&a3);
|
|
get3(&b3);
|
|
|
|
bool x3 = a3 == b3;
|
|
bool y3 = a3 != b3;
|
|
|
|
}
|
|
|
|
extern fn void aget(double[200]*);
|
|
extern fn void aget2(int[200]*);
|
|
extern fn void aget3(bool[200]*);
|
|
|
|
fn void test2()
|
|
{
|
|
double[200] a @noinit;
|
|
double[200] b @noinit;
|
|
aget(&a);
|
|
aget(&b);
|
|
bool x = a == b;
|
|
bool y = a != b;
|
|
|
|
int[200] a2 @noinit;
|
|
int[200] b2 @noinit;
|
|
aget2(&a2);
|
|
aget2(&b2);
|
|
bool x2 = a2 == b2;
|
|
bool y2 = a2 != b2;
|
|
|
|
bool[200] a3 @noinit;
|
|
bool[200] b3 @noinit;
|
|
aget3(&a3);
|
|
aget3(&b3);
|
|
bool x3 = a3 == b3;
|
|
bool y3 = a3 != b3;
|
|
|
|
}
|
|
|
|
/* #expect: test.ll
|
|
|
|
define void @test.test() #0 {
|
|
entry:
|
|
%a = alloca [2 x double], align 16
|
|
%b = alloca [2 x double], align 16
|
|
%x = alloca i8, align 1
|
|
%y = alloca i8, align 1
|
|
%a2 = alloca [2 x i32], align 4
|
|
%b2 = alloca [2 x i32], align 4
|
|
%x2 = alloca i8, align 1
|
|
%y2 = alloca i8, align 1
|
|
%a3 = alloca [2 x i8], align 1
|
|
%b3 = alloca [2 x i8], align 1
|
|
%x3 = alloca i8, align 1
|
|
%y3 = alloca i8, align 1
|
|
call void @get(ptr %a)
|
|
call void @get(ptr %b)
|
|
%0 = getelementptr inbounds [2 x double], ptr %a, i64 0, i64 0
|
|
%1 = getelementptr inbounds [2 x double], ptr %b, i64 0, i64 0
|
|
%2 = load double, ptr %0, align 8
|
|
%3 = load double, ptr %1, align 8
|
|
%eq = fcmp oeq double %2, %3
|
|
br i1 %eq, label %next_check, label %exit
|
|
|
|
next_check: ; preds = %entry
|
|
%4 = getelementptr inbounds [2 x double], ptr %a, i64 0, i64 1
|
|
%5 = getelementptr inbounds [2 x double], ptr %b, i64 0, i64 1
|
|
%6 = load double, ptr %4, align 8
|
|
%7 = load double, ptr %5, align 8
|
|
%eq1 = fcmp oeq double %6, %7
|
|
br i1 %eq1, label %match, label %exit
|
|
|
|
match: ; preds = %next_check
|
|
br label %exit
|
|
|
|
exit: ; preds = %match, %next_check, %entry
|
|
%array_cmp_phi = phi i1 [ false, %entry ], [ false, %next_check ], [ true, %match ]
|
|
%8 = zext i1 %array_cmp_phi to i8
|
|
store i8 %8, ptr %x, align 1
|
|
%9 = getelementptr inbounds [2 x double], ptr %a, i64 0, i64 0
|
|
%10 = getelementptr inbounds [2 x double], ptr %b, i64 0, i64 0
|
|
%11 = load double, ptr %9, align 8
|
|
%12 = load double, ptr %10, align 8
|
|
%eq2 = fcmp oeq double %11, %12
|
|
br i1 %eq2, label %next_check3, label %exit6
|
|
|
|
next_check3: ; preds = %exit
|
|
%13 = getelementptr inbounds [2 x double], ptr %a, i64 0, i64 1
|
|
%14 = getelementptr inbounds [2 x double], ptr %b, i64 0, i64 1
|
|
%15 = load double, ptr %13, align 8
|
|
%16 = load double, ptr %14, align 8
|
|
%eq4 = fcmp oeq double %15, %16
|
|
br i1 %eq4, label %match5, label %exit6
|
|
|
|
match5: ; preds = %next_check3
|
|
br label %exit6
|
|
|
|
exit6: ; preds = %match5, %next_check3, %exit
|
|
%array_cmp_phi7 = phi i1 [ true, %exit ], [ true, %next_check3 ], [ false, %match5 ]
|
|
%17 = zext i1 %array_cmp_phi7 to i8
|
|
store i8 %17, ptr %y, align 1
|
|
call void @get2(ptr %a2)
|
|
call void @get2(ptr %b2)
|
|
%18 = getelementptr inbounds [2 x i32], ptr %a2, i64 0, i64 0
|
|
%19 = getelementptr inbounds [2 x i32], ptr %b2, i64 0, i64 0
|
|
%20 = load i32, ptr %18, align 4
|
|
%21 = load i32, ptr %19, align 4
|
|
%eq8 = icmp eq i32 %20, %21
|
|
br i1 %eq8, label %next_check9, label %exit12
|
|
|
|
next_check9: ; preds = %exit6
|
|
%22 = getelementptr inbounds [2 x i32], ptr %a2, i64 0, i64 1
|
|
%23 = getelementptr inbounds [2 x i32], ptr %b2, i64 0, i64 1
|
|
%24 = load i32, ptr %22, align 4
|
|
%25 = load i32, ptr %23, align 4
|
|
%eq10 = icmp eq i32 %24, %25
|
|
br i1 %eq10, label %match11, label %exit12
|
|
|
|
match11: ; preds = %next_check9
|
|
br label %exit12
|
|
|
|
exit12: ; preds = %match11, %next_check9, %exit6
|
|
%array_cmp_phi13 = phi i1 [ false, %exit6 ], [ false, %next_check9 ], [ true, %match11 ]
|
|
%26 = zext i1 %array_cmp_phi13 to i8
|
|
store i8 %26, ptr %x2, align 1
|
|
%27 = getelementptr inbounds [2 x i32], ptr %a2, i64 0, i64 0
|
|
%28 = getelementptr inbounds [2 x i32], ptr %b2, i64 0, i64 0
|
|
%29 = load i32, ptr %27, align 4
|
|
%30 = load i32, ptr %28, align 4
|
|
%eq14 = icmp eq i32 %29, %30
|
|
br i1 %eq14, label %next_check15, label %exit18
|
|
|
|
next_check15: ; preds = %exit12
|
|
%31 = getelementptr inbounds [2 x i32], ptr %a2, i64 0, i64 1
|
|
%32 = getelementptr inbounds [2 x i32], ptr %b2, i64 0, i64 1
|
|
%33 = load i32, ptr %31, align 4
|
|
%34 = load i32, ptr %32, align 4
|
|
%eq16 = icmp eq i32 %33, %34
|
|
br i1 %eq16, label %match17, label %exit18
|
|
|
|
match17: ; preds = %next_check15
|
|
br label %exit18
|
|
|
|
exit18: ; preds = %match17, %next_check15, %exit12
|
|
%array_cmp_phi19 = phi i1 [ true, %exit12 ], [ true, %next_check15 ], [ false, %match17 ]
|
|
%35 = zext i1 %array_cmp_phi19 to i8
|
|
store i8 %35, ptr %y2, align 1
|
|
call void @get3(ptr %a3)
|
|
call void @get3(ptr %b3)
|
|
%36 = getelementptr inbounds [2 x i8], ptr %a3, i64 0, i64 0
|
|
%37 = getelementptr inbounds [2 x i8], ptr %b3, i64 0, i64 0
|
|
%38 = load i8, ptr %36, align 1
|
|
%39 = trunc i8 %38 to i1
|
|
%40 = load i8, ptr %37, align 1
|
|
%41 = trunc i8 %40 to i1
|
|
%eq20 = icmp eq i1 %39, %41
|
|
br i1 %eq20, label %next_check21, label %exit24
|
|
|
|
next_check21: ; preds = %exit18
|
|
%42 = getelementptr inbounds [2 x i8], ptr %a3, i64 0, i64 1
|
|
%43 = getelementptr inbounds [2 x i8], ptr %b3, i64 0, i64 1
|
|
%44 = load i8, ptr %42, align 1
|
|
%45 = trunc i8 %44 to i1
|
|
%46 = load i8, ptr %43, align 1
|
|
%47 = trunc i8 %46 to i1
|
|
%eq22 = icmp eq i1 %45, %47
|
|
br i1 %eq22, label %match23, label %exit24
|
|
|
|
match23: ; preds = %next_check21
|
|
br label %exit24
|
|
|
|
exit24: ; preds = %match23, %next_check21, %exit18
|
|
%array_cmp_phi25 = phi i1 [ false, %exit18 ], [ false, %next_check21 ], [ true, %match23 ]
|
|
%48 = zext i1 %array_cmp_phi25 to i8
|
|
store i8 %48, ptr %x3, align 1
|
|
%49 = getelementptr inbounds [2 x i8], ptr %a3, i64 0, i64 0
|
|
%50 = getelementptr inbounds [2 x i8], ptr %b3, i64 0, i64 0
|
|
%51 = load i8, ptr %49, align 1
|
|
%52 = trunc i8 %51 to i1
|
|
%53 = load i8, ptr %50, align 1
|
|
%54 = trunc i8 %53 to i1
|
|
%eq26 = icmp eq i1 %52, %54
|
|
br i1 %eq26, label %next_check27, label %exit30
|
|
|
|
next_check27: ; preds = %exit24
|
|
%55 = getelementptr inbounds [2 x i8], ptr %a3, i64 0, i64 1
|
|
%56 = getelementptr inbounds [2 x i8], ptr %b3, i64 0, i64 1
|
|
%57 = load i8, ptr %55, align 1
|
|
%58 = trunc i8 %57 to i1
|
|
%59 = load i8, ptr %56, align 1
|
|
%60 = trunc i8 %59 to i1
|
|
%eq28 = icmp eq i1 %58, %60
|
|
br i1 %eq28, label %match29, label %exit30
|
|
|
|
match29: ; preds = %next_check27
|
|
br label %exit30
|
|
|
|
exit30: ; preds = %match29, %next_check27, %exit24
|
|
%array_cmp_phi31 = phi i1 [ true, %exit24 ], [ true, %next_check27 ], [ false, %match29 ]
|
|
%61 = zext i1 %array_cmp_phi31 to i8
|
|
store i8 %61, ptr %y3, align 1
|
|
ret void
|
|
}
|
|
define void @test.test2() #0 {
|
|
entry:
|
|
%a = alloca [200 x double], align 16
|
|
%b = alloca [200 x double], align 16
|
|
%x = alloca i8, align 1
|
|
%cmp.idx = alloca i64, align 8
|
|
%y = alloca i8, align 1
|
|
%cmp.idx1 = alloca i64, align 8
|
|
%a2 = alloca [200 x i32], align 16
|
|
%b2 = alloca [200 x i32], align 16
|
|
%x2 = alloca i8, align 1
|
|
%cmp.idx9 = alloca i64, align 8
|
|
%y2 = alloca i8, align 1
|
|
%cmp.idx17 = alloca i64, align 8
|
|
%a3 = alloca [200 x i8], align 16
|
|
%b3 = alloca [200 x i8], align 16
|
|
%x3 = alloca i8, align 1
|
|
%cmp.idx25 = alloca i64, align 8
|
|
%y3 = alloca i8, align 1
|
|
%cmp.idx33 = alloca i64, align 8
|
|
call void @aget(ptr %a)
|
|
call void @aget(ptr %b)
|
|
store i64 0, ptr %cmp.idx, align 8
|
|
br label %array_loop_start
|
|
|
|
array_loop_start: ; preds = %array_loop_comparison, %entry
|
|
%0 = load i64, ptr %cmp.idx, align 8
|
|
%1 = getelementptr inbounds [200 x double], ptr %a, i64 0, i64 %0
|
|
%2 = getelementptr inbounds [200 x double], ptr %b, i64 0, i64 %0
|
|
%3 = load double, ptr %1, align 8
|
|
%4 = load double, ptr %2, align 8
|
|
%eq = fcmp oeq double %3, %4
|
|
br i1 %eq, label %array_loop_comparison, label %array_cmp_exit
|
|
|
|
array_loop_comparison: ; preds = %array_loop_start
|
|
%inc = add i64 %0, 1
|
|
store i64 %inc, ptr %cmp.idx, align 8
|
|
%lt = icmp ult i64 %inc, 200
|
|
br i1 %lt, label %array_loop_start, label %array_cmp_exit
|
|
|
|
array_cmp_exit: ; preds = %array_loop_comparison, %array_loop_start
|
|
%array_cmp_phi = phi i1 [ true, %array_loop_comparison ], [ false, %array_loop_start ]
|
|
%5 = zext i1 %array_cmp_phi to i8
|
|
store i8 %5, ptr %x, align 1
|
|
store i64 0, ptr %cmp.idx1, align 8
|
|
br label %array_loop_start2
|
|
|
|
array_loop_start2: ; preds = %array_loop_comparison4, %array_cmp_exit
|
|
%6 = load i64, ptr %cmp.idx1, align 8
|
|
%7 = getelementptr inbounds [200 x double], ptr %a, i64 0, i64 %6
|
|
%8 = getelementptr inbounds [200 x double], ptr %b, i64 0, i64 %6
|
|
%9 = load double, ptr %7, align 8
|
|
%10 = load double, ptr %8, align 8
|
|
%eq3 = fcmp oeq double %9, %10
|
|
br i1 %eq3, label %array_loop_comparison4, label %array_cmp_exit7
|
|
|
|
array_loop_comparison4: ; preds = %array_loop_start2
|
|
%inc5 = add i64 %6, 1
|
|
store i64 %inc5, ptr %cmp.idx1, align 8
|
|
%lt6 = icmp ult i64 %inc5, 200
|
|
br i1 %lt6, label %array_loop_start2, label %array_cmp_exit7
|
|
|
|
array_cmp_exit7: ; preds = %array_loop_comparison4, %array_loop_start2
|
|
%array_cmp_phi8 = phi i1 [ false, %array_loop_comparison4 ], [ true, %array_loop_start2 ]
|
|
%11 = zext i1 %array_cmp_phi8 to i8
|
|
store i8 %11, ptr %y, align 1
|
|
call void @aget2(ptr %a2)
|
|
call void @aget2(ptr %b2)
|
|
store i64 0, ptr %cmp.idx9, align 8
|
|
br label %array_loop_start10
|
|
|
|
array_loop_start10: ; preds = %array_loop_comparison12, %array_cmp_exit7
|
|
%12 = load i64, ptr %cmp.idx9, align 8
|
|
%13 = getelementptr inbounds [200 x i32], ptr %a2, i64 0, i64 %12
|
|
%14 = getelementptr inbounds [200 x i32], ptr %b2, i64 0, i64 %12
|
|
%15 = load i32, ptr %13, align 4
|
|
%16 = load i32, ptr %14, align 4
|
|
%eq11 = icmp eq i32 %15, %16
|
|
br i1 %eq11, label %array_loop_comparison12, label %array_cmp_exit15
|
|
|
|
array_loop_comparison12: ; preds = %array_loop_start10
|
|
%inc13 = add i64 %12, 1
|
|
store i64 %inc13, ptr %cmp.idx9, align 8
|
|
%lt14 = icmp ult i64 %inc13, 200
|
|
br i1 %lt14, label %array_loop_start10, label %array_cmp_exit15
|
|
|
|
array_cmp_exit15: ; preds = %array_loop_comparison12, %array_loop_start10
|
|
%array_cmp_phi16 = phi i1 [ true, %array_loop_comparison12 ], [ false, %array_loop_start10 ]
|
|
%17 = zext i1 %array_cmp_phi16 to i8
|
|
store i8 %17, ptr %x2, align 1
|
|
store i64 0, ptr %cmp.idx17, align 8
|
|
br label %array_loop_start18
|
|
|
|
array_loop_start18: ; preds = %array_loop_comparison20, %array_cmp_exit15
|
|
%18 = load i64, ptr %cmp.idx17, align 8
|
|
%19 = getelementptr inbounds [200 x i32], ptr %a2, i64 0, i64 %18
|
|
%20 = getelementptr inbounds [200 x i32], ptr %b2, i64 0, i64 %18
|
|
%21 = load i32, ptr %19, align 4
|
|
%22 = load i32, ptr %20, align 4
|
|
%eq19 = icmp eq i32 %21, %22
|
|
br i1 %eq19, label %array_loop_comparison20, label %array_cmp_exit23
|
|
|
|
array_loop_comparison20: ; preds = %array_loop_start18
|
|
%inc21 = add i64 %18, 1
|
|
store i64 %inc21, ptr %cmp.idx17, align 8
|
|
%lt22 = icmp ult i64 %inc21, 200
|
|
br i1 %lt22, label %array_loop_start18, label %array_cmp_exit23
|
|
|
|
array_cmp_exit23: ; preds = %array_loop_comparison20, %array_loop_start18
|
|
%array_cmp_phi24 = phi i1 [ false, %array_loop_comparison20 ], [ true, %array_loop_start18 ]
|
|
%23 = zext i1 %array_cmp_phi24 to i8
|
|
store i8 %23, ptr %y2, align 1
|
|
call void @aget3(ptr %a3)
|
|
call void @aget3(ptr %b3)
|
|
store i64 0, ptr %cmp.idx25, align 8
|
|
br label %array_loop_start26
|
|
|
|
array_loop_start26: ; preds = %array_loop_comparison28, %array_cmp_exit23
|
|
%24 = load i64, ptr %cmp.idx25, align 8
|
|
%25 = getelementptr inbounds [200 x i8], ptr %a3, i64 0, i64 %24
|
|
%26 = getelementptr inbounds [200 x i8], ptr %b3, i64 0, i64 %24
|
|
%27 = load i8, ptr %25, align 1
|
|
%28 = trunc i8 %27 to i1
|
|
%29 = load i8, ptr %26, align 1
|
|
%30 = trunc i8 %29 to i1
|
|
%eq27 = icmp eq i1 %28, %30
|
|
br i1 %eq27, label %array_loop_comparison28, label %array_cmp_exit31
|
|
|
|
array_loop_comparison28: ; preds = %array_loop_start26
|
|
%inc29 = add i64 %24, 1
|
|
store i64 %inc29, ptr %cmp.idx25, align 8
|
|
%lt30 = icmp ult i64 %inc29, 200
|
|
br i1 %lt30, label %array_loop_start26, label %array_cmp_exit31
|
|
|
|
array_cmp_exit31: ; preds = %array_loop_comparison28, %array_loop_start26
|
|
%array_cmp_phi32 = phi i1 [ true, %array_loop_comparison28 ], [ false, %array_loop_start26 ]
|
|
%31 = zext i1 %array_cmp_phi32 to i8
|
|
store i8 %31, ptr %x3, align 1
|
|
store i64 0, ptr %cmp.idx33, align 8
|
|
br label %array_loop_start34
|
|
|
|
array_loop_start34: ; preds = %array_loop_comparison36, %array_cmp_exit31
|
|
%32 = load i64, ptr %cmp.idx33, align 8
|
|
%33 = getelementptr inbounds [200 x i8], ptr %a3, i64 0, i64 %32
|
|
%34 = getelementptr inbounds [200 x i8], ptr %b3, i64 0, i64 %32
|
|
%35 = load i8, ptr %33, align 1
|
|
%36 = trunc i8 %35 to i1
|
|
%37 = load i8, ptr %34, align 1
|
|
%38 = trunc i8 %37 to i1
|
|
%eq35 = icmp eq i1 %36, %38
|
|
br i1 %eq35, label %array_loop_comparison36, label %array_cmp_exit39
|
|
|
|
array_loop_comparison36: ; preds = %array_loop_start34
|
|
%inc37 = add i64 %32, 1
|
|
store i64 %inc37, ptr %cmp.idx33, align 8
|
|
%lt38 = icmp ult i64 %inc37, 200
|
|
br i1 %lt38, label %array_loop_start34, label %array_cmp_exit39
|
|
|
|
array_cmp_exit39: ; preds = %array_loop_comparison36, %array_loop_start34
|
|
%array_cmp_phi40 = phi i1 [ false, %array_loop_comparison36 ], [ true, %array_loop_start34 ]
|
|
%39 = zext i1 %array_cmp_phi40 to i8
|
|
store i8 %39, ptr %y3, align 1
|
|
ret void
|
|
}
|