On Wed, 9 Aug 2023, Jakub Jelinek wrote: > On Wed, Aug 09, 2023 at 01:06:22PM -0700, Andrew Pinski wrote: > > That was my next thought, returning NULL from > > single_non_singleton_phi_for_edges if it would return a virtual OP > > might be better even. > > Either version of these patches are ok with me (though I am not the > > maintainer here). > > In patch form that would be (but so far untested):
LGTM > 2023-08-09 <ja...@redhat.com> > > PR c/102989 > * tree-ssa-phiopt.cc (single_non_singleton_phi_for_edges): Never > return virtual phis and return NULL if there is a virtual phi > where the arguments from E0 and E1 edges aren't equal. > > --- gcc/tree-ssa-phiopt.cc.jj 2023-08-09 22:08:07.974563266 +0200 > +++ gcc/tree-ssa-phiopt.cc 2023-08-09 22:11:37.291517911 +0200 > @@ -63,7 +63,13 @@ single_non_singleton_phi_for_edges (gimp > gimple_stmt_iterator i; > gphi *phi = NULL; > if (gimple_seq_singleton_p (seq)) > - return as_a <gphi *> (gsi_stmt (gsi_start (seq))); > + { > + phi = as_a <gphi *> (gsi_stmt (gsi_start (seq))); > + /* Never return virtual phis. */ > + if (virtual_operand_p (gimple_phi_result (phi))) > + return NULL; > + return phi; > + } > for (i = gsi_start (seq); !gsi_end_p (i); gsi_next (&i)) > { > gphi *p = as_a <gphi *> (gsi_stmt (i)); > @@ -72,6 +78,10 @@ single_non_singleton_phi_for_edges (gimp > gimple_phi_arg_def (p, e1->dest_idx))) > continue; > > + /* Punt on virtual phis with different arguments from the edges. */ > + if (virtual_operand_p (gimple_phi_result (p))) > + return NULL; > + > /* If we already have a PHI that has the two edge arguments are > different, then return it is not a singleton for these PHIs. */ > if (phi) > > > Jakub > > -- Richard Biener <rguent...@suse.de> SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg, Germany; GF: Ivo Totev, Andrew McDonald, Werner Knoblich; (HRB 36809, AG Nuernberg)