This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: should MEM tracking be able to optimize this?
- From: Paolo Carlini <pcarlini at unitus dot it>
- To: Daniel Berlin <dan at cgsoftware dot com>, gcc at gcc dot gnu dot org
- Date: Sun, 18 Nov 2001 11:50:36 +0100
- Subject: Re: should MEM tracking be able to optimize this?
- References: <5824D336-DBE2-11D5-AA31-000393575BCC@cgsoftware.com>
Slightly off-topic... (C -> C++)
Hi all, hi Daniel,
what do you think of my beloved C++ testcase, which, I'm told, shows the limitations of
current C++ alias analysis? Could be perhaps dealt with at the tree-level similarly to
what Daniel is suggesting for C structs?
I'm told that many tough problems with C++ alias analysis comes from intricate
inherithance hierarchies but (as alluded to by Kenner) could'nt the simplest (sorry if I'm
too naive) cases at least be dealt with? It is'nt possible to stop early the analysis in
those cases without recursion, say: ok this class does not belong to any inheritance
hierarchy, we can deal with it (from the point of view of alias analysis) exactly as if
were a simple C struct...
(sorry if I'm being too naive)
Cheers,
Paolo.
////////////////////////
class RealMatrix {
public:
float &index(int i, int j)
{
return d[i - 1 + n[0] * (j - 1)];
}
float index(int i, int j) const
{
return d[i - 1 + n[0] * (j - 1)];
}
int dim(int i) const { return n[i - 1]; }
private:
float *d;
int n[4];
};
void rmatMul(RealMatrix &t, const RealMatrix &a, const RealMatrix &b)
{
const int M = a.dim(1), N = b.dim(2), K = b.dim(1);
for (int j = 1; j <= N; j++)
{
for (int k = 1; k <= K; k++)
{
float temp = b.index(k, j);
if (temp != 0.0)
{
for (int i = 1; i <= M; i++)
t.index(i, j) += temp * a.index(i, k);
}
}
}
}