public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Kewen.Lin" <linkw@linux.ibm.com>
To: Segher Boessenkool <segher@kernel.crashing.org>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>,
	David Edelsohn <dje.gcc@gmail.com>,
	Peter Bergner <bergner@linux.ibm.com>,
	iain@sandoe.co.uk
Subject: Re: [PATCH] rs6000: Rework option -mpowerpc64 handling [PR106680]
Date: Thu, 29 Sep 2022 14:16:04 +0800	[thread overview]
Message-ID: <ba9d35be-4698-124e-2569-45117e2a1eac@linux.ibm.com> (raw)
In-Reply-To: <20220928220443.GV25951@gate.crashing.org>

Hi Segher!

Thanks for the review comments!!

on 2022/9/29 06:04, Segher Boessenkool wrote:
> On Wed, Sep 28, 2022 at 01:30:46PM +0800, Kewen.Lin wrote:
>> PR106680 shows that -m32 -mpowerpc64 is different from
>> -mpowerpc64 -m32, this is determined by the way how we
>> handle option powerpc64 in rs6000_handle_option.
>>
>> Segher pointed out this difference should be taken as
>> a bug and we should ensure that option powerpc64 is
>> independent of -m32/-m64.  So this patch removes the
>> handlings in rs6000_handle_option and add some necessary
>> supports in rs6000_option_override_internal instead.
> 
> Thanks!
> 
>> With this patch, if users specify -m{no-,}powerpc64, the
>> specified value is honoured, otherwise, for 64bit it
>> always enables OPTION_MASK_POWERPC64 while for 32bit
>> it disables OPTION_MASK_POWERPC64 if OS_MISSING_POWERPC64.
> 
> If the user says -m64 -mno-powerpc64 it should error, and perhaps -m32
> -mpowerpc64 should warn if OS_MISSING_POWERPC64?

OK ...

> 
>> -  /* Some OSs don't support saving the high part of 64-bit registers on context
>> -     switch.  Other OSs don't support saving Altivec registers.  On those OSs,
>> -     we don't touch the OPTION_MASK_POWERPC64 or OPTION_MASK_ALTIVEC settings;
>> -     if the user wants either, the user must explicitly specify them and we
>> -     won't interfere with the user's specification.  */
>> +  /* Some OSs don't support saving Altivec registers.  On those OSs, we don't
>> +     touch the OPTION_MASK_POWERPC64 or OPTION_MASK_ALTIVEC settings; if the
>> +     user wants either, the user must explicitly specify them and we won't
>> +     interfere with the user's specification.  */
>>
>>    set_masks = POWERPC_MASKS;
>> -#ifdef OS_MISSING_POWERPC64
>> -  if (OS_MISSING_POWERPC64)
>> -    set_masks &= ~OPTION_MASK_POWERPC64;
>> -#endif
> 
> As I said elsewhere, it probably is helpful if we still warn here for
> -m32 -mpowerpc64 with OS_MISSING_POWERPC64 (or without the -m32 even,
> same thing).
> 

OK ... 

