mirror of
https://github.com/danog/ir.git
synced 2024-12-02 17:55:40 +01:00
56 lines
1018 B
Plaintext
56 lines
1018 B
Plaintext
--TEST--
|
|
SWITCH 001
|
|
--ARGS--
|
|
--emit-llvm
|
|
--CODE--
|
|
{
|
|
uintptr_t c_1 = 0;
|
|
bool c_2 = 0;
|
|
bool c_3 = 1;
|
|
int32_t c_4 = 0;
|
|
int32_t c_5 = 1;
|
|
int32_t c_6 = 2;
|
|
int32_t c_7 = 3;
|
|
l_1 = START(l_16);
|
|
int32_t d_2 = PARAM(l_1, "z", 0);
|
|
l_4 = SWITCH(l_1, d_2);
|
|
l_5 = CASE_VAL(l_4, c_4);
|
|
int32_t x_1 = MUL(d_2, c_7);
|
|
l_6 = END(l_5);
|
|
l_7 = CASE_VAL(l_4, c_5);
|
|
int32_t x_2 = ADD(d_2, c_5);
|
|
l_8 = END(l_7);
|
|
l_9 = CASE_VAL(l_4, c_6);
|
|
int32_t x_3 = SUB(d_2, c_6);
|
|
l_10 = END(l_9);
|
|
l_11 = CASE_DEFAULT(l_4);
|
|
int32_t x_4 = SUB(d_2, c_6);
|
|
l_12 = END(l_11);
|
|
l_13 = MERGE/4(l_6, l_8, l_10, l_12);
|
|
int32_t ret = PHI/4(l_13, x_1, x_2, x_3, x_4);
|
|
l_16 = RETURN(l_13, ret);
|
|
}
|
|
--EXPECT--
|
|
define i32 @test(i32 %d2)
|
|
{
|
|
%d3 = sub i32 %d2, 2
|
|
switch i32 %d2, label %l6 [
|
|
i32 0, label %l2
|
|
i32 1, label %l4
|
|
i32 2, label %l5
|
|
]
|
|
l2:
|
|
%d6 = mul i32 %d2, 3
|
|
br label %l3
|
|
l3:
|
|
%d17 = phi i32 [%d6, %l2], [%d9, %l4], [%d3, %l5], [%d3, %l6]
|
|
ret i32 %d17
|
|
l4:
|
|
%d9 = add i32 %d2, 1
|
|
br label %l3
|
|
l5:
|
|
br label %l3
|
|
l6:
|
|
br label %l3
|
|
}
|