Fix -Waggressive-loop-optimizations
Reference issue
What does this implement/fix?
x86-64 gcc version 10+ emits a Waggressive-loop-optimizations warning for certain matrix-vector products. The warning appears when the dimensions of the matrix is a fixed size multiple of the packet type (?). -mavx2 silences these warnings for Matrix<float,32,32>, but not 64.
Regardless of the reason, the warnings are probably false positives, as the code block in question is never executed. Explicitly defining the loop bounds fixes the issue. All additional integer arithmetic involves compile time powers of 2 so calculating the bounds is fairly trivial.
Minimum reproducer:
int main()
{
Matrix<float,32,32> A;
Matrix<float,1,32> b, c;
c.noalias() = b * A;
}
https://godbolt.org/z/bsjYcE8bT
Additional information
Edited by Charles Schlosser