<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/67648>67648</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[loop-split] split loop to remove control-flow
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
vfdff
</td>
</tr>
</table>
<pre>
* test: https://gcc.godbolt.org/z/f5a6G5EYa
```
int foo1 (int);
int foo2 (int);
int test (int m, int n)
{
int sum = 0;
for (int i=0; i < n; ++i) {
if (i < m) // there is control-flow inside the loop
sum += foo1(i);
else
sum += foo2(i);
}
return sum;
}
```
* gcc: split loop into 2 loop bodies
```
csel w19, w1, w0, le
mov w20, 0
.L4: ; loop body1
mov w0, w21
add w21, w21, 1
bl foo1(int)
add w20, w20, w0
cmp w21, w19
blt .L4
cmp w22, w23
ble .L12
.L5: ; loop body2
mov w0, w19
add w19, w19, 1
bl foo2(int)
add w20, w20, w0
cmp w22, w19
bgt .L5
```
there is a topic on it, but no update for years, so add a issue to track this issue.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJycVM2SmzwQfJrhMmVKDD9GBw72-vN32RfIUYCwlQjkQsKuzdOnJLC9bJwcsrUlC01Pq3skjbBWnQYpK8j3kB8iMbmzGatr13ZdVJv2owLaoZPWQbrDs3MXC-kO6Ah0PDVNfDJtbbSLzXgCOv4EOna5KP7P__smgB2A7aBgy3_4VIPDzpgEgUo1OCAO6X4VohehJ8ArWQDYA72hnwweOwO3SwaGgJ16hPSA7MGE2JnxTqAgPfgQKoT0DQc_BdoD7RUQx09kiKoLWQHY-yjORUB3lqNEZbExgxuN3nTa3FANVrXSB1Ebc3ny4CyK9l6Xr4Rn_ezVQ6S28s8p9HsKbA_LdJRuGgef8azePfjlLJaRdnhqGn-89qKVC3p99QzSPK9Nq6R9SYHYWKnxlnB_FrckjMyP-mGgN1e8UVhcsuL3zG_ny33f4CNZwQP6Ro9F0bbhc1mlN3yEav0o43xpVikLEVuE3UX3lwddwp9MDr20FYhmgvQJkhi_J3R3knsnL_9W9uiFvWSt9V5D_sIe_YM9-mrv5O3lf7kKj6ss0JmLatAMqJynqSeHg8Hp0gonwxP6kGK0PmRN0CJQWTtJdAbdKJof6M7Kzmtx1FZpy1MuIlklBc9LTjzl0bliGXVpl-aM8mRbbCWVJWNSFkWb51mW80hVxChlnErGiRIe12Up6kQ0WZFuy6zZQsZkL5SOtb72vgtFYcuq2BZZGWlRS21DbyMa5G3WA0S-1Y2Vz9nU08lCxrSyzj5ZnHI6NEV_gpvwMCA_fH4hzuAoe3OV64cfTaOuvvRJ5c5THTemBzr6HZafzWU032XjgI5BlwU6Bt2_AgAA___RLIb2">