rs6000: Allow powerpc64 to be unset for implicit 64 bit [PR108240]
authorKewen Lin <linkw@linux.ibm.com>
Wed, 1 Mar 2023 05:17:48 +0000 (23:17 -0600)
committerKewen Lin <linkw@linux.ibm.com>
Wed, 1 Mar 2023 05:17:48 +0000 (23:17 -0600)
Before r13-4894, if 64 bit is explicitly specified, option
powerpc64 is explicitly enabled too; while if 64 bit is
implicitly enabled and there is no explicit setting for
option powerpc64, option powerpc64 is eventually enabled
or not would rely on the default value of the used cpu.
It's initially set as the setting for 64 bit, but later if
the used cpu doesn't have powerpc64 supported by default,
it gets cleared.

To keep it consistent with before (also the relevant error/
warning messages), this patch is to allow that powerpc64
can be unset if 64 bit is enabled implicitly, and only stop
it from being unset if 64 bit is enabled explicitly.

Note that since the behaviors are different for implicit
and explicit 64 bit, I failed to construct one solid test
case since it becomes fragile once RUNTESTFLAGS specifying
-m64 explicitly.

PR target/108240

gcc/ChangeLog:

* config/rs6000/rs6000.cc (rs6000_option_override_internal): Allow
implicit powerpc64 setting to be unset if 64 bit is enabled implicitly.

gcc/config/rs6000/rs6000.cc

index 16ca3a3..8e0b0d0 100644 (file)
@@ -3662,14 +3662,17 @@ rs6000_option_override_internal (bool global_init_p)
 
   /* Without option powerpc64 specified explicitly, we need to ensure
      powerpc64 always enabled for 64 bit here, otherwise some following
-     checks can use unexpected TARGET_POWERPC64 value.  Meanwhile, we
-     need to ensure set_masks doesn't have OPTION_MASK_POWERPC64 on,
-     otherwise later processing can clear it.  */
+     checks can use unexpected TARGET_POWERPC64 value.  */
   if (!(rs6000_isa_flags_explicit & OPTION_MASK_POWERPC64)
       && TARGET_64BIT)
     {
       rs6000_isa_flags |= OPTION_MASK_POWERPC64;
-      set_masks &= ~OPTION_MASK_POWERPC64;
+      /* Need to stop powerpc64 from being unset in later processing,
+        so clear it in set_masks.  But as PR108240 shows, to keep it
+        consistent with before, we want to make this only if 64 bit
+        is enabled explicitly.  This is a hack, revisit this later.  */
+      if (rs6000_isa_flags_explicit & OPTION_MASK_64BIT)
+       set_masks &= ~OPTION_MASK_POWERPC64;
     }
 
   /* Process the -mcpu=<xxx> and -mtune=<xxx> argument.  If the user changed