Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Work on loop code #45

Open
JordiChauzi opened this issue Jul 1, 2020 · 0 comments
Open

Work on loop code #45

JordiChauzi opened this issue Jul 1, 2020 · 0 comments
Labels
enhancement New feature or request

Comments

@JordiChauzi
Copy link

JordiChauzi commented Jul 1, 2020

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.

@JordiChauzi JordiChauzi added the enhancement New feature or request label Jul 1, 2020
@JordiChauzi JordiChauzi assigned JordiChauzi and ghost Jul 1, 2020
@JordiChauzi JordiChauzi unassigned JordiChauzi and ghost May 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant