diff options
author | Roger Sayle <roger@nextmovesoftware.com> | 2021-10-18 11:56:56 +0100 |
---|---|---|
committer | Roger Sayle <roger@nextmovesoftware.com> | 2021-10-18 11:59:31 +0100 |
commit | fecda57e60488d15a180b8dde02cf7a4d978ebc7 (patch) | |
tree | 6cc4448f52ee426ca22812800aa5f60414826d79 /gcc/gcov.c | |
parent | eb032893675afea4b01cc6ad06a3e0dcfe9b51cd (diff) | |
download | gcc-fecda57e60488d15a180b8dde02cf7a4d978ebc7.zip gcc-fecda57e60488d15a180b8dde02cf7a4d978ebc7.tar.gz gcc-fecda57e60488d15a180b8dde02cf7a4d978ebc7.tar.bz2 |
bfin: Popcount-related improvements to machine description.
Blackfin processors support a ONES instruction that implements a
32-bit popcount returning a 16-bit result. This instruction was
previously described by GCC's bfin backend using an UNSPEC, which
this patch changes to use a popcount:SI rtx thats capture its semantics,
allowing it to evaluated and simplified at compile-time. I've decided
to keep the instruction name the same (avoiding any changes to the
__builtin_bfin_ones machinery), but have provided popcountsi2 and
popcounthi2 expanders so that the middle-end can use this instruction
to implement __builtin_popcount (and __builtin_parity).
The new testcase ones.c
short foo ()
{
int t = 5;
short r = __builtin_bfin_ones(t);
return r;
}
previously generated:
_foo: nop;
nop;
R0 = 5 (X);
R0.L = ONES R0;
rts;
with this patch, now generates:
_foo: nop;
nop;
nop;
R0 = 2 (X);
rts;
The new testcase popcount.c
int foo(int x)
{
return __builtin_popcount(x);
}
previously generated:
_foo: [--SP] = RETS;
SP += -12;
call ___popcountsi2;
SP += 12;
RETS = [SP++];
rts;
now generates:
_foo: nop;
nop;
R0.L = ONES R0;
R0 = R0.L (Z);
rts;
And the new testcase parity.c
int foo(int x)
{
return __builtin_parity(x);
}
previously generated:
_foo: [--SP] = RETS;
SP += -12;
call ___paritysi2;
SP += 12;
RETS = [SP++];
rts;
now generates:
_foo: nop;
R1 = 1 (X);
R0.L = ONES R0;
R0 = R1 & R0;
rts;
2021-10-18 Roger Sayle <roger@nextmovesoftware.com>
gcc/ChangeLog
* config/bfin/bfin.md (define_constants): Remove UNSPEC_ONES.
(define_insn "ones"): Replace UNSPEC_ONES with a truncate of
a popcount, allowing compile-time evaluation/simplification.
(popcountsi2, popcounthi2): New expanders using a "ones" insn.
gcc/testsuite/ChangeLog
* gcc.target/bfin/ones.c: New test case.
* gcc.target/bfin/parity.c: New test case.
* gcc.target/bfin/popcount.c: New test case.
Diffstat (limited to 'gcc/gcov.c')
0 files changed, 0 insertions, 0 deletions