Skip to content

Commit 08f7e32

Browse files
committed
Support RISC-V unaligned-scalar-mem target feature
This adds `unaligned-scalar-mem` as an allowed RISC-V target feature. Some RISC-V cores support unaligned access to memory without trapping. On such cores, the compiler could significantly improve code-size and performance when using functions like core::ptr::read_unaligned<u32> by emitting a single load or store instruction with an unaligned address, rather than a long sequence of byte load/store/bitmanip instructions. Enabling the `unaligned-scalar-mem` target feature allows LLVM to do this optimization. Fixes #110883
1 parent adaac6b commit 08f7e32

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

compiler/rustc_codegen_ssa/src/target_features.rs

+1
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ const RISCV_ALLOWED_FEATURES: &[(&str, Option<Symbol>)] = &[
252252
("f", Some(sym::riscv_target_feature)),
253253
("m", Some(sym::riscv_target_feature)),
254254
("relax", Some(sym::riscv_target_feature)),
255+
("unaligned-scalar-mem", Some(sym::riscv_target_feature)),
255256
("v", Some(sym::riscv_target_feature)),
256257
("zba", Some(sym::riscv_target_feature)),
257258
("zbb", Some(sym::riscv_target_feature)),

0 commit comments

Comments
 (0)