Usenet comp.sys.dec (1990-2013)
 help / color / mirror / Atom feed
From: michael.williams@arm-sponge.com (Michael Williams)
Subject: Re: Final kick at the "Merced Guessing Game"
Date: 1997/10/15	[thread overview]
Message-ID: <62204j$aio@sis.cambridge.arm.com> (raw)
In-Reply-To: t7d8l88qr8.fsf@tanna.dcs.gla.ac.uk


In article <t7d8l88qr8.fsf@tanna.dcs.gla.ac.uk>,
Richard Black  <rjb@tanna.dcs.gla.ac.uk> wrote:
>michael.williams@arm-sponge.com (Michael Williams) writes:
>But if gcc knows the same amount of information as Fortran (i.e. that
>f() is side-effect-free) it can also make the same optimisation. viz:
>
>extern int f(int a) __attribute__ ((const));
>
>int b(int a)
>{
>    return 0 * f(a);
>}
>
>becomes (since you are at ARM):
>
>@ Generated by gcc 2.7.2 for ARM/(generic)
>rfp     .req    r9
>sl      .req    r10
>fp      .req    r11
>ip      .req    r12
>sp      .req    r13
>lr      .req    r14
>pc      .req    r15
>gcc2_compiled.:
>___gnu_compiled_c:
>.text
>        .align  0
>        .global _b
>_b:
>        @ args = 0, pretend = 0, frame = 0
>        @ frame_needed = 1, current_function_anonymous_args = 0
>        mov     ip, sp
>        stmfd   sp!, {fp, ip, lr, pc}
>        mov     r0, #0
>        sub     fp, ip, #4
>        ldmea   fp, {fp, sp, pc}

Tsk.

Norcroft ARM C compiles the equivalent:

   extern __pure int f(int a);

   int b(int a)
   {
       return 0 * f(a);
   }

to

		      b
    000000  e3a00000          MOV      a1,#0
    000004  e1a0f00e          MOV      pc,lr
  
I thought gcc was supposed to be catching up with our compiler? ;-)


Back to thread, a point to make is that neither of these programs are
ANSI C any more, and what's being discussed is ANSI C vs. ISO (?)
Fortran.

Or, as you rightly point out "how do we make a language that ...",
which is what Nick Maclaren has changed the subject to, essentially.

>Fortran "solves" this problem by having a restricted type system which
>makes it inappropriate for some problems (e.g. writing operating
>systems and device drivers).

I think what Fortran solves in this argument is that it guarantees much
less than C. E.g.:

  void copy(char *p, char *q, int n)
  {
    while (n--) *p++ = *q++;
  }

C defines the behaviour should p and q overlap.

  return 0 * f();

C defines that f is called.

  return f() || g();

C defines that g is not called, if f returns non-zero, and that f is called
before g in any case.

Fortran, from what I have read, makes none of these guarantees, which
leaves more flexibility in the compiler to target the application at
a given processor.

Nick Maclaren's gripe appears to be virtual functions, of the type used
often in C (X11, e.g.), C++ and Java. (Java's a bit of a red-herring, as
JIT compiled code might be able to remove the virtual function calls, and
a JVM isn't really executing the Java bytecode - it's a prefetching from
the datacache problem, which is there with any programming style.)

A strong type system certainly helps the compiler - but it isn't all the
problem. (Though it might help with inter-procedural optimisations, which
would solve some of the examples above - e.g. the compiler discovers for
itself that 'f' is __pure.)

Mike.



  reply	other threads:[~1997-10-15  4:00 UTC|newest]

Thread overview: 207+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-10-08  4:00 Final kick at the "Merced Guessing Game" Robert Harley
1997-10-08  4:00 ` David Chase
1997-10-08  4:00 ` William Clodius
1997-10-08  4:00 ` brianh
1997-10-08  4:00   ` boo
1997-10-09  4:00     ` Eric Hildum
1997-10-09  4:00     ` brianh
1997-10-11  4:00     ` Jan Vorbrueggen
1997-10-12  4:00       ` boo
1997-10-13  4:00         ` Carl Perkins
1997-10-13  4:00         ` Michael Williams
1997-10-13  4:00           ` Craig Burley
1997-10-13  4:00             ` boo
1997-10-15  4:00               ` Craig Burley
     [not found]                 ` <623ek6$ef5$1@news.iastate.edu>
