* [PATCH,rs6000] Handle conflicting target options -mno-power9-vector and -mcpu=power9
@ 2017-03-22 17:44 Kelvin Nilsen
2017-03-22 23:35 ` Segher Boessenkool
0 siblings, 1 reply; 6+ messages in thread
From: Kelvin Nilsen @ 2017-03-22 17:44 UTC (permalink / raw)
To: gcc-patches; +Cc: Segher Boessenkool
Internal testing recently revealed that use of the -mno-power9-vector
target option in combination with the -mcpu=power9 target option
results in termination of gcc with the error message:
power9-dform requires power9-vector
This same problem is seen if the -mno-power9-vector target option is
specified to a gcc which was built using --with-cpu=power9 as an
argument to configure.
In both cases, the preferred behavior is that the target option
-mno-power9-vector causes power9-dform to be automatically disabled.
This patch implements the preferred behavior and adds a test case to
demonstrate the fix.
The patch has been bootstrapped and tested with no regressions on both
powerpc64-unknown-linux-gnu and powerpc64le-unknown-linux-gnu. Is this
ok for the trunk?
gcc/testsuite/ChangeLog:
2017-03-21 Kelvin Nilsen <kelvin@gcc.gnu.org>
* gcc.target/powerpc/p9-options-1.c: New test.
gcc/ChangeLog:
2017-03-21 Kelvin Nilsen <kelvin@gcc.gnu.org>
* config/rs6000/rs6000.c (rs6000_option_override_internal): Change
handling of certain combinations of target options, including the
combinations -mpower8-vector vs. -mno-vsx, -mpower8-vector vs.
-mno-power8-vector, and -mpower9_dform vs. -mno-power9-vector.
Index: gcc/config/rs6000/rs6000.c
===================================================================
--- gcc/config/rs6000/rs6000.c (revision 246212)
+++ gcc/config/rs6000/rs6000.c (working copy)
@@ -4246,9 +4246,22 @@ rs6000_option_override_internal (bool global_init_
if (TARGET_P8_VECTOR && !TARGET_VSX)
{
- if (rs6000_isa_flags_explicit & OPTION_MASK_P8_VECTOR)
+ if ((rs6000_isa_flags_explicit & OPTION_MASK_P8_VECTOR)
+ && (rs6000_isa_flags_explicit & OPTION_MASK_VSX))
error ("-mpower8-vector requires -mvsx");
- rs6000_isa_flags &= ~OPTION_MASK_P8_VECTOR;
+ else if ((rs6000_isa_flags_explicit & OPTION_MASK_P8_VECTOR) == 0)
+ {
+ rs6000_isa_flags &= ~OPTION_MASK_P8_VECTOR;
+ if (rs6000_isa_flags_explicit & OPTION_MASK_VSX)
+ rs6000_isa_flags_explicit |= OPTION_MASK_P8_VECTOR;
+ }
+ else
+ {
+ /* OPTION_MASK_P8_VECTOR is explicit, and OPTION_MASK_VSX is
+ not explicit. */
+ rs6000_isa_flags |= OPTION_MASK_VSX;
+ rs6000_isa_flags_explicit |= OPTION_MASK_VSX;
+ }
}
if (TARGET_VSX_TIMODE && !TARGET_VSX)
@@ -4448,9 +4461,22 @@ rs6000_option_override_internal (bool global_init_
error messages. However, if users have managed to select
power9-vector without selecting power8-vector, they
already know about undocumented flags. */
- if (rs6000_isa_flags_explicit & OPTION_MASK_P8_VECTOR)
+ if ((rs6000_isa_flags_explicit & OPTION_MASK_P9_VECTOR) &&
+ (rs6000_isa_flags_explicit & OPTION_MASK_P8_VECTOR))
error ("-mpower9-vector requires -mpower8-vector");
- rs6000_isa_flags &= ~OPTION_MASK_P9_VECTOR;
+ else if ((rs6000_isa_flags_explicit & OPTION_MASK_P9_VECTOR) == 0)
+ {
+ rs6000_isa_flags &= ~OPTION_MASK_P9_VECTOR;
+ if (rs6000_isa_flags_explicit & OPTION_MASK_P8_VECTOR)
+ rs6000_isa_flags_explicit |= OPTION_MASK_P9_VECTOR;
+ }
+ else
+ {
+ /* OPTION_MASK_P9_VECTOR is explicit and
+ OPTION_MASK_P8_VECTOR is not explicit. */
+ rs6000_isa_flags |= OPTION_MASK_P8_VECTOR;
+ rs6000_isa_flags_explicit |= OPTION_MASK_P8_VECTOR;
+ }
}
/* -mpower9-dform turns on both -mpower9-dform-scalar and
@@ -4479,10 +4505,25 @@ rs6000_option_override_internal (bool global_init_
error messages. However, if users have managed to select
power9-dform without selecting power9-vector, they
already know about undocumented flags. */
- if (rs6000_isa_flags_explicit & OPTION_MASK_P9_VECTOR)
+ if ((rs6000_isa_flags_explicit & OPTION_MASK_P9_VECTOR)
+ && (rs6000_isa_flags_explicit & (OPTION_MASK_P9_DFORM_SCALAR
+ | OPTION_MASK_P9_DFORM_VECTOR)))
error ("-mpower9-dform requires -mpower9-vector");
- rs6000_isa_flags &= ~(OPTION_MASK_P9_DFORM_SCALAR
- | OPTION_MASK_P9_DFORM_VECTOR);
+ else if (rs6000_isa_flags_explicit & OPTION_MASK_P9_VECTOR)
+ {
+ rs6000_isa_flags &=
+ ~(OPTION_MASK_P9_DFORM_SCALAR | OPTION_MASK_P9_DFORM_VECTOR);
+ rs6000_isa_flags_explicit |=
+ (OPTION_MASK_P9_DFORM_SCALAR | OPTION_MASK_P9_DFORM_VECTOR);
+ }
+ else
+ {
+ /* We know that OPTION_MASK_P9_VECTOR is not explicit and
+ OPTION_MASK_P9_DFORM_SCALAR or OPTION_MASK_P9_DORM_VECTOR
+ may be explicit. */
+ rs6000_isa_flags |= OPTION_MASK_P9_VECTOR;
+ rs6000_isa_flags_explicit |= OPTION_MASK_P9_VECTOR;
+ }
}
if (TARGET_P9_DFORM_SCALAR && !TARGET_UPPER_REGS_DF)
Index: gcc/testsuite/gcc.target/powerpc/p9-options-1.c
===================================================================
--- gcc/testsuite/gcc.target/powerpc/p9-options-1.c (revision 0)
+++ gcc/testsuite/gcc.target/powerpc/p9-options-1.c (working copy)
@@ -0,0 +1,28 @@
+/* { dg-do compile { target { powerpc*-*-* } } } */
+/* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power9" } } */
+/* { dg-require-effective-target powerpc_p9vector_ok } */
+/* { dg-options "-mcpu=power9 -mno-power9-vector" } */
+
+#include <altivec.h>
+
+/* This program's "test for excess errors" demonstrates that combining
+ the target options -mcpu=power9 and -mno-power9-vector does not
+ result in an error. A previous version of the compiler aborted
+ with the error message:
+
+ "power9-dform requires power9-vector."
+
+ when these two options were used in combination.
+
+ The newer version of the compiler, instead, automatically disables
+ power9-dform when the -mno-power9-vector command-line option is
+ specified. */
+int
+test_any_equal (vector bool char *arg1_p, vector bool char *arg2_p)
+{
+ vector bool char arg_1 = *arg1_p;
+ vector bool char arg_2 = *arg2_p;
+
+ return vec_any_eq (arg_1, arg_2);
+}
+
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH,rs6000] Handle conflicting target options -mno-power9-vector and -mcpu=power9
2017-03-22 17:44 [PATCH,rs6000] Handle conflicting target options -mno-power9-vector and -mcpu=power9 Kelvin Nilsen
@ 2017-03-22 23:35 ` Segher Boessenkool
2017-03-22 23:56 ` Kelvin Nilsen
0 siblings, 1 reply; 6+ messages in thread
From: Segher Boessenkool @ 2017-03-22 23:35 UTC (permalink / raw)
To: Kelvin Nilsen; +Cc: gcc-patches
On Wed, Mar 22, 2017 at 11:44:49AM -0600, Kelvin Nilsen wrote:
> Internal testing recently revealed that use of the -mno-power9-vector
> target option in combination with the -mcpu=power9 target option
> results in termination of gcc with the error message:
>
> power9-dform requires power9-vector
> In both cases, the preferred behavior is that the target option
> -mno-power9-vector causes power9-dform to be automatically disabled.
> This patch implements the preferred behavior and adds a test case to
> demonstrate the fix.
Or it could do -mpower9-dform-scalar but disable -mpower9-dform-vector?
That seems more reasonable.
Ideally none of the -mpower9-dform* or -mpower9-vector options would
exist at all, of course.
> 2017-03-21 Kelvin Nilsen <kelvin@gcc.gnu.org>
>
> * config/rs6000/rs6000.c (rs6000_option_override_internal): Change
> handling of certain combinations of target options, including the
> combinations -mpower8-vector vs. -mno-vsx, -mpower8-vector vs.
> -mno-power8-vector, and -mpower9_dform vs. -mno-power9-vector.
Those other changes are independent?
Segher
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH,rs6000] Handle conflicting target options -mno-power9-vector and -mcpu=power9
2017-03-22 23:35 ` Segher Boessenkool
@ 2017-03-22 23:56 ` Kelvin Nilsen
2017-03-23 4:17 ` Segher Boessenkool
0 siblings, 1 reply; 6+ messages in thread
From: Kelvin Nilsen @ 2017-03-22 23:56 UTC (permalink / raw)
To: Segher Boessenkool; +Cc: gcc-patches
On 03/22/2017 05:35 PM, Segher Boessenkool wrote:
> On Wed, Mar 22, 2017 at 11:44:49AM -0600, Kelvin Nilsen wrote:
>> Internal testing recently revealed that use of the -mno-power9-vector
>> target option in combination with the -mcpu=power9 target option
>> results in termination of gcc with the error message:
>>
>> power9-dform requires power9-vector
>
>> In both cases, the preferred behavior is that the target option
>> -mno-power9-vector causes power9-dform to be automatically disabled.
>> This patch implements the preferred behavior and adds a test case to
>> demonstrate the fix.
>
> Or it could do -mpower9-dform-scalar but disable -mpower9-dform-vector?
> That seems more reasonable.
The internal problem report sent to me said "-mno-power9-vector should
override power9-dform unless the latter has been deliberately specified
by the user." I'm just following orders. If you think it preferable to
only override -mpower-dform-vector, I'll make that modification.
>
> Ideally none of the -mpower9-dform* or -mpower9-vector options would
> exist at all, of course.
>
>> 2017-03-21 Kelvin Nilsen <kelvin@gcc.gnu.org>
>>
>> * config/rs6000/rs6000.c (rs6000_option_override_internal): Change
>> handling of certain combinations of target options, including the
>> combinations -mpower8-vector vs. -mno-vsx, -mpower8-vector vs.
>> -mno-power8-vector, and -mpower9_dform vs. -mno-power9-vector.
>
> Those other changes are independent?
Actually, these other changes are not independent. My initial attempt
at a patch only changed the behavior of -mpower9_dform vs.
-mno-power9-vector. But this actually resulted in a regression of an
existing test. To "properly" handle the new case without impacting
existing "established" behavior (as represented in the existing dejagnu
testsuite), I had to make these other changes as well.
>
>
> Segher
>
>
--
Kelvin Nilsen, Ph.D. kdnilsen@linux.vnet.ibm.com
home office: 801-756-4821, cell: 520-991-6727
IBM Linux Technology Center - PPC Toolchain
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH,rs6000] Handle conflicting target options -mno-power9-vector and -mcpu=power9
2017-03-22 23:56 ` Kelvin Nilsen
@ 2017-03-23 4:17 ` Segher Boessenkool
2017-06-28 14:30 ` Backport " Kelvin Nilsen
0 siblings, 1 reply; 6+ messages in thread
From: Segher Boessenkool @ 2017-03-23 4:17 UTC (permalink / raw)
To: Kelvin Nilsen; +Cc: gcc-patches
On Wed, Mar 22, 2017 at 05:55:53PM -0600, Kelvin Nilsen wrote:
> > Or it could do -mpower9-dform-scalar but disable -mpower9-dform-vector?
> > That seems more reasonable.
>
> The internal problem report sent to me said "-mno-power9-vector should
> override power9-dform unless the latter has been deliberately specified
> by the user." I'm just following orders.
Heh :-)
> If you think it preferable to
> only override -mpower-dform-vector, I'll make that modification.
It is more logical. Or so I though. But as it turns out,
-mpower9-dform-scalar is about vector registers as well.
So the patch is approved for trunk as-is. Thanks!
> >> * config/rs6000/rs6000.c (rs6000_option_override_internal): Change
> >> handling of certain combinations of target options, including the
> >> combinations -mpower8-vector vs. -mno-vsx, -mpower8-vector vs.
> >> -mno-power8-vector, and -mpower9_dform vs. -mno-power9-vector.
> >
> > Those other changes are independent?
>
> Actually, these other changes are not independent. My initial attempt
> at a patch only changed the behavior of -mpower9_dform vs.
> -mno-power9-vector. But this actually resulted in a regression of an
> existing test. To "properly" handle the new case without impacting
> existing "established" behavior (as represented in the existing dejagnu
> testsuite), I had to make these other changes as well.
Too many options :-(
Segher
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Backport [PATCH,rs6000] Handle conflicting target options -mno-power9-vector and -mcpu=power9
2017-03-23 4:17 ` Segher Boessenkool
@ 2017-06-28 14:30 ` Kelvin Nilsen
2017-06-28 21:03 ` Segher Boessenkool
0 siblings, 1 reply; 6+ messages in thread
From: Kelvin Nilsen @ 2017-06-28 14:30 UTC (permalink / raw)
To: Segher Boessenkool; +Cc: gcc-patches
I have bootstrapped and tested this patch on
powerpc64le-unkonwn-linux-gnu with no regressions. Is this ok for
backporting to gcc 6?
On 03/22/2017 10:17 PM, Segher Boessenkool wrote:
> On Wed, Mar 22, 2017 at 05:55:53PM -0600, Kelvin Nilsen wrote:
>>> Or it could do -mpower9-dform-scalar but disable -mpower9-dform-vector?
>>> That seems more reasonable.
>>
>> The internal problem report sent to me said "-mno-power9-vector should
>> override power9-dform unless the latter has been deliberately specified
>> by the user." I'm just following orders.
>
> Heh :-)
>
>> If you think it preferable to
>> only override -mpower-dform-vector, I'll make that modification.
>
> It is more logical. Or so I though. But as it turns out,
> -mpower9-dform-scalar is about vector registers as well.
>
> So the patch is approved for trunk as-is. Thanks!
>
>>>> * config/rs6000/rs6000.c (rs6000_option_override_internal): Change
>>>> handling of certain combinations of target options, including the
>>>> combinations -mpower8-vector vs. -mno-vsx, -mpower8-vector vs.
>>>> -mno-power8-vector, and -mpower9_dform vs. -mno-power9-vector.
>>>
>>> Those other changes are independent?
>>
>> Actually, these other changes are not independent. My initial attempt
>> at a patch only changed the behavior of -mpower9_dform vs.
>> -mno-power9-vector. But this actually resulted in a regression of an
>> existing test. To "properly" handle the new case without impacting
>> existing "established" behavior (as represented in the existing dejagnu
>> testsuite), I had to make these other changes as well.
>
> Too many options :-(
>
>
> Segher
>
>
--
Kelvin Nilsen, Ph.D. kdnilsen@linux.vnet.ibm.com
home office: 801-756-4821, cell: 520-991-6727
IBM Linux Technology Center - PPC Toolchain
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Backport [PATCH,rs6000] Handle conflicting target options -mno-power9-vector and -mcpu=power9
2017-06-28 14:30 ` Backport " Kelvin Nilsen
@ 2017-06-28 21:03 ` Segher Boessenkool
0 siblings, 0 replies; 6+ messages in thread
From: Segher Boessenkool @ 2017-06-28 21:03 UTC (permalink / raw)
To: Kelvin Nilsen; +Cc: gcc-patches
On Wed, Jun 28, 2017 at 08:30:21AM -0600, Kelvin Nilsen wrote:
> I have bootstrapped and tested this patch on
> powerpc64le-unkonwn-linux-gnu with no regressions. Is this ok for
> backporting to gcc 6?
Please wait until after 6.4.
Thanks,
Segher
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-06-28 21:03 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-22 17:44 [PATCH,rs6000] Handle conflicting target options -mno-power9-vector and -mcpu=power9 Kelvin Nilsen
2017-03-22 23:35 ` Segher Boessenkool
2017-03-22 23:56 ` Kelvin Nilsen
2017-03-23 4:17 ` Segher Boessenkool
2017-06-28 14:30 ` Backport " Kelvin Nilsen
2017-06-28 21:03 ` Segher Boessenkool
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).