There are some situations where an __undefined__ keyword would be useful, 
especially w.r.t. vector intrinsics.  Here is an example that came up recently.

    <a bunch of 4 wide vector computation>
    t1 = _mm_movehl_ps(t0, t0);
    t2 = _mm_add_ps(t1, t0);
    _mm_storel_pi(mem, t2);

In this example, the programmer doesn't care about the upper elements of the 
result of the _mm_movehl_ps intrinsic.  They are never used.  The only purpose 
of the first argument to _mm_movehl_ps is to produce these values that are 
never used.  But the programmer has to pass *something* as that first argument. 
 And in this case, the choice of t0 causes the compiler to insert an extra 
copy.  Ideally, the programmer would like to write this:

    <a bunch of 4 wide vector computation>
    t1 = _mm_movehl_ps(__undefined__, t0);
    t2 = _mm_add_ps(t1, t0);
    _mm_storel_pi(mem, t2);

For the Intel Compiler, we are adding new intrinsics to solve this problem, 
e.g. __m128 _mm_undefined_ps().  A keyword would be a nice alternative if we 
could find a convenient syntax.

Dave Kreitzer
IA32/Intel64 Code Generation
Intel Compiler Lab

-----Original Message-----
From: Mark Mitchell [mailto:m...@codesourcery.com] 
Sent: Friday, August 20, 2010 7:33 PM
To: H.J. Lu
Cc: Bernd Schmidt; Ian Lance Taylor; GCC Development; Kreitzer, David L; 
Girkar, Milind
Subject: Re: Add uninitialized attribute?

H.J. Lu wrote:

> void *undef __attribute__ ((uninitialized)); // Or something similar
> 
> foo (undef);
> 
> Compiler can pass some junk to foo.

I don't think that's a very good idea.  If we need this, which I doubt,
it should be something like a new __undefined__ keyword, that expands to
 an undefined value.  In C++, a syntax like __undefined__<X>() would be
plausible; I'm not sure there's a good C syntax.  Perhaps you could do
what tgmath does.

I guess if you had this, you could use it in place of the attribute;

  int i = __undefined__<int>();

would serve to indicate that you were knowingly not initializing i.

-- 
Mark Mitchell
CodeSourcery
m...@codesourcery.com
(650) 331-3385 x713

Reply via email to