1997-10-16  4:00                   ` Craig Burley
1997-10-16  4:00                     ` SimGraphics
1997-10-17  4:00                       ` Craig Burley
1997-10-17  4:00                         ` David Chase
1997-10-18  4:00                           ` Victor Yodaiken
1997-10-20  4:00                             ` Eric Hildum
1997-10-17  4:00                         ` William Clodius
1997-10-19  4:00                           ` Craig Burley
1997-10-18  4:00                         ` Peter L. Montgomery
1997-10-19  4:00                           ` Craig Burley
     [not found]                             ` <3456700e.14141203@news.demon.co.uk>
1997-10-28  5:00                               ` Dirk van der Knijff
1997-10-20  4:00                           ` Richard A. O'Keefe
1997-10-20  4:00                             ` Peter L. Montgomery
1997-10-16  4:00                 ` Flexible Choice of Language (Nothing to do with: Final kick at the "Merced Guessing Game") Ian Dall
1997-10-16  4:00                   ` Craig Burley
1997-10-17  4:00                   ` Richard A. O'Keefe
1997-10-17  4:00                     ` Keith Adams
1997-10-17  4:00                       ` [Reposted due to Enlow UCE cancel]: " John  Bayko
1997-10-20  4:00                         ` Paul D. DeRocco
1997-10-17  4:00                       ` John  Bayko
1997-10-18  4:00                       ` Kelly Hall
1997-10-20  4:00                         ` [Reposted due to Enlow UCE cancel]: " Eric Hildum
1997-10-13  4:00             ` Final kick at the "Merced Guessing Game" Paul Rubin
1997-10-13  4:00               ` William Clodius
1997-10-13  4:00               ` Craig Burley
1997-10-14  4:00               ` Richard A. O'Keefe
1997-10-14  4:00                 ` Michael Williams
1997-10-14  4:00                   ` Richard Black
1997-10-15  4:00                     ` Michael Williams [this message]
1997-10-15  4:00                       ` Dr. Richard Black
1997-10-16  4:00                         ` Richard A. O'Keefe
1997-10-15  4:00                     ` Craig Burley
1997-10-18  4:00                     ` Bruce Hoult
1997-10-14  4:00                 ` Shankar Unni
1997-10-15  4:00                   ` Richard A. O'Keefe
1997-10-15  4:00                     ` Paul D. DeRocco
1997-10-15  4:00                       ` William Clodius
1997-10-15  4:00                       ` Joe Buck
1997-10-16  4:00                       ` Richard A. O'Keefe
1997-10-16  4:00                         ` Craig Burley
1997-10-17  4:00                     ` Shankar Unni
1997-10-15  4:00                   ` Achim Gratz
1997-10-15  4:00                 ` Paul Hsieh
1997-10-09  4:00   ` Gregg E Economou
1997-10-10  4:00     ` Jan Vorbrueggen
     [not found] ` <61ho3v$3m0$1@goanna.cs.rmit.edu.au>
1997-10-09  4:00   ` boo
1997-10-09  4:00     ` William Clodius
1997-10-10  4:00     ` Tyson Richard DOWD
1997-10-12  4:00       ` boo
1997-10-13  4:00         ` Patricia Shanahan
1997-10-15  4:00           ` boo
1997-10-15  4:00             ` Patricia Shanahan
1997-10-13  4:00         ` Steve Tate
1997-10-13  4:00           ` Bernd Paysan
1997-10-13  4:00           ` boo
1997-10-13  4:00             ` Aaron Spink
1997-10-14  4:00               ` boo
1997-10-18  4:00                 ` [Reposted due to Enlow UCE cancel]: " tgg
1997-10-18  4:00                 ` tgg
1997-10-13  4:00           ` boo
1997-10-13  4:00             ` Victor Yodaiken
1997-10-14  4:00             ` Jason.Ozolins
1997-10-15  4:00               ` boo
1997-10-14  4:00             ` Aaron Spink
1997-10-15  4:00             ` David Chase
1997-10-10  4:00     ` boo
1997-10-11  4:00       ` Patricia Shanahan
1997-10-13  4:00         ` Gregg E Economou
1997-10-13  4:00           ` Patricia Shanahan
1997-10-14  4:00           ` Richard A. O'Keefe
1997-10-15  4:00             ` boo
1997-10-16  4:00               ` Timothy A. Seufert
1997-10-16  4:00                 ` boo
1997-10-16  4:00               ` Toon Moene
1997-10-17  4:00               ` Richard A. O'Keefe
1997-10-20  4:00               ` [Reposted due to Enlow UCE cancel]: " tgg
1997-10-20  4:00               ` Jason.Ozolins
1997-10-11  4:00       ` Toon Moene
1997-10-11  4:00       ` Paul DeMone
1997-10-10  4:00     ` Richard A. O'Keefe
     [not found]   ` <EHrwv9.2w3@world.std.com>
1997-10-10  4:00     ` David Gould
1997-10-10  4:00       ` Maynard Handley
1997-10-11  4:00         ` new languages Preston Briggs
1997-10-10  4:00     ` Final kick at the "Merced Guessing Game" David Gould
1997-10-16  4:00       ` Patricia Shanahan
  -- strict thread matches above, loose matches on Subject: below --
