This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug regression/43892] PowerPC suboptimal "add with carry" optimization
- From: "joakim dot tjernlund at transmode dot se" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 20 May 2010 12:13:40 -0000
- Subject: [Bug regression/43892] PowerPC suboptimal "add with carry" optimization
- References: <bug-43892-19087@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #7 from joakim dot tjernlund at transmode dot se 2010-05-20 12:13 -------
The below code doesn't generate any "add with carry" insn's for
either x86 nor powerpc:
u16
ipsum(u16 *buf, unsigned len, u16 sum)
{
int rest, carry ;
u32 acc_sum, *buf_u32, x;
acc_sum = sum;
len >>= 2;
buf_u32 = (u32 *) buf;
carry = 0;
for(buf_u32--; len; --len) {
x = *++buf_u32;
acc_sum += x;
acc_sum += carry;
carry = x > acc_sum ? 1 : 0;
}
acc_sum += carry;
/* Add back carry outs from top 16 bits to low 16 bits.
*/
acc_sum = (acc_sum >> 16) + (acc_sum & 0xffff); /* add high-16 to low-16
*/
acc_sum += (acc_sum >> 16); /* add carry */
return acc_sum;
}
--
joakim dot tjernlund at transmode dot se changed:
What |Removed |Added
----------------------------------------------------------------------------
Severity|enhancement |normal
Component|rtl-optimization |regression
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43892