<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/62294>62294</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
powerpc64le tail recursion miscompilation
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
q66
</td>
</tr>
</table>
<pre>
the following code enters infinite loop:
```
#include <stdio.h>
/*
0 100 1
100 0 0
0 100 1
100 0 0
0 100 1
100 0 0
0 100 1
100 0 0
0 100 1
100 0 0
0 100 1
...
*/
static unsigned int testfunc(unsigned int a, unsigned int b) {
printf("%u %u %d\n", a, b, b > a);
if (b > a) {
return testfunc(b, a);
}
return a - b;
}
int main(void) {
printf("%u\n", testfunc(0, 100));
return 0;
}
```
Confirmed on `ppc64le` with Clang 12 and 15 by me and git by @MaskRay. Confirmed it does not happen on at least `x86_64`, `aarch64` and `riscv64`. Appears to be unrelated to anything other than the architecture, so it seems to be a codegen backend bug.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzElMGSsygQx58GL11jIaiJBw8zyeS2l32BLcRW2UFwoZ1s3n4Lk8wkU1v1Hb9UquXfDX9-iKBiNKNDbFn1xqpjplaafGj_qeus8_2lpQlh8Nb6s3EjaN8joCMMEYwbjDOEYL1fmHxl_Mj4Pdb89r9KIY3Tdu0RmDxE6o3PJybfn4aIExO3NoeCcyiuIjU58N9YyfP8zrhhPlBHUmQ0rG57iz0YR0AYaVidZmL_lFdMHJ57dkw0wHZvVy8AgCUYRwMTeyYEE9UK99Cz6uC25OFq1G0BmHxPumHywcUMwMT-u_g8R_oFpDW4R9Tu5vzsxHbHm7iNUPAC3VeXr_I1pjXNyjgm9p_e9L9c3cOaHkh40gXnieUHzg2C_w_Ajy9uiwfvBhNm7ME7YDVfFl2XFlnN4WxogoNVboRCgHI9FBV0F5hxE6OhpFjJ_1Dx4091yeHbzBD0HiM4TzCpZUGX_BWBRRUpTfTvvv6rLhONOCStVNDTltjcWc2Difpzy-TwuiyoQgTy0CGsLqBVhH3Syl1oSifP04QBaFIO0pFMfoZQ0xowzRF9ooqI891GbYd1RAed0h_oeujWMc_6VvaNbFSGbVHvRSGrgstsaneF2teDbOpSV4VGXmguZF3oWoodoi4z0wouJC-F4LKsuMwR1aBK3Imm0x1vSlZynJWxubWfc-7DmJkYV2xrIZoys6pDG7dbRgiHZ9iKafOrYxbaNOalW8fISm5NpPjtQoYstos_Y7huH5AyFgLqNUTjHcwmaj8vxioy3mVrsO1EtMR0J6VL5TQamtYu135m4pR8b4-XJfi_URMTp40mMnHaaP8LAAD__8J5b4c">