mirror of
https://github.com/danog/ir.git
synced 2024-11-27 04:45:38 +01:00
50 lines
971 B
Plaintext
50 lines
971 B
Plaintext
--TEST--
|
|
DESSA 003
|
|
--ARGS--
|
|
--emit-c
|
|
--CODE--
|
|
# Figure 8 (swap problem) from "Translating Out of Static Single Assignment Form" by Sreedhar
|
|
{
|
|
uintptr_t c_1 = 0;
|
|
bool c_2 = 0;
|
|
bool c_3 = 1;
|
|
int32_t c_4 = 1;
|
|
int32_t c_12 = 12;
|
|
l_1 = START(l_13);
|
|
int32_t x0 = PARAM(l_1, "x", 0);
|
|
int32_t y1 = PARAM(l_1, "y", 1);
|
|
int32_t cond = PARAM(l_1, "z", 2);
|
|
int32_t x1 = DIV(x0, c_12);
|
|
l_3 = END(l_1);
|
|
l_4 = LOOP_BEGIN(l_3, l_9);
|
|
int32_t x2 = PHI(l_4, x1, x3);
|
|
int32_t y2 = PHI(l_4, y1, y3);
|
|
int32_t z = COPY(x2);
|
|
int32_t x3 = COPY(y2);
|
|
int32_t y3 = COPY(z);
|
|
l_7 = IF(l_4, cond);
|
|
l_8 = IF_TRUE(l_7);
|
|
l_9 = LOOP_END(l_8, l_4);
|
|
l_10 = IF_FALSE(l_7);
|
|
l_11 = LOOP_EXIT(l_10, l_4);
|
|
l_12 = BEGIN(l_11);
|
|
l_13 = RETURN(l_12, z);
|
|
}
|
|
--EXPECT--
|
|
int32_t test(int32_t x, int32_t y, int32_t z)
|
|
{
|
|
int32_t d_1 = x;
|
|
int32_t d_2 = y;
|
|
int32_t d_3 = z;
|
|
int32_t d_4;
|
|
d_4 = d_1 / 12;
|
|
bb2:
|
|
if (!d_3) goto bb5;
|
|
tmp = d_4;
|
|
d_4 = d_2;
|
|
d_2 = tmp;
|
|
goto bb2;
|
|
bb5:
|
|
return d_4;
|
|
}
|