By using Code Composer Studio v.5 I have noted some problems in the recognition of the nassert intrinsic for declaring data alignment.
In order to highlight the problem, I have selected to following (simple) code, given as example on the “Optimizing Compiler v7.6 User's Guide” (pag. 235):
int dot_product(short *x, short *y, short z)
{
int sum = 0, i;
_nassert (((int)(x) & 0x3) == 0);
_nassert (((int)(y) & 0x3) == 0);
#pragma MUST_ITERATE(32, , 2);
#pragma UNROLL(2);
for (i = 0; i < z; i++) sum += x[i] * y[i];
return sum;
}
According to the manual, this loop should be implemented with an iteration interval (ii) equal to 1 (with 2x Unrolling) thanks to _nassert intrinsics which allows the employ of LDW instructions to load the data of the two arrays. By using the latest version of the TI Compiler (v.7.4.11) the behavior is on the other hand the following:
- On C64x DSP and its extensions (C64x+, C674x, C66x) the code is optimally implemented with ii=1 and 2x unrolling
- On C67x and C67x+ DSP the above example is implemented with ii=2. Reason: 4 LDH instructions are used to load arrays data. In this case the compiler seems ignoring the _nassert declarations.
I have tested the above code also in Code Composer Studio v.3.3. In this case the old compiler version 6.0 (e.g. v.6.0.8) optimally compile the code, also on DSP C67x, by using ii=1 and LDW instructions. The newest compiler version 6.1 (e.g. v.6.1.23), on the other hand, similarly to v.7.4.11 uses LDH instructions and ii=2 on C67x DSP. In this last case, again, the problem is not present by compiling the code for C64x DSP.
In conclusion it seems that under C67x DSP the old compiler v.6.0 works much better than all new compiler versions from v.6.1 to v.7.4.11.
Is there something that I have not considered to justify the behavior of the novel compiler versions ?
Or do I have discovered a compiler bug iterated from v.6.1 up to v.7.4 ?