>> +  /* With option powerpc64 specified explicitly (either on or off), even if
>> +     being compiled for 64 bit we don't need to check if it's disabled here,
>> +     since subtargets will check and raise an error message if necessary
>> +     later.  But without option powerpc64 specified explicitly, we need to
>> +     ensure powerpc64 enabled for 64 bit and disabled on those OSes with
>> +     OS_MISSING_POWERPC64, since they don't support saving the high part of
>> +     64-bit registers on context switch.  */
>> +  if (!(rs6000_isa_flags_explicit & OPTION_MASK_POWERPC64))
>> +    {
>> +      if (TARGET_64BIT)
>> +	/* Make sure we always enable it by default for 64 bit.  */
>> +	rs6000_isa_flags |= OPTION_MASK_POWERPC64;
>> +#ifdef OS_MISSING_POWERPC64
>> +      else if (OS_MISSING_POWERPC64)
>> +	/* It's unexpected to have OPTION_MASK_POWERPC64 on for OSes which
>> +	   miss powerpc64 support, so disable it.  */
>> +	rs6000_isa_flags &= ~OPTION_MASK_POWERPC64;
>> +#endif
>> +    }
> 
> Aha.  Please don't, just warn instead?  Silently disabling such stuff is
> the worst option :-(

... I'll update this to warn instead as you suggested. :)

> 
>> +/* { dg-error "'-m64' requires a PowerPC64 cpu" "PR106680" { target powerpc*-*-linux* powerpc-*-rtems* } 0 } */
> 
> Everything except AIX even?  So it will include Darwin as well (and the
> BSDs, and powerpc*-elf, etc.)

I found this message only existed in file rtems.h and function rs6000_linux64_override_options,
the latter is used by files linux64.h and freebsd64.h, I guess we just want to add one more
powerpc*-*-freebsd*, but leave the others alone (and update this as needed later)?

> 
>> --- /dev/null
>> +++ b/gcc/testsuite/gcc.target/powerpc/pr106680-4.c
>> @@ -0,0 +1,16 @@
>> +/* Skip this on aix, otherwise it emits the error message like "64-bit
>> +   computation with 32-bit addressing not yet supported" on aix.  */
>> +/* { dg-skip-if "" { powerpc*-*-aix* } } */
>> +/* { dg-require-effective-target ilp32 } */
>> +/* { dg-options "-mpowerpc64 -m32 -O2" } */
> 
> If you have -m32 you don't need ilp32, and the other way around.
> 

Will update!  I was afraid the dejagnu version mattered, it can be:
"-mpowerpc64 -m32 -O2 -m64" or "-m64 -mpowerpc64 -m32 -O2", but just
realized -mpowerpc64 would always take effect, useless worry.  :)

>> +/* Verify option -m32 doesn't override option -mpowerpc64.
>> +   If option -mpowerpc64 gets overridden, the assembly would
>> +   end up with addc and adde.  */
>> +/* { dg-final { scan-assembler-not "addc" } } */
>> +/* { dg-final { scan-assembler-not "adde" } } */
> 
> Lol, nice :-)
> 
> "adde" is a frequent substring, use \m \M please?  You will always get
> these exact insns anyway.  And you could add a -times {\madd\M} 1 ?

Will update, thanks again for all the comments!

> 
> The Darwin problem might be something in darwin*.h, but I don't see it.
> Maybe it is a more generic problem?
> 

Yeah, it's probably a generic problem but only got exposed on darwin,
I just made a trial diff, hope it can work.

BR,
Kewen

  reply	other threads:[~2022-09-29  6:16 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-28  5:30 Kewen.Lin
2022-09-28  6:37 ` Iain Sandoe
2022-09-28 16:18   ` Iain Sandoe
2022-09-28 19:09     ` Iain Sandoe
2022-09-29  5:45       ` Kewen.Lin
2022-09-29  8:16         ` Iain Sandoe
2022-09-29  9:12           ` Kewen.Lin
2022-09-29 16:14             ` Iain Sandoe
2022-09-29 17:04           ` Segher Boessenkool
2022-09-29 18:25             ` Iain Sandoe
2022-09-29 18:37               ` Segher Boessenkool
2022-09-30  9:26                 ` Kewen.Lin
2022-09-29 17:11         ` Segher Boessenkool
2022-09-30 12:15           ` Kewen.Lin
2022-10-03 21:15             ` Segher Boessenkool
2022-10-10  2:15               ` Kewen.Lin
2022-10-10 13:58                 ` Segher Boessenkool
2022-10-12  8:26                   ` Kewen.Lin
2022-09-28 21:30     ` Segher Boessenkool
2022-09-28 23:04       ` Iain Sandoe
2022-09-28 23:16         ` Iain Sandoe
2022-09-29 17:26           ` Segher Boessenkool
2022-09-29 17:18         ` Segher Boessenkool
2022-09-29 18:33           ` Iain Sandoe
2022-09-29 18:50             ` Segher Boessenkool
2022-09-28 22:04 ` Segher Boessenkool
2022-09-29  6:16   ` Kewen.Lin [this message]
2022-09-29 18:56     ` Segher Boessenkool

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ba9d35be-4698-124e-2569-45117e2a1eac@linux.ibm.com \
    --to=linkw@linux.ibm.com \
    --cc=bergner@linux.ibm.com \
    --cc=dje.gcc@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=iain@sandoe.co.uk \
    --cc=segher@kernel.crashing.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).