This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: RFA: fix PR66726 regression for min/max/conversion combo from PR71016 patch


On Mon, Jul 1, 2019 at 1:22 PM Joern Wolfgang Rennecke
<joern.rennecke@riscy-ip.com> wrote:
>
> The heuristic introduced for PR71016 prevents recognizing a max / min
> combo like it is used for
> saturation when followed by a conversion.
> The attached patch refines the heuristic to allow this case. Regression
> tested on x86_64-pc-linux-gnu .

Few style nits:

                  if (!gsi_end_p (gsi))
-                   return NULL;
+                   {
+                     gimple *assign = gsi_stmt (gsi);
+                     if (gimple_code (assign) != GIMPLE_ASSIGN)
+                       return NULL;
                       if (gassign *assign = dyn_cast <gassign *>
(gsi_stmt (gsi)))
                         {
+                     tree lhs = gimple_assign_lhs (assign);
+                     enum tree_code ass_code = gimple_assign_rhs_code (assign);
+                     if (ass_code != MAX_EXPR && ass_code != MIN_EXPR)
+                       return NULL;
+                     gsi_prev_nondebug (&gsi);
+                     if (!gsi_end_p (gsi))
+                       return NULL;
                        }
                      else
                        return NULL;
+                   }

also please check that 'lhs' is equal to gimple_assing_rhs1 (arg0_def_stmt)
otherwise you'd also allow MIN/MAX unrelated to the conversion detected.

On x86 I see the MIN_EXPR is already detected by GENERIC folding,
I wonder if that is required or if we can handle the case without in one
phiopt pass invocation as well.

Otherwise looks good to me.
Thanks,
Richard.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]