On Mon, Nov 20, 2023 at 08:01:45AM +0000, Richard Biener wrote:
> > On Fri, Nov 17, 2023 at 03:01:04PM +0100, Jakub Jelinek wrote:
> > > As a follow-up, I'm considering changing in this routine the popcount
> > > call to IFN_POPCOUNT with 2 arguments and during expansion test costs.
> > 
> > Here is the follow-up which does the rtx costs testing.
> > While having to tweak internal-fn.def so that POPCOUNT can have a custom
> > expand_POPCOUNT, I have noticed we are inconsistent, some DEF_INTERNAL*
> > macros (most of them) were undefined at the end of internal-fn.def (but in
> > some cases uselessly undefined again after inclusion), while others were not
> > (and sometimes undefined after the inclusion).  I've changed it to always
> > undefine at the end of internal-fn.def.
> 
> The last bit is cleanup that could go in independently.

Ok, I've committed the following patch first and the 2 patches adjusted on
top of that.  The 2 original ones were bootstrapped/regtested successfully
on x86_64-linux and i686-linux last night.

2023-11-20  Jakub Jelinek  <ja...@redhat.com>

        * internal-fn.def: Document missing DEF_INTERNAL* macros and make sure
        they are all undefined at the end.
        * internal-fn.cc (lookup_hilo_internal_fn, lookup_evenodd_internal_fn,
        widening_fn_p, get_len_internal_fn): Don't undef DEF_INTERNAL_*FN
        macros after inclusion of internal-fn.def.

--- gcc/internal-fn.def.jj      2023-11-17 15:51:02.642802521 +0100
+++ gcc/internal-fn.def 2023-11-18 10:12:10.329236626 +0100
@@ -33,9 +33,12 @@ along with GCC; see the file COPYING3.
      DEF_INTERNAL_SIGNED_OPTAB_FN (NAME, FLAGS, SELECTOR, SIGNED_OPTAB,
                                   UNSIGNED_OPTAB, TYPE)
      DEF_INTERNAL_FLT_FN (NAME, FLAGS, OPTAB, TYPE)
+     DEF_INTERNAL_FLT_FLOATN_FN (NAME, FLAGS, OPTAB, TYPE)
      DEF_INTERNAL_INT_FN (NAME, FLAGS, OPTAB, TYPE)
      DEF_INTERNAL_COND_FN (NAME, FLAGS, OPTAB, TYPE)
      DEF_INTERNAL_SIGNED_COND_FN (NAME, FLAGS, OPTAB, TYPE)
+     DEF_INTERNAL_WIDENING_OPTAB_FN (NAME, FLAGS, SELECTOR, SOPTAB, UOPTAB,
+                                    TYPE)
 
    where NAME is the name of the function, FLAGS is a set of
    ECF_* flags and FNSPEC is a string describing functions fnspec.
@@ -572,6 +585,9 @@ DEF_INTERNAL_FN (DIVMODBITINT, ECF_LEAF,
 DEF_INTERNAL_FN (FLOATTOBITINT, ECF_LEAF | ECF_NOTHROW, ". O . . ")
 DEF_INTERNAL_FN (BITINTTOFLOAT, ECF_PURE | ECF_LEAF, ". R . ")
 
+#undef DEF_INTERNAL_WIDENING_OPTAB_FN
+#undef DEF_INTERNAL_SIGNED_COND_FN
+#undef DEF_INTERNAL_COND_FN
 #undef DEF_INTERNAL_INT_FN
 #undef DEF_INTERNAL_FLT_FN
 #undef DEF_INTERNAL_FLT_FLOATN_FN
--- gcc/internal-fn.cc.jj       2023-11-07 08:32:01.741254155 +0100
+++ gcc/internal-fn.cc  2023-11-18 11:06:31.740703230 +0100
@@ -102,8 +102,6 @@ lookup_hilo_internal_fn (internal_fn ifn
     {
     default:
       gcc_unreachable ();
-#undef DEF_INTERNAL_FN
-#undef DEF_INTERNAL_WIDENING_OPTAB_FN
 #define DEF_INTERNAL_FN(NAME, FLAGS, TYPE)
 #define DEF_INTERNAL_WIDENING_OPTAB_FN(NAME, F, S, SO, UO, T)  \
     case IFN_##NAME:                                           \
@@ -111,8 +109,6 @@ lookup_hilo_internal_fn (internal_fn ifn
       *hi = internal_fn (IFN_##NAME##_HI);                     \
       break;
 #include "internal-fn.def"
-#undef DEF_INTERNAL_FN
-#undef DEF_INTERNAL_WIDENING_OPTAB_FN
     }
 }
 
@@ -129,8 +125,6 @@ lookup_evenodd_internal_fn (internal_fn
     {
     default:
       gcc_unreachable ();
-#undef DEF_INTERNAL_FN
-#undef DEF_INTERNAL_WIDENING_OPTAB_FN
 #define DEF_INTERNAL_FN(NAME, FLAGS, TYPE)
 #define DEF_INTERNAL_WIDENING_OPTAB_FN(NAME, F, S, SO, UO, T)  \
     case IFN_##NAME:                                           \
@@ -138,8 +132,6 @@ lookup_evenodd_internal_fn (internal_fn
       *odd = internal_fn (IFN_##NAME##_ODD);                   \
       break;
 #include "internal-fn.def"
-#undef DEF_INTERNAL_FN
-#undef DEF_INTERNAL_WIDENING_OPTAB_FN
     }
 }
 
@@ -4261,7 +4253,6 @@ widening_fn_p (code_helper code)
   internal_fn fn = as_internal_fn ((combined_fn) code);
   switch (fn)
     {
-    #undef DEF_INTERNAL_WIDENING_OPTAB_FN
     #define DEF_INTERNAL_WIDENING_OPTAB_FN(NAME, F, S, SO, UO, T) \
     case IFN_##NAME:                                             \
     case IFN_##NAME##_HI:                                        \
@@ -4270,7 +4261,6 @@ widening_fn_p (code_helper code)
     case IFN_##NAME##_ODD:                                       \
       return true;
     #include "internal-fn.def"
-    #undef DEF_INTERNAL_WIDENING_OPTAB_FN
 
     default:
       return false;
@@ -4305,8 +4296,6 @@ set_edom_supported_p (void)
     expand_##TYPE##_optab_fn (fn, stmt, which_optab);                  \
   }
 #include "internal-fn.def"
-#undef DEF_INTERNAL_OPTAB_FN
-#undef DEF_INTERNAL_SIGNED_OPTAB_FN
 
 /* Routines to expand each internal function, indexed by function number.
    Each routine has the prototype:
@@ -4465,8 +4454,6 @@ get_len_internal_fn (internal_fn fn)
 {
   switch (fn)
     {
-#undef DEF_INTERNAL_COND_FN
-#undef DEF_INTERNAL_SIGNED_COND_FN
 #define DEF_INTERNAL_COND_FN(NAME, ...)                                        
\
   case IFN_COND_##NAME:                                                        
\
     return IFN_COND_LEN_##NAME;
@@ -4474,8 +4461,6 @@ get_len_internal_fn (internal_fn fn)
   case IFN_COND_##NAME:                                                        
\
     return IFN_COND_LEN_##NAME;
 #include "internal-fn.def"
-#undef DEF_INTERNAL_COND_FN
-#undef DEF_INTERNAL_SIGNED_COND_FN
     default:
       return IFN_LAST;
     }


        Jakub

Reply via email to