[cfe-dev] Missed opportunity to unroll loop (apparently)
Eli Friedman
eli.friedman at gmail.com
Wed Jan 18 17:53:32 PST 2012
On Wed, Jan 18, 2012 at 5:31 PM, Luc Bourhis <luc_j_bourhis at mac.com> wrote:
> Hi,
>
> consider
>
> static unsigned long const b = 4;
>
> void rank_1_update(unsigned long n, double *a,
> double const *x, double const *y) {
> unsigned long p = n/b, q=n%b;
> for (unsigned long ii=0; ii<p; ii++) for (unsigned long jj=0; jj<p; jj++) {
> for (unsigned long i=0; i<b; i++) for (unsigned long j=0; j<b; j++) {
> *a++ += x[ii*b+i]*y[jj*b+j];
> }
> }
> }
>
> I would expect the inner loops on i and j to be unrolled but with
>
> clang -S -emit-llvm -O3
>
> but they aren't. This is with
>
> clang version 3.0 (http://llvm.org/git/clang.git 67e5928a0bca44eb2281fd2a7aa21bf3f75d5a56)
> Target: x86_64-apple-darwin11.2.0
> Thread model: posix
>
> What am I missing here?
No idea; it appears to be unrolled as expected with a trunk version of clang.
-Eli
-Eli
More information about the cfe-dev
mailing list