Tim Rentsch <tr.1…@z991.linuxsc.com> writes:
>ant…@mips.complang.tuwien.ac.at (Anton Ertl) writes:
>
>> Thomas Koenig <tkoe…@netcologne.de> writes:
>>> (from https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128737 ).
>>
>> If the undefined behaviour nonsense would not be so sad, it
>> would be funny. The undefined behaviour advocates love to
>> claim that undefined behaviour allows more optimization than
>> defined behaviour, but in Comment 1 Richard Biener writes that
>> gcc does not perform this optimization because of undefined
>> behaviour. [...]
>
>I suspect you are misunderstanding the meaning of RB's comment.
The comment in it's entirety is:
|probably a duplicate, the GIMPLE level re-association pass doesn't
|consider signed integers (due to overflow UB)
He uses the word "due" and not "because", but it's clear that the
reason he states for not performing this optimization is "overflow
UB".
In the part of my posting that you deleted, I discuss why the gcc
maintainers may have decided not to reassociate in this case.
>The rules of C do not prohibit the optimization from being done.
>gcc does not perform the transformation because of a choice gcc
>has made about how code is compiled.
This does not change anything about the fact that gcc does not
reassociate the supposedly optimization-friendly overflow-UB integers,
while it does reassociate integers where overflow is defined to
perform modulo arithmetics. And it does not change the fact that
Richard Biener has written that gcc makes this choice "due to overflow
UB".
- anton
--
'Anyone trying for "industrial quality" ISA should avoid undefined behavior.'
Mitch Alsup, <c17f…@googlegroups.com>