Re: [PATCH, rs6000] enable early debug and disable switch for gimple folding

2017-08-09 Thread Will Schmidt
On Tue, 2017-08-08 at 17:31 -0500, Segher Boessenkool wrote:
> Hi!
> 
> On Tue, Aug 08, 2017 at 04:14:56PM -0500, Will Schmidt wrote:
> > * config/rs6000/rs6000.c: rs6000_option_override_internal() Add 
> > blurb
> > to indicate when early gimple folding has been disabled.
> 
>   * config/rs6000/rs6000.c (rs6000_option_override_internal): ...
> 
> 
> > rs6000_gimple_fold_builtin(): Add debug content.
> 
>   (rs6000_gimple_fold_builtin): ...
> 
> > @@ -16157,10 +16161,26 @@ rs6000_gimple_fold_builtin (gimple_stmt_iterator 
> > *gsi)
> >gcc_checking_assert (fndecl && DECL_BUILT_IN_CLASS (fndecl) == 
> > BUILT_IN_MD);
> >enum rs6000_builtins fn_code
> >  = (enum rs6000_builtins) DECL_FUNCTION_CODE (fndecl);
> >tree arg0, arg1, lhs;
> >  
> > +  size_t uns_fncode = (size_t)fn_code;
> 
> Space after cast.  More of this in the rest of the patch.
> 
> > +  if (TARGET_DEBUG_BUILTIN)
> > +  {
> > +  fprintf (stderr, "rs6000_gimple_fold_builtin %d %s %s \n",
> > +  fn_code,fn_name1,fn_name2);
> 
> No space before \n, space after commas.
> 
> > +  if (rs6000_gimple_folding_disable)
> > + return false;
> 
> One space indented too many there.
> 
> > diff --git a/gcc/config/rs6000/rs6000.opt b/gcc/config/rs6000/rs6000.opt
> > index e94aa07..4372b00 100644
> > --- a/gcc/config/rs6000/rs6000.opt
> > +++ b/gcc/config/rs6000/rs6000.opt
> > @@ -146,10 +146,14 @@ Generate AltiVec instructions using little-endian 
> > element order.
> >  
> >  maltivec=be
> >  Target Report RejectNegative Var(rs6000_altivec_element_order, 2)
> >  Generate AltiVec instructions using big-endian element order.
> >  
> > +mgimple-folding=off
> > +Target Report RejectNegative Var(rs6000_gimple_folding_disable, 1)
> > +Disable early gimple folding of builtins.
> 
> Please use -mgimple-folding instead, or better, -mfold-gimple, along
> with its no- variant?  So no RejectNegative.
> 
> It's probably easier to read if the internal var is the positive
> version, too?

Thanks for the review.  (v2) incoming momentarily. 


> 
> 
> Segher
> 




Re: [PATCH, rs6000] enable early debug and disable switch for gimple folding

2017-08-08 Thread Segher Boessenkool
Hi!

On Tue, Aug 08, 2017 at 04:14:56PM -0500, Will Schmidt wrote:
>   * config/rs6000/rs6000.c: rs6000_option_override_internal() Add blurb
>   to indicate when early gimple folding has been disabled.

* config/rs6000/rs6000.c (rs6000_option_override_internal): ...


>   rs6000_gimple_fold_builtin(): Add debug content.

(rs6000_gimple_fold_builtin): ...

> @@ -16157,10 +16161,26 @@ rs6000_gimple_fold_builtin (gimple_stmt_iterator 
> *gsi)
>gcc_checking_assert (fndecl && DECL_BUILT_IN_CLASS (fndecl) == 
> BUILT_IN_MD);
>enum rs6000_builtins fn_code
>  = (enum rs6000_builtins) DECL_FUNCTION_CODE (fndecl);
>tree arg0, arg1, lhs;
>  
> +  size_t uns_fncode = (size_t)fn_code;

Space after cast.  More of this in the rest of the patch.

> +  if (TARGET_DEBUG_BUILTIN)
> +  {
> +  fprintf (stderr, "rs6000_gimple_fold_builtin %d %s %s \n",
> +fn_code,fn_name1,fn_name2);

No space before \n, space after commas.

> +  if (rs6000_gimple_folding_disable)
> + return false;

One space indented too many there.

> diff --git a/gcc/config/rs6000/rs6000.opt b/gcc/config/rs6000/rs6000.opt
> index e94aa07..4372b00 100644
> --- a/gcc/config/rs6000/rs6000.opt
> +++ b/gcc/config/rs6000/rs6000.opt
> @@ -146,10 +146,14 @@ Generate AltiVec instructions using little-endian 
> element order.
>  
>  maltivec=be
>  Target Report RejectNegative Var(rs6000_altivec_element_order, 2)
>  Generate AltiVec instructions using big-endian element order.
>  
> +mgimple-folding=off
> +Target Report RejectNegative Var(rs6000_gimple_folding_disable, 1)
> +Disable early gimple folding of builtins.

Please use -mgimple-folding instead, or better, -mfold-gimple, along
with its no- variant?  So no RejectNegative.

It's probably easier to read if the internal var is the positive
version, too?


Segher


[PATCH, rs6000] enable early debug and disable switch for gimple folding

2017-08-08 Thread Will Schmidt
Hi, 

[PATCH, rs6000] enable early debug and disable switch for gimple folding

Enable debug options related to gimple folding for the rs6000 target.
Adds some output to the existing -mdebug=builtin option
Add a -mgimple-folding=off option to disable the early rs6000 gimple folding.

OK for trunk?

Thanks,
-Will


[gcc]

2017-08-08  Will Schmidt  

* config/rs6000/rs6000.c: rs6000_option_override_internal() Add blurb
to indicate when early gimple folding has been disabled.
rs6000_gimple_fold_builtin(): Add debug content.

diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index 1fb9861..0466fd0 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -4180,10 +4180,14 @@ rs6000_option_override_internal (bool global_init_p)
 {
   warning (0, N_("-maltivec=le not allowed for big-endian targets"));
   rs6000_altivec_element_order = 0;
 }
 
+  if (rs6000_gimple_folding_disable)
+ fprintf (stderr,
+ "gimple folding of rs6000 builtins has been disabled.\n");
+
   /* Add some warnings for VSX.  */
   if (TARGET_VSX)
 {
   const char *msg = NULL;
   if (!TARGET_HARD_FLOAT || !TARGET_SINGLE_FLOAT || !TARGET_DOUBLE_FLOAT)
@@ -16157,10 +16161,26 @@ rs6000_gimple_fold_builtin (gimple_stmt_iterator *gsi)
   gcc_checking_assert (fndecl && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_MD);
   enum rs6000_builtins fn_code
 = (enum rs6000_builtins) DECL_FUNCTION_CODE (fndecl);
   tree arg0, arg1, lhs;
 
+  size_t uns_fncode = (size_t)fn_code;
+  enum insn_code icode = rs6000_builtin_info[uns_fncode].icode;
+  const char *fn_name1 = rs6000_builtin_info[uns_fncode].name;
+  const char *fn_name2 = ((icode != CODE_FOR_nothing)
+ ? get_insn_name ((int)icode)
+ : "nothing");
+
+  if (TARGET_DEBUG_BUILTIN)
+  {
+  fprintf (stderr, "rs6000_gimple_fold_builtin %d %s %s \n",
+  fn_code,fn_name1,fn_name2);
+  }
+
+  if (rs6000_gimple_folding_disable)
+ return false;
+
   /* Generic solution to prevent gimple folding of code without a LHS.  */
   if (!gimple_call_lhs (stmt))
 return false;
 
   switch (fn_code)
@@ -16516,10 +16536,13 @@ rs6000_gimple_fold_builtin (gimple_stmt_iterator *gsi)
gsi_insert_seq_before (gsi, stmts, GSI_SAME_STMT);
update_call_from_tree (gsi, res);
return true;
   }
 default:
+   if (TARGET_DEBUG_BUILTIN)
+  fprintf (stderr, "gimple builtin intrinsic not matched:%d %s %s \n",
+  fn_code,fn_name1,fn_name2);
   break;
 }
 
   return false;
 }
diff --git a/gcc/config/rs6000/rs6000.opt b/gcc/config/rs6000/rs6000.opt
index e94aa07..4372b00 100644
--- a/gcc/config/rs6000/rs6000.opt
+++ b/gcc/config/rs6000/rs6000.opt
@@ -146,10 +146,14 @@ Generate AltiVec instructions using little-endian element 
order.
 
 maltivec=be
 Target Report RejectNegative Var(rs6000_altivec_element_order, 2)
 Generate AltiVec instructions using big-endian element order.
 
+mgimple-folding=off
+Target Report RejectNegative Var(rs6000_gimple_folding_disable, 1)
+Disable early gimple folding of builtins.
+
 mhard-dfp
 Target Report Mask(DFP) Var(rs6000_isa_flags)
 Use decimal floating point instructions.
 
 mmulhw