diff mbox series

[09/12] aarch64: Assign flags to local constexpr variable

Message ID dbf193a2-8873-fea2-4fb4-3223314b42cb@e124511.cambridge.arm.com
State New
Headers show
Series aarch64: Extend aarch64_feature_flags to 128 bits | expand

Commit Message

Andrew Carlotti May 14, 2024, 2:58 p.m. UTC
This guarantees that the constant values are actually evaluated at
compile time.

In previous testing, I have observed GCC failing to evaluate and inline
these constant values, which exposed a separate bug in which some of the
required symbols from feature_deps were missing.  Richard Sandiford has
since fixed that bug, but we still want to ensure we get the benefits of
compile-time evaluation here.

gcc/ChangeLog:

	* common/config/aarch64/aarch64-common.cc
	(aarch64_set_asm_isa_flags): Make constant explicitly constexpr.
	* config/aarch64/aarch64.cc
	(aarch64_override_options_internal): Ditto.
diff mbox series

Patch

diff --git a/gcc/common/config/aarch64/aarch64-common.cc b/gcc/common/config/aarch64/aarch64-common.cc
index 2f437b82a24c16d9f808a4367ce2a281a49a77ee..9f583bb80456709e0028c358a1bad23ad59f20f4 100644
--- a/gcc/common/config/aarch64/aarch64-common.cc
+++ b/gcc/common/config/aarch64/aarch64-common.cc
@@ -74,7 +74,10 @@  aarch64_set_asm_isa_flags (gcc_options *opts, aarch64_feature_flags flags)
 {
   opts->x_aarch64_asm_isa_flags_0 = flags;
   if (opts->x_target_flags & MASK_GENERAL_REGS_ONLY)
-    flags &= ~feature_deps::get_flags_off (AARCH64_FL_FP);
+    {
+      constexpr auto flags_mask = ~feature_deps::get_flags_off (AARCH64_FL_FP);
+      flags &= flags_mask;
+    }
   opts->x_aarch64_isa_flags_0 = flags;
 }
 
diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc
index eef0905069232bacc59d574cad0f6edbaf062387..69c3b257982b4a0e282cbf7486802b147d166945 100644
--- a/gcc/config/aarch64/aarch64.cc
+++ b/gcc/config/aarch64/aarch64.cc
@@ -18305,7 +18305,8 @@  aarch64_override_options_internal (struct gcc_options *opts)
 	      " option %<-march%>, or by using the %<target%>"
 	      " attribute or pragma", "sme");
       opts->x_target_flags &= ~MASK_GENERAL_REGS_ONLY;
-      auto new_flags = isa_flags | feature_deps::SME ().enable;
+      constexpr auto flags_enable_sme = feature_deps::SME ().enable;
+      auto new_flags = isa_flags | flags_enable_sme;
       aarch64_set_asm_isa_flags (opts, new_flags);
     }