Files
c3c/test/test_suite/expressions/chained_conditional.c3t
2023-04-28 19:11:57 +02:00

71 lines
1.2 KiB
Plaintext

// #target: macos-x64
module chained;
fn int foo()
{
return 1;
}
fn void test()
{
int x = foo();
int y = foo();
int z = foo();
if (x > 0 && y > 0 && z > 0)
{
foo();
}
else
{
x++;
}
}
/* #expect: chained.ll
entry:
%x = alloca i32, align 4
%y = alloca i32, align 4
%z = alloca i32, align 4
%0 = call i32 @chained.foo()
store i32 %0, ptr %x, align 4
%1 = call i32 @chained.foo()
store i32 %1, ptr %y, align 4
%2 = call i32 @chained.foo()
store i32 %2, ptr %z, align 4
%3 = load i32, ptr %x, align 4
%gt = icmp sgt i32 %3, 0
br i1 %gt, label %and.rhs, label %and.phi
and.rhs:
%4 = load i32, ptr %y, align 4
%gt1 = icmp sgt i32 %4, 0
br label %and.phi
and.phi:
%val = phi i1 [ false, %entry ], [ %gt1, %and.rhs ]
br i1 %val, label %and.rhs2, label %and.phi4
and.rhs2:
%5 = load i32, ptr %z, align 4
%gt3 = icmp sgt i32 %5, 0
br label %and.phi4
and.phi4:
%val5 = phi i1 [ false, %and.phi ], [ %gt3, %and.rhs2 ]
br i1 %val5, label %if.then, label %if.else
if.then:
%6 = call i32 @chained.foo()
br label %if.exit
if.else:
%7 = load i32, ptr %x, align 4
%add = add i32 %7, 1
store i32 %add, ptr %x, align 4
br label %if.exit
if.exit:
ret void
}