This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

As-if Rule (was: ARMv8, GCC 4.9 and necessary code optimized away)


> 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.

I'm not sure I would agree. GCC needs to know intent (q.v.), and I'm
guessing that's probably an NP-complete problem.

C++11 got constexpr to specify intent, so I know the committee is
familiar with the concept.

Sorry to sound argumentative. I'm frustrated when a correct program is
turned into a misbehaving program :)

Maybe as a stop gap GCC could warn when its completely discarding
blocks of code. As far as I know, the only warning at the moment is
for -Wstrict-overflow when an optimization is taken due to integer
overflow. And maybe the "unreachable" because of an early return.

Jeff


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]