https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117573
Bug ID: 117573
Summary: RISC-V target -O2 generates Misaligned Access despite
-mstrict-align
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: [email protected]
Target Milestone: ---
___Issue Summary___
Enabling GCC optimizations (e.g., -O2) for our RISC-V project results in
program failures due to misaligned memory accesses, despite using the
-mstrict-align flag. Disabling optimizations (-O0) leads to increased binary
size and reduced performance.
___Performance Impact___
Without Optimizations (-O0):
Binary Size: ~4 KB
Performance: 8.87 DMIPS
With Optimizations (-O2):
Binary Size: ~2.8 KB
Performance: 24.15 DMIPS
This indicates a potential performance gain of approximately 2.7x when
optimizations are enabled.
___Observed Behavior___
Despite applying the -mstrict-align flag, GCC generates misaligned memory
accesses under optimization levels like -O2, leading to program crashes.
For additional detail, please refer to:
https://github.com/chili-chips-ba/wireguard-fpga/issues/5#issue-2651618418