Skip to content

RISC-V: enable -mno-strict-align when Zicclsm is enabled #110454

Closed
@newpavlov

Description

@newpavlov

Otherwise LLVM generates terrible code for misaligned loads/stores, as can be seen here: https://rust.godbolt.org/z/ax1bqeeKx

The RISC-V Profiles specification states the following

Even though mandated, misaligned loads and stores might execute extremely slowly. Standard software distributions should assume their existence only for correctness, not for performance.

This footnote is not present in the RVA23 spec, but it's unclear whether it got deprecated or implicitly inherited from the profiles spec.

In practice, we probably can expect that most hardware which declares Zicclsm support will have "fast" misaligned support implemented in hardware.

As another data point, it looks like Linux also considers that enabled Zicclsm means "fast" misaligned operations. From this patch:

If Zicclsm is present, the kernel will set both scalar and vector unaligned access speed to FAST.

Metadata

Metadata

Assignees

No one assigned

    Labels

    backend:RISC-VquestionA question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions