On Mon, 8 Jan 2024, Jeff Law wrote: > > > On 1/8/24 09:57, Andrew Pinski wrote: > > On Mon, Jan 8, 2024 at 6:44?AM Uros Bizjak <ubiz...@gmail.com> wrote: > >> > >> Instead of converting XOR or PLUS of two values, ANDed with two constants > >> that > >> have no bits in common, to IOR expression, convert IOR or XOR of said two > >> ANDed values to PLUS expression. > > > > I think this only helps targets which have leal like instruction. Also > > I think it is the same issue as I recorded as PR 111763 . I suspect > > BIT_IOR is more of a Canonical form for GIMPLE while we should handle > > this in expand to decide if we want to use PLUS or IOR. > Actually there's benefit on RISC-V to using PLUS over IOR/XOR when there's no > bits in common. In fact, I've been asked to do that by Andrew W. for a case > where we know ahead of time there's no bits in common in a sequence that > currently uses IOR. > > Specifically it can allow more use of the compact instructions as the compact > PLUS allows the full set of hard registers while compact IOR/XOR only allow a > subset of registers.
Still the benefit of IOR is no undefined overflow issues and thus better re-association (on GIMPLE). Of course in the end what is better "depends", but when "depends" depends on what the target can do better it's indeed better to leave that to either RTL expansion or instruction selection. Richard.