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

            Bug ID: 117821
           Summary: ~(unsigned smaller type)var_type, the ~ should prop
                    over the truncation (nop too)
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: pinskia at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
  Target Milestone: ---

Take:
```
unsigned char f1(unsigned int a)
{
  unsigned char t = a;
  t = ~t;
  return t;
}

unsigned char f2(unsigned int a)
{
  a = ~a;
  unsigned char t = a;
  return t;
}

int g(unsigned int t)
{
  return f1(t) == f2(t);
}
unsigned char f1_ior(unsigned int a)
{
  unsigned char t = a;
  t = t|1;
  return t;
}

unsigned char f2_ior(unsigned int a)
{
  a = a|1;
  unsigned char t = a;
  return t;
}

int g_ior(unsigned int t)
{
  return f1_ior(t) == f2_ior(t);
}
unsigned int h1(int a)
{
  unsigned int t = a;
  t = ~t;
  return t;
}

unsigned int h2(int a)
{
  a = ~a;
  unsigned int t = a;
  return t;
}

int h(int t)
{
  return (h1(t) + h2(t)) == h1(t)*2;
}
```

Reply via email to