Skip to content

stage2 array access performance (boundchecks related?) #12215

@xxxbxxx

Description

@xxxbxxx

Zig Version

0.10.0-dev.3286+9ec3f611c

Steps to Reproduce

const std = @import("std");

test {
    const array = try std.testing.allocator.create([10][10 * 10 * 10 * 10]u64);
    defer std.testing.allocator.destroy(array);
    array[1][1] = 0;

    var a: u32 = 1;
    var b: u32 = 1;

    var i: u32 = 0;
    while (i < 12345678) : (i += 1) {
        array[a][b] += array[a][b] * i;
    }

    try std.testing.expect(array[a][b] == 0);
}

Expected Behavior

test passes in <1s
(and does with stage 1)

Actual Behavior

test passes in > 20s (stage 2)

in debug and releasesafe modes.
seems to work fine in releasefast. (there's no memcpy in the llvmir)

Metadata

Metadata

Assignees

Labels

bugObserved behavior contradicts documented or intended behaviorfrontendTokenization, parsing, AstGen, Sema, and Liveness.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions