Files
c3c/test/test_suite/statements/comparison_widening.c3t
Christoffer Lerno 44df6eb75b Cleanup.
2022-08-12 18:13:24 +02:00

34 lines
814 B
C

// #target: macos-x64
fn void test1()
{
char a = 1;
int b = 2;
char c = b > a ? 1u8 : 0u8;
int d = b ?: 1;
}
/* #expect: comparison_widening.ll
define void @comparison_widening_test1() #0 {
entry:
%a = alloca i8, align 1
%b = alloca i32, align 4
%c = alloca i8, align 1
%d = alloca i32, align 4
store i8 1, i8* %a, align 1
store i32 2, i32* %b, align 4
%0 = load i32, i32* %b, align 4
%1 = load i8, i8* %a, align 1
%zext = zext i8 %1 to i32
%gt = icmp sgt i32 %0, %zext
%check = icmp sge i32 %zext, 0
%siui-gt = and i1 %check, %gt
%ternary = select i1 %siui-gt, i8 1, i8 0
store i8 %ternary, i8* %c, align 1
%2 = load i32, i32* %b, align 4
%intbool = icmp ne i32 %2, 0
%elvis = select i1 %intbool, i32 %2, i32 1
store i32 %elvis, i32* %d, align 4
ret void
}