On 5/19/24 1:59 PM, Andrew Pinski wrote:
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))))
I'm not sure where the best place to put the conversion would be in
gimple. I bet there's times when we want the conversion at the outer
level and others times at the inner level. Just not sure it's going to
be clear cut with either solution likely causing regressions somewhere.
What we can (and probably should) do is put this simplification into
simplify-rtx. It's target independent and shouldn't be hard to capture
there.
Jeff