[Bug middle-end/27181] Does not fold access to base with cast to different derived type

2006-04-28 Thread steven at gcc dot gnu dot org


-- 

steven at gcc dot gnu dot org changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
 Ever Confirmed|0   |1
   Last reconfirmed|-00-00 00:00:00 |2006-04-28 19:12:09
   date||


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27181



[Bug middle-end/27181] Does not fold access to base with cast to different derived type

2006-04-28 Thread rguenth at gcc dot gnu dot org


--- Comment #2 from rguenth at gcc dot gnu dot org  2006-04-28 19:26 ---
The code is invalid.  Anybody knows a trick to have a POD storage for non-POD
n-dimensional object which individual elements can be accessed using a
specialized 1-dimensional non-POD object?  POD storage to avoid spurious
initialization.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27181



[Bug middle-end/27181] Does not fold access to base with cast to different derived type

2006-04-28 Thread rguenth at gcc dot gnu dot org


--- Comment #3 from rguenth at gcc dot gnu dot org  2006-04-28 20:22 ---
Ok, this one does it, just for the curious:

template int Dim
struct Loc;

struct LocStorage
{ 
  int x;
};

template 
struct Loc1 : public LocStorage
{
  Loc() {}
  Loc(int i) { this-x = i; }
  Loc1 operator[](int) { return *this; }
  int get() { return this-x; }
};

template int Dim
struct WrapLoc1 : public Loc1
{
  WrapLoc1() {}
  WrapLoc1(int i) : Loc1(i) {}
};

template int Dim
struct WrapLocN : public LocDim-1
{
  WrapLocN() {}
  WrapLocN(int i) : LocDim-1(i) {}
};

template int Dim
struct Loc : public WrapLocNDim, public WrapLoc1Dim
{
  Loc() {}
  Loc(int i) : WrapLocNDim(i), WrapLoc1Dim(i) {}
  Loc1 operator[](int i)
  {
if (i == Dim-1)
  {
WrapLoc1Dim *w = this;
return *w;
  }
else
  {
WrapLocNDim *sl = this;
return sl-operator[](i-1);
  }
  }
};

int foo(void)
{
  Loc4 l(1);
  return l[0].get() + l[1].get() + l[2].get() + l[3].get();
}

now, we can optimize foo() to return 4, starting with gcc 4.0.


-- 

rguenth at gcc dot gnu dot org changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution||INVALID


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27181



[Bug middle-end/27181] Does not fold access to base with cast to different derived type

2006-04-18 Thread pinskia at gcc dot gnu dot org


-- 

pinskia at gcc dot gnu dot org changed:

   What|Removed |Added

   Severity|normal  |enhancement


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27181



[Bug middle-end/27181] Does not fold access to base with cast to different derived type

2006-04-17 Thread rguenth at gcc dot gnu dot org


--- Comment #1 from rguenth at gcc dot gnu dot org  2006-04-17 12:31 ---
The tree-combiner requiring function depends on 27084.  Also this happens in
tramp3d again.  Also related to 27090.  Still fold needs to catch it first.


-- 

rguenth at gcc dot gnu dot org changed:

   What|Removed |Added

  BugsThisDependsOn||27084, 27090
OtherBugsDependingO||22501
  nThis||


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27181