Missed loop unwind
bearophile
bearophileHUGS at lycos.com
Tue Mar 25 16:25:49 PDT 2014
If I compile this code with the latest ldc2 with -O -release
-inline -noboundscheck, the inner loop is unrolled (while gdc
unrolls it):
void main() {
import core.stdc.stdio;
enum uint n = 1 << 25;
static immutable uint[5] factors = [101, 103, 107, 109, 113];
uint c = 0;
for (uint i = 1; i < n; i++)
for (uint j = 0; j < 5; j++)
if (i % factors[j] == 0) {
c++;
break;
}
printf("%u\n", c);
}
A little cheap unrolling could be present in -O.
Bye,
bearophile
More information about the digitalmars-d-ldc
mailing list