Article View: comp.arch
Article #922Re: vector length CSR?
From: aph
Date: Tue, 24 Nov 2026 09:28
Date: Tue, 24 Nov 2026 09:28
55 lines
4099 bytes
4099 bytes
David Brown <david.brown@hesbynett.no> wrote:
> On 21/11/2026 15:54, Thomas Koenig 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.
>>
>
> That surprises me, but okay. There is certainly no reason why signed
> integer types cannot be treated as wrapping if it results in better code
> (assuming, of course, you don't have "-ftrapv" or relevant sanitizer
> flags in effect).
No pass within GCC (and probably any other compiler) may introduce
undefined behaviour where there was none in the program. That is
because a later pass might detect the introduced UB and miscompile it,
or even drop it onto the floor altogether.
Andrew.
Technical Details
Message-ID:
<Xq-dnT0DMOYjxZj2nZ2dnZfqnPGdnZ2d@supernews.com>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!weretis.net!feeder9.news.weretis.net!border-1.nntp.ord.giganews.com!nntp.giganews.com!Xl.tags.giganews.com!local-3.nntp.ord.giganews.com!nntp.supernews.com!news.supernews.com.POSTED!not-for-mailReferences:
<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> <11dschm$5rju$1@dont-email.me>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!weretis.net!feeder9.news.weretis.net!border-1.nntp.ord.giganews.com!nntp.giganews.com!Xl.tags.giganews.com!local-3.nntp.ord.giganews.com!nntp.supernews.com!news.supernews.com.POSTED!not-for-mail
NNTP-Posting-Date: Tue, 24 Nov 2026 09:28:30 +0000
Sender: Andrew Haley <aph@li-f2cf9ecc-3241-11b2-a85c-b613f11f80f0.ibm.com>
From: aph@littlepinkcloud.invalid
Subject: Re: vector length CSR?
Newsgroups: comp.arch
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> <11dschm$5rju$1@dont-email.me>
User-Agent: tin/1.9.2-20070201 ("Dalaruan") (UNIX) (Linux/7.3.3-100.fc43.x86_64 (x86_64))
Message-ID: <Xq-dnT0DMOYjxZj2nZ2dnZfqnPGdnZ2d@supernews.com>
Date: Tue, 24 Nov 2026 09:28:30 +0000
Lines: 55
X-Trace: sv3-mUpsr+1HqzhxRBKbF1zvk7QfHZxiFhkP4BsHI6ug+1L6eIXzr4WvayKh9VUG4NUxrzKIlgv0haOC8mu!XGalYM/bHwOu7JyDfi6vnmQqlPwIBrhVTEfn2VDWc/mQhPVNLLbj+BM6YNEK3DXnazu81r6szopJ!OegPEJi8XEQa
X-Complaints-To: www.supernews.com/docs/abuse.html
X-DMCA-Complaints-To: www.supernews.com/docs/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40