This is the mail archive of the
mailing list for the GCC project.
Re: [RFA] [target/87369] Prefer "bit" over "bfxil"
On 12/7/18 10:31 AM, Richard Earnshaw (lists) wrote:
> On 07/12/2018 15:52, Jeff Law wrote:
>> As I suggested in the BZ, this patch rejects constants with just the
>> high bit set for the recently added "bfxil" pattern. As a result we'll
>> return to using "bit" for the test in the BZ.
>> I'm not versed enough in aarch64 performance tuning to know if "bit" is
>> actually a better choice than "bfxil". "bit" results in better code for
>> the testcase, but that seems more a function of register allocation than
>> "bit" being inherently better than "bfxil". Obviously someone with
>> more aarch64 knowledge needs to make a decision here.
>> My first iteration of the patch changed "aarch64_high_bits_all_ones_p".
>> We could still go that way too, though the name probably needs to change.
>> I've bootstrapped and regression tested on aarch64-linux-gnu and it
>> fixes the regression. I've also bootstrapped aarch64_be-linux-gnu, but
>> haven't done any kind of regression tested on that platform.
>> OK for the trunk?
> The problem here is that the optimum solution depends on the register
> classes involved and we don't know this during combine. If we have
> general register, then we want bfi/bfxil to be used; if we have a vector
> register, then bit is preferable as it changes 3 inter-bank register
> copies to a single inter-bank copy; and that copy might be hoisted out
> of a loop.
Ugh. Things are never simple, are they?
> Ultimately, the best solution here will probably depend on which we
> think is more likely, copysign or the example I give above.
I'd tend to suspect we'd see more pure integer bit twiddling than the
> It might be that for copysign we'll need to expand initially to some
> unspec that uses a register initialized with a suitable immediate, but
> otherwise hides the operation from combine until after that has run,
> thus preventing the compiler from doing the otherwise right thing. We'd
> lose in the (hopefully) rare case where the operands really were in
> general registers, but otherwise win for the more common case where they
Could we have the bfxil pattern have an alternative that accepts vector
regs and generates bit in appropriate circumstances?
Hmm, maybe the other way around would be better. Have the "bit"
pattern with a general register alternative that generates bfxil when
presented with general registers.
I would generally warn against hiding things in unspecs like you've
suggested above. We're seeing cases where that's been on in the x86
backend and it's inhibiting optimizations in various places.