I could be dissuaded from this position, which I have not entirely thought
through, but it would seem to me that embedded assembler ought to be utterly
exempt from compiler optimization. They are mutually exclusive approaches.
You want the compiler to do its best? Code in C and let the compiler
optimize it. You want to use the X, Y and Z assembler instructions? Code in
embedded assembler and get exactly what you want.

I suppose an exception might be made for unreachable and otherwise
unreferenced code? What is the point of hand-coded assembler that will never
be referenced? (And yes, "referenced" would have to include every possible
source of references.)

COBOL 6 I think has a COPYRIGHT keyword that works as Gil describes.

Charles


-----Original Message-----
From: IBM Mainframe Assembler List [mailto:[email protected]]
On Behalf Of Paul Gilmartin
Sent: Saturday, November 20, 2021 8:19 AM
To: [email protected]
Subject: Re: Curious compiler optimization

On Nov 20, 2021, at 08:45:38, Phil Smith III wrote:
> 
> Mario Bezzi wrote about inline assembler being optimized out of existence.
> 
> Seems APARable, no?
>  
That's perfectly reasonable behavior for peephole optimization
which detects otiose instructions.  Why should it preserve
"BCR 0,0"?

This is the rationale for C's "volatile" storage class.  References
to volatile objects must not be moved out of loops; they might be
accesses to hardware registers.

I had a co-worker who complained of an Intel assembler's substituting
a faster branch instruction, breaking his intended CPU timing loop.

I have worked with a language that had a "legalnotice" keyword which
protected otherwise unreferenced copyright strings from elimination
by optimization.

Reply via email to