Re: Avoid a possible out-of-bounds access (src/backend/optimizer/util/relnode.c) - Mailing list pgsql-hackers

From David Rowley
Subject Re: Avoid a possible out-of-bounds access (src/backend/optimizer/util/relnode.c)
Date
Msg-id CAApHDvqoZ8dCSuWF60hL=EPHNr5riRvbZ6YP6wyj-fu5K0gV9Q@mail.gmail.com
Whole thread Raw
In response to Avoid a possible out-of-bounds access (src/backend/optimizer/util/relnode.c)  (Ranier Vilela <ranier.vf@gmail.com>)
List pgsql-hackers
On Wed, 27 Sept 2023 at 01:31, Ranier Vilela <ranier.vf@gmail.com> wrote:
> It seems to me that it adds a LEA instruction.
> https://godbolt.org/z/b4jK3PErE

There's a fairly significant difference in the optimisability of a
comparison with a compile-time constant vs a variable. For example,
would you expect the compiler to emit assembly for each side of the
boolean AND in: if (a > 12 && a > 20),  or how about if (a > 12 && a >
y)?  No need to answer. Just consider it.

I suggest keeping your experiments as close to the target code as
practical. You might be surprised by what the compiler can optimise.

David



pgsql-hackers by date:

Previous
From: Ranier Vilela
Date:
Subject: Re: Avoid a possible out-of-bounds access (src/backend/optimizer/util/relnode.c)
Next
From: Fabrízio de Royes Mello
Date:
Subject: Re: Add test module for Table Access Method