Skip to content

[RISCV] fpic optimisation  #54372

@abukharmeh

Description

@abukharmeh

When compiling position independent code for RISC-V and trying to access global variable inside any loop, the compiler tries to get the address of the global variable from GOT in every iteration of the loop, while in ARM, it does it only once before entering the loop.

I think it only need to do it once in RISC-V as well.

Example code that illisturate the problem compiled for RISC-V and ARM:
https://godbolt.org/z/YMoxGrY97

Edit: GCC does it before entering the loop for RISC-V

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions