Explanation
Burst widening works best if the total number of accesses is divisible by 2. Consider adjusting the number of accesses to be always even.
For variable length of accesses, use __builtin_assume or assert statements to give hints to the widening algorithm.
Examples
- Constant number of
accesses:
//////////// ORIGINAL //////////// void foo(int *a) { int buff[9]; for (long i = 0; i < 10; ++i) buff[i] = a[i]; ... } //////////// UPDATED //////////// // Change number of accesses from 11 to 12 void foo(int *a) { int buff[10]; for (long i = 0; i < 11; ++i) buff[i] = a[i]; ... }
- Variable number of
accesses:
//////////// ORIGINAL //////////// void foo(int *a, int n) { for (long i = 0; i < n; ++i) ... = a[i]; } //////////// UPDATED //////////////////////////// // Use __builtin_assume/assert to guide widening. void foo(int *a, int n) { assert(n % 8 == 0); for (long i = 0; i < n; ++i) ... = a[i]; }