[Bug rtl-optimization/66248] subreg truncation not hoisted from loop

pinskia at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Dec 15 18:28:00 GMT 2015


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66248

--- Comment #8 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Couldn't it be optimized as:
short func(short *a, int y)
{
 short ret = 0;
 unsigned int tmp = 0;
 int i;
 for(i = 0; i < y; i++) 
   tmp += (unsigned int)(int)a[i];

 return (short)tmp;
}

Such that the addition happens in unsigned (so there is only wrapping and is
well defined) and only one truncatation happens at the end of the loop.


More information about the Gcc-bugs mailing list