Bug 17141 - *&a->b is not folded
Summary: *&a->b is not folded
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: Andrew Pinski
URL:
Keywords: missed-optimization, TREE
Depends on: 15459
Blocks: 19986 19626
  Show dependency treegraph
 
Reported: 2004-08-23 04:10 UTC by Andrew Pinski
Modified: 2023-12-30 01:15 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-01-13 04:48:44


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Pinski 2004-08-23 04:10:39 UTC
struct A { int i; };
int
foo(struct A *locp, int str)
{
  int T355, *T356;
  T356 = &locp->i;
  *T356 = str;
  return locp->i;
}
Comment 1 Andrew Pinski 2004-08-23 04:49:30 UTC
Confirmed.
Comment 2 Steven Bosscher 2004-08-23 06:56:07 UTC
Apparently something else _is_ folded.  And a bit early too.  We've already 
dropped to "T356<D1123> = (int<D0> *)locp<D1118>" even before gimplifying. 
Comment 3 Andrew Pinski 2004-08-23 12:41:01 UTC
Actually I just fixed that yesterday.
Comment 4 Andrew Pinski 2004-09-01 16:29:21 UTC
Mine, I have a simple pass which does this.
Comment 5 Andrew Pinski 2004-09-11 01:16:21 UTC
Actually I got my tree combiner to do the work for me.
Comment 6 Andrew Pinski 2004-09-21 02:41:56 UTC
This shows up in PR 8361.
Comment 7 Andrew Pinski 2005-03-23 20:10:31 UTC
And here is a testcase for a missed optimization on the TREE level:
void abort (void);
struct a
{
  int i;
} *a;
int f(void)
{
  int *ii = &a->i;
  void *l;
  a->i = 1;
  if (*ii)
   l = &&l1;
  else
   l = &&l2;
  goto *l;
l1:
  return 0;
l2:
  abort ();
}
Comment 8 Jeffrey A. Law 2005-05-17 16:39:05 UTC
Fixed with this patch:

http://gcc.gnu.org/ml/gcc-patches/2005-05/msg01726.html