bounds checking and optimization
David Nadlinger
code at klickverbot.at
Wed Jun 30 23:21:33 UTC 2021
On 30 Jun 2021, at 12:43, Johan via digitalmars-d-ldc wrote:
> On Wednesday, 30 June 2021 at 01:18:53 UTC, Bruce Carneal wrote:
>> could c.length be extracted and asserted as being leq a.length and
>> b.length before we drop in to the loop?
>
> That would be observable behavior change, so not possible. Unless the
> behavior upon out-of-bounds access is defined as UB.
There might be LLVM optimisation passes to recognise the range checks
and coalesce them into a single one before the loop header, though – I
vaguely remember seeing something like this in the tree at some point,
developed with a few towards Java, and not enabled by default in the
PassManagerBuilder. We might be able to reuse/adapt that logic.
— David
More information about the digitalmars-d-ldc
mailing list