This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] RISC-V: If -m[no-]strict-align is not passed, assume its value from -mtune
- From: Palmer Dabbelt <palmer at dabbelt dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: patches at groups dot riscv dot org, Andrew Waterman <andrew at sifive dot com>
- Date: Sat, 04 Nov 2017 17:38:50 -0700 (PDT)
- Subject: Re: [PATCH] RISC-V: If -m[no-]strict-align is not passed, assume its value from -mtune
- Authentication-results: sourceware.org; auth=none
On Fri, 03 Nov 2017 09:14:10 PDT (-0700), Palmer Dabbelt wrote:
> From: Andrew Waterman <andrew@sifive.com>
>
> 2017-11-03 Andrew Waterman <andrew@sifive.com>
>
> * config/riscv/riscv.c (riscv_option_override): Conditionally set
> TARGET_STRICT_ALIGN based upon -mtune argument.
> ---
> gcc/config/riscv/riscv.c | 10 +++++++---
> 1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/gcc/config/riscv/riscv.c b/gcc/config/riscv/riscv.c
> index b81a2d29fbfd..f0b05d7eaeda 100644
> --- a/gcc/config/riscv/riscv.c
> +++ b/gcc/config/riscv/riscv.c
> @@ -3772,9 +3772,13 @@ riscv_option_override (void)
>
> /* 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. */
> - riscv_slow_unaligned_access_p = (cpu->tune_info->slow_unaligned_access
> - || TARGET_STRICT_ALIGN);
> + the performance cost is too great, even for -Os. Similarly, if
> + -m[no-]strict-align is left unspecified, heed -mtune's advice. */
> + riscv_slow_unaligned_access = (cpu->tune_info->slow_unaligned_access
> + || TARGET_STRICT_ALIGN);
> + if ((target_flags_explicit & MASK_STRICT_ALIGN) == 0
> + && cpu->tune_info->slow_unaligned_access)
> + target_flags |= MASK_STRICT_ALIGN;
>
> /* If the user hasn't specified a branch cost, use the processor's
> default. */
This was a bit broken, we missed a cleanup patch. I committed the following
diff --git a/gcc/config/riscv/riscv.c b/gcc/config/riscv/riscv.c
index b81a2d29fbfd..52bbc25d0cce 100644
--- a/gcc/config/riscv/riscv.c
+++ b/gcc/config/riscv/riscv.c
@@ -3772,9 +3772,13 @@ riscv_option_override (void)
/* 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. */
+ the performance cost is too great, even for -Os. Similarly, if
+ -m[no-]strict-align is left unspecified, heed -mtune's advice. */
riscv_slow_unaligned_access_p = (cpu->tune_info->slow_unaligned_access
|| TARGET_STRICT_ALIGN);
+ if ((target_flags_explicit & MASK_STRICT_ALIGN) == 0
+ && cpu->tune_info->slow_unaligned_access)
+ target_flags |= MASK_STRICT_ALIGN;
/* If the user hasn't specified a branch cost, use the processor's
default. */