Something's definitely "up with" the RISC-V GCC port; in principle maybe there are just some passes or backend options that need to be flipped on in some way?
Looks like clang does the optimization for -mno-strict-align, but gcc doesn't seem to support that fully yet: https://godbolt.org/z/xn8erKMTe
Edit: Apparently gcc assumes by default, that unaligned loads aren't supported, but with -mtune=size it somehow enables it: https://godbolt.org/z/d9P19aMnn
Edit: Apparently gcc assumes by default, that unaligned loads aren't supported, but with -mtune=size it somehow enables it: https://godbolt.org/z/d9P19aMnn
some discussion around that: https://gcc.gnu.org/bugzilla/show_bug.cgi?format=multiple&id...