Related articles |
---|
Undefined Behavior Optimizations in C lucic71@ctrl-c.club (Lucian Popescu) (2023-01-05) |
Re: Undefined Behavior Optimizations in C spibou@gmail.com (Spiros Bousbouras) (2023-01-05) |
Re: Undefined Behavior Optimizations in C gah4@u.washington.edu (gah4) (2023-01-05) |
Re: Undefined Behavior Optimizations in C anton@mips.complang.tuwien.ac.at (2023-01-06) |
Re: Undefined Behavior Optimizations in C anton@mips.complang.tuwien.ac.at (2023-01-06) |
Re: Undefined Behavior Optimizations in C david.brown@hesbynett.no (David Brown) (2023-01-06) |
Re: Undefined Behavior Optimizations in C gah4@u.washington.edu (gah4) (2023-01-06) |
Re: Undefined Behavior Optimizations in C gah4@u.washington.edu (gah4) (2023-01-06) |
Re: Undefined Behavior Optimizations in C spibou@gmail.com (Spiros Bousbouras) (2023-01-07) |
Re: Undefined Behavior Optimizations in C 864-117-4973@kylheku.com (Kaz Kylheku) (2023-01-09) |
Re: Undefined Behavior Optimizations in C 864-117-4973@kylheku.com (Kaz Kylheku) (2023-01-09) |
Re: Undefined Behavior Optimizations in C david.brown@hesbynett.no (David Brown) (2023-01-10) |
Re: Undefined Behavior Optimizations in C gah4@u.washington.edu (gah4) (2023-01-10) |
Re: Undefined Behavior Optimizations in C tkoenig@netcologne.de (Thomas Koenig) (2023-01-11) |
[21 later articles] |
From: | gah4 <gah4@u.washington.edu> |
Newsgroups: | comp.compilers |
Date: | Fri, 6 Jan 2023 11:39:42 -0800 (PST) |
Organization: | Compilers Central |
References: | 23-01-009 23-01-011 23-01-012 23-01-017 23-01-018 |
Injection-Info: | gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="65439"; mail-complaints-to="abuse@iecc.com" |
Keywords: | optimize, history, comment |
Posted-Date: | 06 Jan 2023 15:04:26 EST |
In-Reply-To: | 23-01-018 |
On Friday, January 6, 2023 at 10:49:59 AM UTC-8, gah4 wrote:
(snip)
> Now, this would not be a problem at all in C, with short-circuit IF
> evaluation required, but even now Fortran doesn't do short
> circuit IF evaluation. The way Fortran did static allocation in 1977,
> there was pretty much no chance that you would access outside
> your address space evaluating X(0). There is a chance, though,
> that the value 3 is stored there.
(snip)
> [Both Fortran 66 and 77 could do short-circuit evaluation, but it's
> not required. I think most compilers did, since it was easy, but
> of course you couldn't count on it. -John]
Sorry, yes, you can't count on it.
But if you can't count on it, then you can't use it in standard programs.
But now that you mention it, I was compiling this last year with
gfortran, and ran into those, so it wasn't doing it. At least it wasn't
doing all of them. I would run the program with bounds check on,
and see where it failed.
Reminds me, though, of another one from years ago.
DO 11 I=l,10
DO 12 J=l,10
IF (B(I}.LT.0.)GO TO 11
12 C(J)=SQRT(B(I)}
11 CONTINUE
comes from an IBM manual explaining the Fortran H optimizations.
It seems that the optimizer can move the SQRT out of the inner loop,
but not the test on B(I). This is actually documented, so isn't UB
anymore. (Well, not IBM UB.)
That is in an IBM manual from 1973.
[It's on page 65 of this 1967 edition. I guess they did data flow but not control flow.
http://bitsavers.org/pdf/ibm/360/fortran/C28-6602-3_OS_FORTRAN_IV_H_Programmers_Guide_1967.pdf
-John]
Return to the
comp.compilers page.
Search the
comp.compilers archives again.