2022-04-21 23:11:34 +02:00
|
|
|
--TEST--
|
|
|
|
DESSA 003
|
2022-05-25 16:38:22 +02:00
|
|
|
--TARGET--
|
|
|
|
x86_64
|
2022-04-21 23:11:34 +02:00
|
|
|
--ARGS--
|
|
|
|
-S
|
|
|
|
--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;
|
2022-06-15 16:27:31 +02:00
|
|
|
l_1 = START(l_11);
|
2022-04-21 23:11:34 +02:00
|
|
|
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);
|
2022-06-15 16:27:31 +02:00
|
|
|
l_11 = RETURN(l_10, z);
|
2022-04-21 23:11:34 +02:00
|
|
|
}
|
|
|
|
--EXPECT--
|
|
|
|
test:
|
2022-05-05 21:35:39 +02:00
|
|
|
movl %edx, %ecx
|
2022-04-21 23:11:34 +02:00
|
|
|
movl %edi, %eax
|
2022-05-05 21:35:39 +02:00
|
|
|
movl $0xc, %edi
|
2022-04-21 23:11:34 +02:00
|
|
|
cltd
|
2022-05-05 21:35:39 +02:00
|
|
|
idivl %edi
|
2022-04-21 23:11:34 +02:00
|
|
|
.L1:
|
2022-05-05 21:35:39 +02:00
|
|
|
testl %ecx, %ecx
|
2022-04-21 23:11:34 +02:00
|
|
|
je .L2
|
2022-05-12 23:32:37 +02:00
|
|
|
movl %eax, %edx
|
|
|
|
movl %esi, %eax
|
|
|
|
movl %edx, %esi
|
2022-04-21 23:11:34 +02:00
|
|
|
jmp .L1
|
|
|
|
.L2:
|
|
|
|
retq
|