Skip to content

Global symbols in arithmetic operations use one register more than needed #44

Open
@JordiChauzi

Description

@JordiChauzi

Global symbols are not treated as 32-bit immediates in arithmetic instructions. We are losing one move.

Code:

#include <stdint.h>

uint8_t dpu_mram_buffer[(8 << 20)];

extern void bar(uint8_t *ptr);

void foo(uint32_t i) {
    bar(dpu_mram_buffer+i);
}

Output:

foo:                                    // @foo
        sd r22, 0, d22
        add r22, r22, 8
        move r1, dpu_mram_buffer
        add r0, r1, r0
        call r23, bar
        ld d22, r22, -8
        jump r23

https://dpu.dev/z/WI12nI

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions