Files
c3c/test/test_suite/errors/else_checks.c3t

118 lines
4.0 KiB
C

// #target: macos-x64
extern fn int! testError();
fn void test()
{
double x = (testError() + testError()) ?? 100;
double y = (1 << testError()) ?? 100;
double z = testError() >> 1 ?? 100;
double w = testError() * testError() ?? 100;
}
/* #expect: else_checks.ll
; Function Attrs: nounwind
declare i64 @testError(ptr) #0
; Function Attrs: nounwind
define void @else_checks.test() #0 {
entry:
%x = alloca double, align 8
%retparam = alloca i32, align 4
%retparam1 = alloca i32, align 4
%y = alloca double, align 8
%retparam4 = alloca i32, align 4
%z = alloca double, align 8
%retparam11 = alloca i32, align 4
%w = alloca double, align 8
%retparam18 = alloca i32, align 4
%retparam21 = alloca i32, align 4
%0 = call i64 @testError(ptr %retparam)
%not_err = icmp eq i64 %0, 0
%1 = call i1 @llvm.expect.i1(i1 %not_err, i1 true)
br i1 %1, label %after_check, label %else_block
after_check: ; preds = %entry
%2 = load i32, ptr %retparam, align 4
%3 = call i64 @testError(ptr %retparam1)
%not_err2 = icmp eq i64 %3, 0
%4 = call i1 @llvm.expect.i1(i1 %not_err2, i1 true)
br i1 %4, label %after_check3, label %else_block
after_check3: ; preds = %after_check
%5 = load i32, ptr %retparam1, align 4
%add = add i32 %2, %5
br label %phi_block
else_block: ; preds = %after_check, %entry
br label %phi_block
phi_block: ; preds = %else_block, %after_check3
%val = phi i32 [ %add, %after_check3 ], [ 100, %else_block ]
%sifp = sitofp i32 %val to double
store double %sifp, ptr %x, align 8
%6 = call i64 @testError(ptr %retparam4)
%not_err5 = icmp eq i64 %6, 0
%7 = call i1 @llvm.expect.i1(i1 %not_err5, i1 true)
br i1 %7, label %after_check6, label %else_block7
after_check6: ; preds = %phi_block
%8 = load i32, ptr %retparam4, align 4
%shl = shl i32 1, %8
%9 = freeze i32 %shl
br label %phi_block8
else_block7: ; preds = %phi_block
br label %phi_block8
phi_block8: ; preds = %else_block7, %after_check6
%val9 = phi i32 [ %9, %after_check6 ], [ 100, %else_block7 ]
%sifp10 = sitofp i32 %val9 to double
store double %sifp10, ptr %y, align 8
%10 = call i64 @testError(ptr %retparam11)
%not_err12 = icmp eq i64 %10, 0
%11 = call i1 @llvm.expect.i1(i1 %not_err12, i1 true)
br i1 %11, label %after_check13, label %else_block14
after_check13: ; preds = %phi_block8
%12 = load i32, ptr %retparam11, align 4
%ashr = ashr i32 %12, 1
%13 = freeze i32 %ashr
br label %phi_block15
else_block14: ; preds = %phi_block8
br label %phi_block15
phi_block15: ; preds = %else_block14, %after_check13
%val16 = phi i32 [ %13, %after_check13 ], [ 100, %else_block14 ]
%sifp17 = sitofp i32 %val16 to double
store double %sifp17, ptr %z, align 8
%14 = call i64 @testError(ptr %retparam18)
%not_err19 = icmp eq i64 %14, 0
%15 = call i1 @llvm.expect.i1(i1 %not_err19, i1 true)
br i1 %15, label %after_check20, label %else_block24
after_check20: ; preds = %phi_block15
%16 = load i32, ptr %retparam18, align 4
%17 = call i64 @testError(ptr %retparam21)
%not_err22 = icmp eq i64 %17, 0
%18 = call i1 @llvm.expect.i1(i1 %not_err22, i1 true)
br i1 %18, label %after_check23, label %else_block24
after_check23: ; preds = %after_check20
%19 = load i32, ptr %retparam21, align 4
%mul = mul i32 %16, %19
br label %phi_block25
else_block24: ; preds = %after_check20, %phi_block15
br label %phi_block25
phi_block25: ; preds = %else_block24, %after_check23
%val26 = phi i32 [ %mul, %after_check23 ], [ 100, %else_block24 ]
%sifp27 = sitofp i32 %val26 to double
store double %sifp27, ptr %w, align 8
ret void
}