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>,
	Peter Bergner <bergner@linux.ibm.com>,
	Michael Meissner <meissner@linux.ibm.com>,
	David Edelsohn <dje.gcc@gmail.com>
Subject: Re: [PATCH] rs6000: Fix some issues related to Power10 fusion [PR104024]
Date: Mon, 19 Dec 2022 14:13:49 +0800	[thread overview]
Message-ID: <bce16dfc-85db-511b-00a5-df81c67f198b@linux.ibm.com> (raw)
In-Reply-To: <20221214222944.GR25951@gate.crashing.org>

Hi Segher,

Thanks for the review comments!

on 2022/12/15 06:29, Segher Boessenkool wrote:
> On Wed, Nov 30, 2022 at 04:30:13PM +0800, Kewen.Lin wrote:
>> As PR104024 shows, the option -mpower10-fusion isn't guarded by
>> -mcpu=power10, it causes compiler to fuse for some patterns
>> even without power10 support and then causes ICE unexpectedly,
>> this patch is to simply unmask it without power10 support, not
>> emit any warnings as this option is undocumented.
> 
> Yes, it mostly exists for debugging purposes (and also for testcase).
> 
>> Besides, for some define_insns in fusion.md which use constraint
>> v, it requires the condition VECTOR_UNIT_ALTIVEC_OR_VSX_P
>> (<MODE>mode), otherwise it can cause ICE in reload, see test
>> case pr104024-2.c.
> 
> Please don't two separate things in one patch.  It makes bisecting
> harder than necessary, and perhaps more interesting to you: it makes
> writing good changelog entries and commit messages harder.

OK, will do.

> 
>> --- a/gcc/config/rs6000/genfusion.pl
>> +++ b/gcc/config/rs6000/genfusion.pl
>> @@ -167,7 +167,7 @@ sub gen_logical_addsubf
>>  	$inner_comp, $inner_inv, $inner_rtl, $inner_op, $both_commute, $c4,
>>  	$bc, $inner_arg0, $inner_arg1, $inner_exp, $outer_arg2, $outer_exp,
>>  	$ftype, $insn, $is_subf, $is_rsubf, $outer_32, $outer_42,$outer_name,
>> -	$fuse_type);
>> +	$fuse_type, $constraint_cond);
>>    KIND: foreach $kind ('scalar','vector') {
>>        @outer_ops = @logicals;
>>        if ( $kind eq 'vector' ) {
>> @@ -176,12 +176,14 @@ sub gen_logical_addsubf
>>  	  $pred = "altivec_register_operand";
>>  	  $constraint = "v";
>>  	  $fuse_type = "fused_vector";
>> +	  $constraint_cond = "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode) && ";
>>        } else {
>>  	  $vchr = "";
>>  	  $mode = "GPR";
>>  	  $pred = "gpc_reg_operand";
>>  	  $constraint = "r";
>>  	  $fuse_type = "fused_arith_logical";
>> +	  $constraint_cond = "";
>>  	  push (@outer_ops, @addsub);
>>  	  push (@outer_ops, ( "rsubf" ));
>>        }
> 
> I don't like this at all.  Please use the "isa" attribute where needed?
> Or do you need more in some cases?  But, again, separate patch.

This is to add one more condition for those define_insns, for example:

@@ -1875,7 +1875,7 @@ (define_insn "*fuse_vand_vand"
                           (match_operand:VM 1 "altivec_register_operand" "%v,v,v,v"))
                  (match_operand:VM 2 "altivec_register_operand" "v,v,v,v")))
    (clobber (match_scratch:VM 4 "=X,X,X,&v"))]
-  "(TARGET_P10_FUSION)"
+  "(VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode) && TARGET_P10_FUSION)"
   "@
    vand %3,%1,%0\;vand %3,%3,%2
    vand %3,%1,%0\;vand %3,%3,%2

It's to avoid the pseudo whose mode isn't available for register constraint v
causes ICE during reload.  I'm not sure how the "isa" attribute helps here,
could you elaborate it?

> 
>> +  if (TARGET_POWER10
>> +      && (rs6000_isa_flags_explicit & OPTION_MASK_P10_FUSION) == 0)
>> +    rs6000_isa_flags |= OPTION_MASK_P10_FUSION;
>> +  else if (!TARGET_POWER10 && TARGET_P10_FUSION)
>> +    rs6000_isa_flags &= ~OPTION_MASK_P10_FUSION;
> 
> That's not right.  If you want something like this you should check for
> TARGET_POWER10 whenever you check for TARGET_P10_FUSION; but there
> really is no reason at all to disable P10 fusion on other CPUs (neither
> newer nor older!).

Good point, and I just noticed that we should check tune setting instead
of TARGET_POWER10 here?  Something like:

if (!(rs6000_isa_flags_explicit & OPTION_MASK_P10_FUSION))
  {
    if (processor_target_table[tune_index].processor == PROCESSOR_POWER10)
      rs6000_isa_flags |= OPTION_MASK_P10_FUSION;
    else
      rs6000_isa_flags &= ~OPTION_MASK_P10_FUSION;
  }

> 
>> --- /dev/null
>> +++ b/gcc/testsuite/gcc.target/powerpc/pr104024-1.c
>> @@ -0,0 +1,16 @@
>> +/* { dg-require-effective-target int128 } */
>> +/* { dg-options "-O1 -mdejagnu-cpu=power6 -mpower10-fusion" } */
> 
> Does this need -O1?  If not, use -O2 please; if so, document it.
> 

No, it doesn't, will use -O2 instead.

BR,
Kewen

  reply	other threads:[~2022-12-19  6:14 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-30  8:30 Kewen.Lin
2022-12-14 11:25 ` PING^1 " Kewen.Lin
2022-12-14 22:29 ` Segher Boessenkool
2022-12-19  6:13   ` Kewen.Lin [this message]
2022-12-20 13:19     ` Segher Boessenkool
2022-12-21  3:41       ` Kewen.Lin
2022-12-22 18:53         ` Segher Boessenkool
  -- strict thread matches above, loose matches on Subject: below --
2022-02-22  2:47 Kewen.Lin

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=bce16dfc-85db-511b-00a5-df81c67f198b@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=meissner@linux.ibm.com \
    --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).