Bug 22312 - reassoc does not handle (i+j)+(k+l) well
Summary: reassoc does not handle (i+j)+(k+l) well
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.1.0
: P2 enhancement
Target Milestone: 4.2.0
Assignee: Not yet assigned to anyone
URL:
Keywords: missed-optimization
Depends on:
Blocks: 18589 23429
  Show dependency treegraph
 
Reported: 2005-07-05 18:33 UTC by Andrew Pinski
Modified: 2005-12-13 04:29 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-11-21 02:43:36


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Pinski 2005-07-05 18:33:41 UTC
take the following example:
int f(int i, int j, int k, int l)
{
  int r1 = (i+j)+(k+l);
  int r2 = (j+k)+(l+i);
  return r1 == r2;
}

This should return 1 all the time.  I found this while making testcases for reassoc working fp (well I just 
change one little thing to make it work really).
Comment 1 Daniel Berlin 2005-07-05 19:02:39 UTC
Subject: Re:  New: reassoc does not handle
	(i+j)+(k+l) well

On Tue, 2005-07-05 at 18:33 +0000, pinskia at gcc dot gnu dot org wrote:
> take the following example:
> int f(int i, int j, int k, int l)
> {
>   int r1 = (i+j)+(k+l);
>   int r2 = (j+k)+(l+i);
>   return r1 == r2;
> }
> 
> This should return 1 all the time.  I found this while making testcases for reassoc working fp (well I just 
> change one little thing to make it work really).

We can't do a full top-down reassocation because update_stmt reorders
our operands so we lose information about which is the high ranked
operand, etc.
It's a pain in the ass to fix, but possible.

> 

Comment 2 Andrew Pinski 2005-07-05 19:35:57 UTC
Confirmed then.
Comment 3 Andrew Pinski 2005-12-13 04:29:23 UTC
Fixed.