1997-10-09  4:00 Robert Harley
1997-10-08  4:00 Robert Harley
1997-10-08  4:00 ` Michael Meissner
1997-10-09  4:00 ` Richard A. O'Keefe
1997-10-08  4:00 Robert Harley
     [not found] ` <343C0387.41C6@lanl.gov>
1997-10-08  4:00   ` boo
1997-10-09  4:00     ` David Chase
1997-10-08  4:00       ` boo
1997-10-09  4:00       ` William Clodius
1997-10-09  4:00     ` Patrick Chase
1997-10-10  4:00       ` boo
1997-10-09  4:00 ` David Chase
1997-10-07  4:00 Robert Harley
1997-10-07  4:00 ` Nick Maclaren
1997-10-07  4:00 ` Shankar Unni
1997-10-08  4:00   ` boo
1997-10-09  4:00     ` Patrick F. McGehearty
1997-10-10  4:00       ` Richard A. O'Keefe
1997-10-15  4:00         ` David Chase
1997-10-16  4:00           ` William Clodius
1997-10-07  4:00 ` Martin Rodgers
1997-10-03  4:00 Robert Harley
1997-10-06  4:00 ` Richard A. O'Keefe
1997-10-06  4:00   ` boo
1997-10-07  4:00     ` Richard A. O'Keefe
1997-10-06  4:00       ` Graham Hughes
1997-10-07  4:00       ` boo
1997-10-07  4:00         ` William Clodius
1997-10-07  4:00       ` William Clodius
     [not found]         ` <y4wwjon203.fsf@mailhost.neuroinformatik.ruhr-uni-bochum.de>
