https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78335

            Bug ID: 78335
           Summary: Fold ~(1 << x) -> (~1 lrotate_expr x) on GIMPLE
           Product: gcc
           Version: 7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: prathamesh3492 at gcc dot gnu.org
  Target Milestone: ---

Hi,
It appears the following transform
~(1 << x) -> (~1 lrotate_expr x)
is done on RTL but not on GIMPLE.

Test-case:
int f(int x)
{
  int t1 = 1 << x;
  int t2 = ~t1;
  return t2;
}

optimized dump shows:

f (int x)
{
  int t2;
  int t1;

  <bb 2>:
  t1_2 = 1 << x_1(D);
  t2_3 = ~t1_2;
  return t2_3;

}

I suppose we want to do the transform on GENERIC/GIMPLE too (in match.pd) ?
Working on a patch.

Reply via email to