Re: fast array assignement

robert.corbett_at_sun.com
Date: 02/07/05


Date: 6 Feb 2005 21:04:07 -0800


> It is surprising
> to me that now, almost 15 years after array syntax was standardized
> in the language, optimizers aren't doing a better job with array
> syntax.

It is no surprise to me. Optimizing array expressions is hard.
Consider an example that was presented before on c.l.f.
Someone wanted to know why the expression

      COUNT( (/ a, b, c, d /) ) == 4

where a, b, c, and d are logical expressions took longer to execute
than

      a .and. b .and. c .and. d

Most compilers figure out that the array constructor has a small
fixed-size value, and so dynamic allocation is unnecessary. A few
understand that evaluating the count does not require storing the
elements of the constructor. If any compiler does the transformation
into logical conjunctions, it is because a special case was tossed in
as a result of the earlier posting on c.l.f.

                Sincerely,

                 Bob Corbett



Relevant Pages

  • Re: Array.Clear vs List<>.Clear
    ... that creating a great big value array was still faster. ... That in mind, your results aren't all that surprising to me, as it's ... internal framework function. ... just eventually call some sort of memset variant (which is really ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Getting the right class with inheritance and super()
    ... If you use inheritance you must make sure that your ... class's invariant is not broken. ... FixesSizedArray is far from usable in every place where an Array is ... or is it least surprising to let the 100 line window ...
    (comp.lang.ruby)
  • Re: Operator overloading () with Fortran 95 ?
    ... it's not possible to write a derived type in Fortran ... >> unfortunate since Fortran's array syntax is very powerful indeed). ... > elemental subroutine assign ...
    (comp.lang.fortran)
  • Re: new for n-dimensional array.
    ... The 'size' argument for allocating an array with 'operator new' ... as well as automatically resize ... The vector can be accessed using array syntax: ...
    (comp.lang.cpp)
  • Re: ARRAY EQUATION VS FORALL
    ... code does, whereas I have to search out the type statements for a, b,c, ... I personally prefer the simpler array statement than the equivalent ... in an array expression. ... require complicated mergeand mask contortions with array syntax. ...
    (comp.lang.fortran)