On Sun, May 19, 2024 at 10:58 AM Jeff Law <j...@ventanamicro.com> wrote:
>
> perl has some internal bitmap code.  One of its implementation
> properties is that if you ask it to set a bit, the bit is first cleared.
>
>
> Unfortunately this is fairly hard to see in gimple/match due to type
> changes in the IL.  But it is easy to see in the code we get from
> combine.  So we just match the relevant cases.


So looking into this from a gimple point of view, we can see the issue
on x86_64 if you used explicitly `unsigned char`.
We have:
```
  c_8 = (unsigned char) _1;
  _2 = *a_10(D);
  c.0_3 = (signed char) _1;
  _4 = ~c.0_3;
  _12 = (unsigned char) _4;
``
So for this, we could push the no_op cast from `signed char` to
`unsigned char` past the `bit_not` and I think it will fix the issue
on the gimple level.
So something like:
```
/* Push no_op conversion past the bit_not expression if it was single use. */
(simplify
 (convert (bit_not:s @0))
 (if (tree_nop_conversion_p (type, TREE_TYPE (@0)))
  (bit_not (convert @0))))
```

Thanks,
Andrew Pinski

>
>
>
> Regression tested in Ventana's CI system as well as my own.  Waiting on
> the Rivos CI system before moving forward.
>
>
>
> Jeff

Reply via email to