🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.arch
Article #984

Re: reassociation and undefined behaviour (was: vector length CSR?)

#984
From: Anton Ertl
Date: Mon, 30 Nov 2026 09:22
42 lines
3221 bytes
Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
>anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:
>
>> Thomas Koenig <tkoenig@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, <c17fcd89-f024-40e7-a594-88a85ac10d20o@googlegroups.com>
Technical Details
Message-ID: <2026Nov30.102207@mips.complang.tuwien.ac.at>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.hispagatos.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
References: <11cpqih$acf5$1@dont-email.me> <sgu0flpndaqltpdbft40fghmi7vk78q2hs@4ax.com> <11cq2v7$dh5b$1@dont-email.me> <8jk1fl182pskj3fsmp4ju6qf420pgl0htg@4ax.com> <11csull$1ef6e$1@dont-email.me> <2026Nov9.230104@mips.complang.tuwien.ac.at> <11cvcr4$28k7g$1@dont-email.me> <11d3npt$3mmho$1@dont-email.me> <11dn936$2ebc2$1@dont-email.me> <11dndfd$2fr9j$1@dont-email.me> <2026Nov19.193817@mips.complang.tuwien.ac.at> <86o6b6kaqf.fsf@linuxsc.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.hispagatos.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
From: anton@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.arch
Subject: Re: reassociation and undefined behaviour (was: vector length CSR?)
Date: Mon, 30 Nov 2026 09:22:07 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 42
Message-ID: <2026Nov30.102207@mips.complang.tuwien.ac.at>
References: <11cpqih$acf5$1@dont-email.me> <sgu0flpndaqltpdbft40fghmi7vk78q2hs@4ax.com> <11cq2v7$dh5b$1@dont-email.me> <8jk1fl182pskj3fsmp4ju6qf420pgl0htg@4ax.com> <11csull$1ef6e$1@dont-email.me> <2026Nov9.230104@mips.complang.tuwien.ac.at> <11cvcr4$28k7g$1@dont-email.me> <11d3npt$3mmho$1@dont-email.me> <11dn936$2ebc2$1@dont-email.me> <11dndfd$2fr9j$1@dont-email.me> <2026Nov19.193817@mips.complang.tuwien.ac.at> <86o6b6kaqf.fsf@linuxsc.com>
Injection-Date: Mon, 30 Nov 2026 09:39:46 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="299369"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX184+CyhoU92QhXZ1KSky45o"; posting-host="9f98da6933dc7cb94ede6b09405aa366"
Cancel-Lock: sha1:SUA9HAEEpYe+hAzTN3+ysft59QY= sha256:WVjOqJ7VdGGr8dSypbGvwb7zeczlvfIjki9d9XUMjqw=
	sha1:vFNGbEFxmk6HzAq4AhX8j3zH+0w= sha256:+T8XWkiNZeoUcUhGEwMOsi8inFp3V/If8HhbJDElZk4=
X-newsreader: xrn 10.11