On Tue, Apr 28, 2020 at 11:16:13AM +0200, Richard Biener wrote:
> I think we generally want to use :s, but OTOH even for your new case,
> since you restrict to nop-conversions, :s isn't strictly needed since
> VN should know how to materialize nop-converted variants.  I think
> it's different for the 2nd case you add since there we deal with
> bitops in different sign.
> 
> So maybe just remove the single_use () calls?

I've tried doing that, but that regresses e.g.
void bar (unsigned int, unsigned int);

unsigned int
foo (int x, int y)
{
  unsigned int x2 = x;
  unsigned int y2 = y;
  bar (x2, y2);
  return x2 | y2;
}

@@ -6,12 +6,14 @@ foo (int x, int y)
   unsigned int y2;
   unsigned int x2;
   unsigned int _7;
+  int _8;
 
   <bb 2> [local count: 1073741824]:
   x2_2 = (unsigned int) x_1(D);
   y2_4 = (unsigned int) y_3(D);
   bar (x2_2, y2_4);
-  _7 = x2_2 | y2_4;
+  _8 = x_1(D) | y_3(D);
+  _7 = (unsigned int) _8;
   return _7;
 
 }

As the patch was meant purely as an IL size optimization, that is not the
case here.

> > Or should I e.g. move this GIMPLE rule as a separate simplify (under the
> > same for) and then use :s in there?
> 
> That wouldn't work, if a structural pattern matched others are not
> considered so it wouldn't ever be used.  genmatch even warns for this
> I think.

Ah, ok.

        Jakub

Reply via email to