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

            Bug ID: 125592
           Summary: conditional for BIT_IOR not removed on the gimple
                    level
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Keywords: missed-optimization, TREE
          Severity: enhancement
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
            Blocks: 85316
  Target Milestone: ---

Take:
```
int f(int t)
{
  int is_inf = t & 0x0040;
  t &= ~(0x0080 | 0x0100 | 0x0200);
  if (is_inf)
    t |= 0x0040;
  return t;
}

```

This should be just optimized to:
t &= ~(0x0080 | 0x0100 | 0x0200)
return t;
Which it is on the rtl level (on some targets, e.g. x86 and aarch64).

VRP knows the 0x40 is set in t_4.
>From evrp:
t_4     [irange] int [-2147483584, -897][64, 2147482751] MASK 0xfffffc3f VALUE
0x40
    <bb 3> :
    t_5 = t_4 | 64;

But it does not remove the BIT_IOR_EXPR here.


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85316
[Bug 85316] [meta-bug] VRP range propagation missed cases

Reply via email to