------- Comment #171 from ian at airs dot com  2007-06-08 07:49 -------
Created an attachment (id=13666)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=13666&action=view)
Patch

This variant of the previous patch does better on at least some of the tramp3d
functions.  Here we eliminate the CHANGE_DYNAMIC_TYPE_EXPR nodes during the
first aliasing pass, which prevents them from retaining references to local
variables and generally clogging up optimizations.

For this test case it generates the same results as mainline, which was not
true of the previous patch.

typedef __SIZE_TYPE__ size_t;

inline void* operator new(size_t, void* __p) throw() { return __p; }

template <class T, int D>
class Vector
{
public:
   Vector()
   {
     for (int i = 0; i < D; ++i)
        new (&x_m[i]) T();
   }
   T& operator[](int i) { return x_m[i]; }

private:
   T x_m[D];
};

struct sia
{
  int ai[3];
};

struct s
{
  struct si
  {
    sia* p;
  } asi[3];
  float* pd;
};

class c
{
  int foo(int, int, int);
  s sm;
};


extern void bar(Vector<float, 3>*, int);
int c::foo(int f1, int f2, int f3)
{
  float sum = 0;
  for (int i = 0; i < 3; ++i)
    {
      for (int j = 0; j < 3; ++j)
        {
          Vector<float, 3> v;
          v[0] = 1.0;
          v[1] = 2.0;
          v[2] = 3.0;
          for (int k = 0; k < 3; ++k)
            {
              float f = (f1 * this->sm.asi[0].p->ai[0]
                         + f2 * this->sm.asi[1].p->ai[0]
                         + f3 * this->sm.asi[2].p->ai[0]);
              sum += f * v[k];
            }
          *this->sm.pd = sum;
        }
    }
  return sum;
}


-- 

ian at airs dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #13637|0                           |1
        is obsolete|                            |


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

Reply via email to