Re: Add new for_each macros for iterating over a List that do not require ListCell pointer - Mailing list pgsql-hackers

From Jelte Fennema-Nio
Subject Re: Add new for_each macros for iterating over a List that do not require ListCell pointer
Date
Msg-id CAGECzQSZf8OF++D5kpsd35KZb3ibbo_X0rt3c6NuiHJ2+4uw6w@mail.gmail.com
Whole thread Raw
In response to Re: Add new for_each macros for iterating over a List that do not require ListCell pointer  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Add new for_each macros for iterating over a List that do not require ListCell pointer
List pgsql-hackers
On Wed, 3 Jan 2024 at 23:13, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> I like Nathan's wording.

To be clear, I don't want to block this patch on the wording of that
single comment. So, if you feel Nathan's wording was better, I'm fine
with that too. But let me respond to your arguments anyway:

> Your assertion is contradicted by cases as
> obvious as -O0

My suggestion specifically mentions optimizing compilers, -O0 is by
definition not an optimizing compiler.

> just how far back might gcc choose to do that unrolling?

gcc 5.1 and clang 3.0 (possibly earlier, but this is the oldest I was
able to test the code with on godbolt). As seen upthread:

> I did some testing on godbolt.org and both versions of the macros
> result in the same assembly when compiling with -O2 (and even -O1)
> when compiling with ancient versions of gcc (5.1) and clang (3.0):
> https://godbolt.org/z/WqfTbhe4e

> Does the size of the loop body matter?)

I copy pasted a simple printf ~800 times and the answer seems to be
no, it doesn't matter: https://godbolt.org/z/EahYPa8KM



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Add new for_each macros for iterating over a List that do not require ListCell pointer
Next
From: Matthias van de Meent
Date:
Subject: Re: Reducing output size of nodeToString