On 19/07/2025 12:03, Florian Weimer via Gcc-help wrote:
* David Brown:
I am guessing that this transformation is being done on internal
representation of the code - but I don't know the details of how these
work in gcc. (One day, I'd love to have the time to learn.) It might
well be that there is no way in that representation to request that
these multiplies be two's complement wrapping when the main context is
UB overflow. If that's the case, then I can understand how that
optimisation is not applied - but that would be a limitation of the
internal representation rather than a fundamental issue with the
optimisation.
Yes, that's what I meant. It's a limitation of GCC's IR, I think.
(Obviously no expert in this matter.)
Okay, that clears it up for me - thanks. It's easy for me (far less
knowledgable about gcc's internals than you) to talk about what a
compiler is /allowed/ to do (while remaining standards-conforming -
though compilers can be very useful in non-conforming modes too). But I
can often misunderstand the practical and realistic limitations of a
given compiler.
David