Skip to content

Commit

Permalink
[PATCH] RISC-V: override alignment of function/jump/loop
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
wangpc-pp authored and JeffreyALaw committed Oct 24, 2024
1 parent a616b7e commit 078f7c4
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions gcc/config/riscv/riscv.cc
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,9 @@ struct riscv_tune_param
bool overlap_op_by_pieces;
unsigned int fusible_ops;
const struct cpu_vector_cost *vec_costs;
const char *function_align = nullptr;
const char *jump_align = nullptr;
const char *loop_align = nullptr;
};


Expand Down Expand Up @@ -10283,6 +10286,18 @@ riscv_override_options_internal (struct gcc_options *opts)
? &optimize_size_tune_info
: cpu->tune_param;

/* If not optimizing for size, set the default
alignment to what the target wants. */
if (!opts->x_optimize_size)
{
if (opts->x_flag_align_loops && !opts->x_str_align_loops)
opts->x_str_align_loops = tune_param->loop_align;
if (opts->x_flag_align_jumps && !opts->x_str_align_jumps)
opts->x_str_align_jumps = tune_param->jump_align;
if (opts->x_flag_align_functions && !opts->x_str_align_functions)
opts->x_str_align_functions = tune_param->function_align;
}

/* Use -mtune's setting for slow_unaligned_access, even when optimizing
for size. For architectures that trap and emulate unaligned accesses,
the performance cost is too great, even for -Os. Similarly, if
Expand Down

0 comments on commit 078f7c4

Please sign in to comment.