🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.arch
Article #870

Re: vector length CSR?

#870
From: Michael S
Date: Sat, 21 Nov 2026 20:50
85 lines
4237 bytes
On Sat, 21 Nov 2026 14:54:08 -0000 (UTC)
Thomas Koenig <tkoenig@netcologne.de> wrote:

> David Brown <david.brown@hesbynett.no> schrieb:
> > On 21/11/2026 15:01, Thomas Koenig wrote:  
> >> David Brown <david.brown@hesbynett.no> schrieb:  
> >>> On 20/11/2026 19:57, Thomas Koenig wrote:  
> >>>> Anton Ertl <anton@mips.complang.tuwien.ac.at> schrieb:  
> >>>>> Stephen Fuld <sfuld@alumni.cmu.edu.invalid> writes:  
> >>>>>> On 11/19/2026 10:00 AM, Thomas Koenig wrote:  
> >>>>>>> Stephen Fuld <sfuld@alumni.cmu.edu.invalid> schrieb:  
> >>>>>>>> On 11/11/2026 10:53 PM, Thomas Koenig wrote:  
> >>>>>>>>> Stephen Fuld <sfuld@alumni.cmu.edu.invalid> schrieb:
> >>>>>>>>>       s = 0;
> >>>>>>>>>       for (long int i=0; i<n; i++)
> >>>>>>>>>         s = s + a[i];  
> 
> [...]
> 
> > Without additional effort from the compiler user, a loop like this
> > can be re-arranged using commutative and associative laws and any
> > other information the compiler has.  I would not expect the
> > compiler to handle this differently for signed or unsigned types.  
> 
> gcc treats wrapping and non-wrapping differently.  Here's a function
> from gcc/tree-ssa-reassoc.cc:
> 
> /* Returns true if we can reassociate operations of TYPE.
>    That is for integral or non-saturating fixed-point types, and for
>    floating point type when associative-math is enabled.  */
> 
> static bool
> can_reassociate_type_p (tree type)
> {
>   if ((ANY_INTEGRAL_TYPE_P (type) && TYPE_OVERFLOW_WRAPS (type))
>       || NON_SAT_FIXED_POINT_TYPE_P (type)
>       || (flag_associative_math && FLOAT_TYPE_P (type)))
>     return true;
>   return false;
> }
> 
> Reassociation is possible with -frwapv, not possible with
> normal semantics.
> 


I don't know what exactly this flag means, but it does not mean what you
think it does.


int sum_int(const int* a)
{
  int sum = 0;
  for (int i = 0; i < 128; ++i)
    sum += a[i];
  return sum;
}

Compiled by gcc into:
sum_int:
        leaq    512(%rdi), %rax
        vpxor   %xmm0, %xmm0, %xmm0
.L2:
        vpaddd  (%rdi), %ymm0, %ymm0
        addq    $32, %rdi
        cmpq    %rdi, %rax
        jne     .L2
        vextracti128    $0x1, %ymm0, %xmm1
        vpaddd  %xmm0, %xmm1, %xmm0
        vpsrldq $8, %xmm0, %xmm1
        vpaddd  %xmm1, %xmm0, %xmm0
        vpsrldq $4, %xmm0, %xmm1
        vpaddd  %xmm1, %xmm0, %xmm0
        vmovd   %xmm0, %eax
        vzeroupper
        ret

https://godbolt.org/z/n8YjxnrW6






Technical Details
Message-ID: <20261121225025.000010a7@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> <11dngb5$2he51$1@dont-email.me> <2026Nov19.203832@mips.complang.tuwien.ac.at> <11dq56a$3f094$1@dont-email.me> <11ds0io$12f8$1@dont-email.me> <11ds88c$46jd$1@dont-email.me> <11ds95m$4co4$1@dont-email.me> <11dsbag$5a43$1@dont-email.me>

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: vector length CSR?
Date: Sat, 21 Nov 2026 22:50:25 +0200
Organization: A noiseless patient Spider
Lines: 85
Message-ID: <20261121225025.000010a7@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>
	<11dngb5$2he51$1@dont-email.me>
	<2026Nov19.203832@mips.complang.tuwien.ac.at>
	<11dq56a$3f094$1@dont-email.me>
	<11ds0io$12f8$1@dont-email.me>
	<11ds88c$46jd$1@dont-email.me>
	<11ds95m$4co4$1@dont-email.me>
	<11dsbag$5a43$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 21 Nov 2026 20:50:24 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="225258"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX19jKu0aR5rKeZt00AA3rlhJQYGe8Yg/vuU="; posting-host="00c07e9ec34dc910f3ffb3cd1391c851"
Cancel-Lock: sha1:i9gj1bQB9J2o9x35KfTXjrkgVB0= sha256:bl9oyRunSbUiEmW8ieNcIitmIQvYscHcuCx+4AbLU6Y=
	sha1:3XBD1T6DEZSk5ZN0vlb+WaUnHHY= sha256:I0s/WfsPaMMVSRbf+AGqIwK1gdOsin1Xz/18GzKzJIE=
X-Newsreader: Claws Mail 4.1.1 (GTK 3.24.34; x86_64-w64-mingw32)