Bug 15785 - fold misses unary transformation
Summary: fold misses unary transformation
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.0.0
: P2 enhancement
Target Milestone: 4.0.0
Assignee: James A. Morrison
URL:
Keywords: missed-optimization, TREE
Depends on:
Blocks:
 
Reported: 2004-06-02 21:07 UTC by Andrew Pinski
Modified: 2005-02-15 21:58 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2004-12-26 14:40:36


Attachments
testcase (174 bytes, text/plain)
2005-02-12 14:03 UTC, James A. Morrison
Details
Fold unary operations (540 bytes, patch)
2005-02-12 14:04 UTC, James A. Morrison
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Pinski 2004-06-02 21:07:24 UTC
int f(int x)
{
  return ~(x-1);//should be -x
}
Comment 1 Andrew Pinski 2004-06-02 21:08:54 UTC
int f(int x)
{
  return ~ (-x); // x-1
}
Comment 2 Andrew Pinski 2004-06-02 21:20:04 UTC
int f(int x)
{
  return  - (~x); // should be x-1
}
Comment 3 Andrew Pinski 2004-06-26 20:22:31 UTC
Confirmed.
Comment 4 Kazu Hirata 2004-07-04 07:23:32 UTC
Actually, the function in Comment #2 should generate "x + 1".
Comment 5 James A. Morrison 2005-02-12 14:03:46 UTC
Created attachment 8183 [details]
testcase
Comment 6 James A. Morrison 2005-02-12 14:04:46 UTC
Created attachment 8184 [details]
Fold unary operations

 This folds the three cases givin in this bug.
Comment 7 James A. Morrison 2005-02-15 21:58:57 UTC
 Fixed.