diff mbox series

RISC-V: If -m[no-]strict-align is not passed, assume its value from -mtune

Message ID 20171103161410.4807-1-palmer@dabbelt.com
State New
Headers show
Series RISC-V: If -m[no-]strict-align is not passed, assume its value from -mtune | expand

Commit Message

Palmer Dabbelt Nov. 3, 2017, 4:14 p.m. UTC
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(-)

Comments

Palmer Dabbelt Nov. 5, 2017, 12:38 a.m. UTC | #1
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.  */
diff mbox series

Patch

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.  */