ARMv8, GCC 4.9 and necessary code optimized away?

Richard Earnshaw (lists)
Wed Jun 1 10:26:00 GMT 2016

On 01/06/16 10:36, Jeffrey Walton wrote:
>>> ...
>>> An statement to test for the presence of an instruction is only code.
>> This is a mistake by the programmer.  To test for the presence of an
>> instruction, they need to emit the instruction.  Asm statements do
>> that.
> Thanks Andrew. Doesn't the intrinsic do that?
> ARM instrinsics are very appealing for us. They work on Linux,
> Android, iOS, Windows Phone, Windows Store, and Aarch32 on Aarch64.
> (I want to ensure I'm not wandering into unwanted or unseen side effects).
> Jeff

ARM intrinsics, as with most constructs in programming languages are
governed by the 'as if' rule.  That is, the behaviour (from the
view-point of the abstract machine defined by the programming language)
is as if the operation were performed.  If the compiler can determine
that an alternative code sequence can satisfy that requirement it is at
liberty to substitute that alternative sequence.

By and large, any result that is not used, can be removed by this rule
since the observable behaviour of the abstract machine is the same.

Note, finally, that asm constructs are not defined by the language
standards, so you won't get very far appealing to the relevant language
standards in this area.


More information about the Gcc-help mailing list