[Bug rtl-optimization/85551] No strength reduction of modulo and integer vision
linux at carewolf dot com
gcc-bugzilla@gcc.gnu.org
Fri Apr 27 11:57:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85551
--- Comment #2 from Allan Jensen <linux at carewolf dot com> ---
Hmm.. I appear to have made unsafe assumptions in the mod_opt cases.
The first safe optimization version would then be:
void mod_opt(int *a, int count, int stride, unsigned width)
{
int pos_opt = 0;
for (int i = 0; i < count; ++i) {
if (pos_opt < 0 || pos_opt >= width)
pos_opt = pos_opt % width;
a[i] = pos_opt;
pos_opt += stride;
}
}
To be able to completely get rid of modulo, you need to know or check for the
size of stride compared to width.
More information about the Gcc-bugs
mailing list