diff options
author | Jakub Jelinek <jakub@redhat.com> | 2023-06-08 10:13:23 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2023-06-08 10:13:23 +0200 |
commit | fcbef8e431c246c1f584537a08d58fcd5c5a1831 (patch) | |
tree | 4a499fc25f8cc1c88e6c11b00b30b78eb3c6fc0f /gcc/range-op-float.cc | |
parent | 2b2bf793d3fb8980cb2b83e9e2a8c236ad2434f5 (diff) | |
download | gcc-fcbef8e431c246c1f584537a08d58fcd5c5a1831.zip gcc-fcbef8e431c246c1f584537a08d58fcd5c5a1831.tar.gz gcc-fcbef8e431c246c1f584537a08d58fcd5c5a1831.tar.bz2 |
optabs: Implement double-word ctz and ffs expansion
We have expand_doubleword_clz for a couple of years, where we emit
double-word CLZ as if (high_word == 0) return CLZ (low_word) + word_size;
else return CLZ (high_word);
We can do something similar for CTZ and FFS IMHO, just with the 2
words swapped. So if (low_word == 0) return CTZ (high_word) + word_size;
else return CTZ (low_word); for CTZ and
if (low_word == 0) { return high_word ? FFS (high_word) + word_size : 0;
else return FFS (low_word);
The following patch implements that.
Note, on some targets which implement both word_mode ctz and ffs patterns,
it might be better to incrementally implement those double-word ffs expansion
patterns in md files, because we aren't able to optimize it correctly;
nothing can detect we have just made sure that argument is not 0 and so
don't need to bother with handling that case. So, on ia32 just using
CTZ patterns would be better there, but I think we can even do better and
instead of doing the comparisons of the operands against 0 do the CTZ
expansion followed by testing of flags.
2023-06-08 Jakub Jelinek <jakub@redhat.com>
* optabs.cc (expand_ffs): Add forward declaration.
(expand_doubleword_clz): Rename to ...
(expand_doubleword_clz_ctz_ffs): ... this. Add UNOPTAB argument,
handle also doubleword CTZ and FFS in addition to CLZ.
(expand_unop): Adjust caller. Also call it for doubleword
ctz_optab and ffs_optab.
* gcc.target/i386/ctzll-1.c: New test.
* gcc.target/i386/ffsll-1.c: New test.
Diffstat (limited to 'gcc/range-op-float.cc')
0 files changed, 0 insertions, 0 deletions