1997-10-08  4:00           ` William Clodius
1997-10-08  4:00             ` Stanley Chow
1997-10-08  4:00         ` Richard A. O'Keefe
1997-10-08  4:00           ` William Clodius
1997-10-08  4:00           ` William Clodius
1997-10-09  4:00         ` William Clodius
1997-10-10  4:00           ` Larry Kilgallen
1997-10-10  4:00             ` Zalman Stern
1997-10-11  4:00             ` Andrew Cruickshank
1997-10-12  4:00               ` Paul D. DeRocco
1997-10-13  4:00               ` Michael Williams
1997-10-08  4:00       ` Gregg E Economou
1997-10-08  4:00         ` Richard A. O'Keefe
1997-10-08  4:00         ` David Chase
1997-10-07  4:00     ` Serge Pachkovsky
1997-10-07  4:00       ` Martin Rodgers
1997-10-07  4:00         ` Greg Weeks
1997-10-07  4:00           ` Martin Rodgers
     [not found]           ` <343AAE5A.A3FCC9D@no.informatik.spam.tu-muenchen.thanks.de>
1997-10-09  4:00             ` Torben AEgidius Mogensen
     [not found]               ` <EHsr7B.Dt8@bit3.com>
1997-10-10  4:00                 ` Torben AEgidius Mogensen
     [not found]       ` <61cv5e$qn$6@vixen.cso.uiuc.edu>
1997-10-08  4:00         ` William Clodius
1997-10-07  4:00     ` Carlie Coats
1997-10-07  4:00       ` Paul Hsieh
1997-10-07  4:00         ` boo
1997-10-08  4:00           ` Carlie Coats
1997-10-08  4:00     ` James C. Stutts
1997-10-02  4:00 Robert Harley
1997-10-02  4:00 ` Nick Maclaren
1997-10-03  4:00 ` Richard A. O'Keefe
1997-10-02  4:00 Robert Harley
1997-10-02  4:00 ` Nick Maclaren
1997-10-02  4:00   ` Stanley Chow
1997-09-30  4:00 Paul DeMone
1997-09-30  4:00 ` Guy Harris
1997-10-01  4:00   ` Tom Thornhill
1997-10-01  4:00 ` Richard A. Schumacher
1997-10-01  4:00 ` Tom Thornhill
1997-10-01  4:00   ` Paul DeMone
1997-10-01  4:00   ` Jim Hull
1997-10-01  4:00 ` Nick Maclaren
1997-10-01  4:00   ` J. Corbally
1997-10-01  4:00     ` Nick Maclaren
1997-10-01  4:00       ` Ketil Z Malde
1997-10-01  4:00         ` Michael D. Nahas
1997-10-01  4:00           ` Stefan Monnier
1997-10-01  4:00             ` Nick Maclaren
1997-10-01  4:00               ` P Murray
1997-10-01  4:00                 ` Nick Maclaren
1997-10-02  4:00                   ` Andrew Glew
1997-10-02  4:00                   ` Vesa Karvonen
1997-10-02  4:00                     ` Joseph H Allen
1997-10-02  4:00                       ` Wilco Dijkstra
1997-10-03  4:00                         ` Jason.Ozolins
1997-10-03  4:00                           ` Alex Colvin
1997-10-06  4:00                             ` Richard A. O'Keefe
1997-10-08  4:00                               ` Zalman Stern
1997-10-03  4:00                         ` Stefan Monnier
1997-10-03  4:00                       ` Stefan Monnier
1997-10-02  4:00                 ` Torben AEgidius Mogensen
1997-10-02  4:00                   ` Patrick F. McGehearty
1997-10-02  4:00                     ` brianh
1997-10-03  4:00                     ` Michael Williams
1997-10-01  4:00               ` John Wilson
1997-10-01  4:00               ` Allen Kim
1997-10-02  4:00               ` Jon Leech
1997-10-02  4:00               ` Stefan Monnier
1997-10-03  4:00                 ` Richard A. O'Keefe
1997-10-03  4:00               ` Mike Smith
1997-10-03  4:00                 ` Nick Maclaren
1997-10-03  4:00                   ` Rob Barris
1997-10-03  4:00                     ` Andrew Glew
1997-10-05  4:00                       ` Gianni Mariani
1997-10-04  4:00                     ` Nick Maclaren
1997-10-04  4:00                       ` H. Eckert
1997-10-05  4:00                       ` Andy "Krazy" Glew
1997-10-06  4:00                         ` Nick Maclaren
1997-10-01  4:00           ` brianh
1997-10-02  4:00           ` Eric Hildum
1997-10-01  4:00   ` Paul DeMone
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox