🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.arch
Article #1063

Re: reassociation and undefined behaviour

#1063
From: MitchAlsup
Date: Fri, 04 Dec 2026 03:37
37 lines
2632 bytes
scott@slp53.sl.home (Scott Lurndal) posted:

> MitchAlsup <user5857@newsgrouper.org.invalid> writes:
> >anton@mips.complang.tuwien.ac.at (Anton Ertl) posted:
> >
> >> David Brown <david.brown@hesbynett.no> writes:
> >> >On 03/12/2026 03:07, MitchAlsup wrote:
> >> >> David Brown <david.brown@hesbynett.no> posted:
> >> >>> In general, "(x<<n) | (x>>(32-n))" cannot be replaced with "undef"
> >> >> 
> >> >> It should be replaced with::
> >> >> 
> >> >>       ROTW     Rt,Rx,Rn
> >> >> 
> >> >
> >> >Optimising compilers generally do implement such expressions with 
> >> >rotation instructions, when "n" is a variable.
> >> 
> >> I looked at this in 2015, and found that clang-3.5 generates:
> >> 
> >> mov %sil,%cl
> >> rol %cl,%edi
> >> 
> >> if it knows nothing about n, but code that produces 0 if it knows that
> >> n=0.
> >> 
> >> >There are good reasons for such shifts being UB in C.  Processors are 
> >> >not consistent in how out-of-range shifts are handled.  "x >> 32" might 
> >> >give 0 or it might give x.
> >
> >How is x a useful result ?? EVER ???
> 
> If the programmer wants a zero, surely it is more efficient to
> to just assign zero the the variable rather than right-shifting
> some random 32-bit value by 32 bits.

Not questioning 0--but questioning when (x>>32) == x when x !=0
Technical Details
Message-ID: <1796355421-5857@newsgrouper.org>
Path: mbox-mo1.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!news.hispagatos.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!newsgrouper.org!.POSTED!not-for-mail
References: <11cpqih$acf5$1@dont-email.me> <86o6b6kaqf.fsf@linuxsc.com> <11ejr5e$nk8$1@reader2.panix.com> <11ejtoe$eoj7$1@dont-email.me> <11el2c1$q43$1@reader2.panix.com> <11emcgn$1k681$1@dont-email.me> <jwvbj74bzm4.fsf-monnier+comp.arch@gnu.org> <11eolqn$2peg5$1@dont-email.me> <2026Dec2.132411@mips.complang.tuwien.ac.at> <11epd07$362ph$1@dont-email.me> <1796263648-5857@newsgrouper.org> <11ergn7$6utu$1@dont-email.me> <2026Dec3.122036@mips.complang.tuwien.ac.at> <1796326998-5857@newsgrouper.org> <eCkQS.41981$ncv4.3699@fx06.iad>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!news.hispagatos.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!newsgrouper.org!.POSTED!not-for-mail
From: MitchAlsup <user5857@newsgrouper.org.invalid>
Newsgroups: comp.arch
Subject: Re: reassociation and undefined behaviour
References: <11cpqih$acf5$1@dont-email.me> <86o6b6kaqf.fsf@linuxsc.com> <11ejr5e$nk8$1@reader2.panix.com> <11ejtoe$eoj7$1@dont-email.me> <11el2c1$q43$1@reader2.panix.com> <11emcgn$1k681$1@dont-email.me> <jwvbj74bzm4.fsf-monnier+comp.arch@gnu.org> <11eolqn$2peg5$1@dont-email.me> <2026Dec2.132411@mips.complang.tuwien.ac.at> <11epd07$362ph$1@dont-email.me> <1796263648-5857@newsgrouper.org> <11ergn7$6utu$1@dont-email.me> <2026Dec3.122036@mips.complang.tuwien.ac.at> <1796326998-5857@newsgrouper.org> <eCkQS.41981$ncv4.3699@fx06.iad>
Date: Fri, 04 Dec 2026 03:37:01 GMT
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Message-ID: <1796355421-5857@newsgrouper.org>
Injection-Info: newsgrouper.org; mail-complaints-to="newsgrouper@yahoo.com"; posting-account=user5857
Injection-Date: Fri, 04 Dec 2026 03:37:01 GMT
User-Agent: Newsgrouper/0.9.0