Friendly-C
deadalnix via Digitalmars-d
digitalmars-d at puremagic.com
Fri Aug 29 01:29:49 PDT 2014
On Friday, 29 August 2014 at 05:55:18 UTC, Ola Fosheim Gr wrote:
> On Friday, 29 August 2014 at 05:31:02 UTC, deadalnix wrote:
>> If the value in unspecified, rather than the behavior
>> undefined, it means that no load or store can be optimized
>> away or reordered, unless the compiler can prove that is won't
>> fault.
>>
>> I'm talking about doubtful optimization to gain 0.5% here, but
>> that everything single variable except locals must be
>> considered volatile in the C sense.
>
> Why is that? If the value is unspecified then you can assume a
> random value, so no single store is needed unless explicitly
> volatile?
>
> Wrapping semantics is also bad for optimization, though. You
> cannot reduce length < length+N to true in generic code, so you
> need to establish bounds on x or create multiple execution
> paths. This is usually silly when using a 64 bit int...
Because, if you don't have undefined BEHAVIOR, you can't change
the BEHAVIOR. So you have to prove that store/loads won't fault
before doing anything with them. As per spec. Or you'll change
the BEHAVIOR.
More information about the Digitalmars-d
mailing list