🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.arch
Article #992

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

#992
From: Michael S
Date: Mon, 30 Nov 2026 21:54
55 lines
3862 bytes
On Mon, 30 Nov 2026 09:22:07 GMT
anton@mips.complang.tuwien.ac.at (Anton Ertl) wrote:

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

Show me.
I I spent dozens of minutes looking for such cases and did not find
them.
In all my tests gcc either generate poorly optimized latency bound code
both for signed and unsigned integers or it generates better-looking
code (I didn't measure if it really is faster) again, both for signed
and unsigned integers. I never encountered the latter cases in the
"open" code, only in loops and only in association with SIMDification.

> And it does not change the fact that
> Richard Biener has written that gcc makes this choice "due to overflow
> UB".
> 
> - anton

Technical Details
Message-ID: <20261130235457.00006421@yahoo.com>
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> <2026Nov30.102207@mips.complang.tuwien.ac.at>

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: Michael S <already5chosen@yahoo.com>
Newsgroups: comp.arch
Subject: Re: reassociation and undefined behaviour (was: vector length CSR?)
Date: Mon, 30 Nov 2026 23:54:57 +0200
Organization: A noiseless patient Spider
Lines: 55
Message-ID: <20261130235457.00006421@yahoo.com>
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>
	<2026Nov30.102207@mips.complang.tuwien.ac.at>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 30 Nov 2026 21:54:57 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="877015"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1+XKAJsh3N4wdIiKcFW6XlHIopRjhxEcAM="; posting-host="af37ef6e2a2298e04b8c13cc1e0c97d7"
Cancel-Lock: sha1:LoEyyw+NUinQX7Kb7zMWNuGYLew= sha256:AzAuTlK6f79kSJUXME9or8aBfDmEq+NXM8KmxGFdLes=
	sha1:nb4ax+QI4GTyiT9iWkzDa7CunOE= sha256:3MerU540IsIssWsP+9Cz3XcUVAeexb2mfe3g6SueygA=
X-Newsreader: Claws Mail 4.1.1 (GTK 3.24.34; x86_64-w64-mingw32)