Skip to content

Commit 078f7c4

Browse files
wangpc-ppJeffreyALaw
authored andcommitted
[PATCH] RISC-V: override alignment of function/jump/loop
Just like what AArch64 has done. Signed-off-by: Wang Pengcheng <[email protected]> gcc/ChangeLog: * config/riscv/riscv.cc (struct riscv_tune_param): Add new tune options. (riscv_override_options_internal): Override the default alignment when not optimizing for size.
1 parent a616b7e commit 078f7c4

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

gcc/config/riscv/riscv.cc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,9 @@ struct riscv_tune_param
295295
bool overlap_op_by_pieces;
296296
unsigned int fusible_ops;
297297
const struct cpu_vector_cost *vec_costs;
298+
const char *function_align = nullptr;
299+
const char *jump_align = nullptr;
300+
const char *loop_align = nullptr;
298301
};
299302

300303

@@ -10283,6 +10286,18 @@ riscv_override_options_internal (struct gcc_options *opts)
1028310286
? &optimize_size_tune_info
1028410287
: cpu->tune_param;
1028510288

10289+
/* If not optimizing for size, set the default
10290+
alignment to what the target wants. */
10291+
if (!opts->x_optimize_size)
10292+
{
10293+
if (opts->x_flag_align_loops && !opts->x_str_align_loops)
10294+
opts->x_str_align_loops = tune_param->loop_align;
10295+
if (opts->x_flag_align_jumps && !opts->x_str_align_jumps)
10296+
opts->x_str_align_jumps = tune_param->jump_align;
10297+
if (opts->x_flag_align_functions && !opts->x_str_align_functions)
10298+
opts->x_str_align_functions = tune_param->function_align;
10299+
}
10300+
1028610301
/* Use -mtune's setting for slow_unaligned_access, even when optimizing
1028710302
for size. For architectures that trap and emulate unaligned accesses,
1028810303
the performance cost is too great, even for -Os. Similarly, if

0 commit comments

Comments
 (0)