Bug 17598 - an extra addition when comparing address of &a->b and &c->b.
Summary: an extra addition when comparing address of &a->b and &c->b.
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.0.0
: P2 enhancement
Target Milestone: 4.1.0
Assignee: Richard Biener
URL: http://gcc.gnu.org/ml/gcc-patches/200...
Keywords: missed-optimization, patch
Depends on:
Blocks: 19987
  Show dependency treegraph
 
Reported: 2004-09-22 03:52 UTC by Andrew Pinski
Modified: 2005-04-26 16:37 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-04-25 13:38:23


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Pinski 2004-09-22 03:52:02 UTC
Function g and g1 should produce the same code, this is not a regression, I noticed this when looking 
into PR 8361.
struct f
{
  int i;
  int j;
};
int g(struct f *x, struct f *y)
{
  return &x->j == &y->j;
}
int g1(struct f *x, struct f *y)
{
  return x == y;
}
Comment 1 Andrew Pinski 2004-09-26 14:26:01 UTC
Fold should be able to deal with this.
Comment 2 Richard Biener 2005-04-25 13:38:22 UTC
Patch in testing.
Comment 3 Richard Biener 2005-04-26 09:13:07 UTC
Patch posted:
http://gcc.gnu.org/ml/gcc-patches/2005-04/msg02658.html
Comment 4 CVS Commits 2005-04-26 16:35:51 UTC
Subject: Bug 17598

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	rguenth@gcc.gnu.org	2005-04-26 16:35:32

Modified files:
	gcc            : ChangeLog fold-const.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/gcc.dg/tree-ssa: pr17598.c 

Log message:
	2004-04-26  Richard Guenther  <rguenth@gcc.gnu.org>
	
	PR tree-optimization/17598
	* fold-const.c (fold_binary): Fold comparisons of addresses
	of COMPONENT_REFs which reference the same field to
	comparisons of the addresses of the base objects.
	
	* gcc.dg/tree-ssa/pr17598.c: New testcase.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.8465&r2=2.8466
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fold-const.c.diff?cvsroot=gcc&r1=1.571&r2=1.572
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.5399&r2=1.5400
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/tree-ssa/pr17598.c.diff?cvsroot=gcc&r1=NONE&r2=1.1

Comment 5 Richard Biener 2005-04-26 16:37:19 UTC
Fixed.