Bug 56212 - Does not fold unsigned (b - a) + a
Summary: Does not fold unsigned (b - a) + a
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.8.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: missed-optimization
Depends on:
Blocks:
 
Reported: 2013-02-05 12:50 UTC by Richard Biener
Modified: 2014-12-11 14:22 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Richard Biener 2013-02-05 12:50:42 UTC
unsigned foo (unsigned a, unsigned b)
{
  return (b - a) + a;
}

should be simplified to return b.  Later GIMPLE reassoc and forwprop do that job.
Comment 1 Marek Polacek 2014-12-11 14:22:25 UTC
Trunk optimizes it to return b now, so I guess fixed.