Skip to content

Work on loop code #45

@JordiChauzi

Description

@JordiChauzi

Code:

extern unsigned char array[256];

unsigned int foo() {
    unsigned int r = 0;

    for (int i = 255; i >= 0; --i) {
        r += array[i];
    }

    return r;
}
foo:                                    // @foo
        move r0, 0
        move r1, -256
.LBB0_1:                                // =>This Inner Loop Header: Depth=1
        not r2, r1
        lbu r2, r2, array
        add r3, r1, 1
        sub r4, r3, r1, ltu
        add r0, r0, r2
        move r1, r3
        jz r4, .LBB0_1
        jump r23

This is not ideal.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions