svn commit: r363773 - projects/clang1100-import/contrib/llvm-project/compiler-rt/lib/builtins

Dimitry Andric dim at FreeBSD.org
Mon Aug 3 17:19:41 UTC 2020


On 3 Aug 2020, at 19:05, Jessica Clarke <jrtc27 at FreeBSD.org> wrote:
> 
> On 3 Aug 2020, at 17:50, Dimitry Andric <dim at FreeBSD.org> wrote:
>> 
>> On 2 Aug 2020, at 22:50, Jessica Clarke <jrtc27 at FreeBSD.org> wrote:
...
>> There are indeed quite a lot of calls to __builtin_c[lt]z throughout
>> compiler-rt, so removing this workaround from the int_lib.h header
>> will possibly pessimize all of those. Is that going to work alright for
>> all affected architectures, which appear to be mips64, riscv and
>> sparc64?
> 
> I don't think it matters much. __clzdi2 is this (the preprocessed
> version of which you provided):
> 
>  dwords x;
>  x.all = a;
>  const si_int f = -(x.s.high == 0);
>  return __builtin_clz((x.s.high & ~f) | (x.s.low & f)) +
>         (f & ((si_int)(sizeof(si_int) * CHAR_BIT)));
> 
> The implementation of __clzsi2 does a bunch more work than that (not
> crazy, but still several times more), so I don't think you'll notice
> all that much. Besides, Clang is our primary compiler and won't suffer
> from this workaround, so I personally have no qualms about a small
> performance hit when using GCC and what should be a relatively cold[1]
> function. I'm of the view we should be as close to upstream as
> possible, ideally with zero diffs, so personally wouldn't carry patches
> like this unless it had a noticeable affect on system performance, but
> even then would encourage others to patch it upstream first and
> foremost.

Yeah, less patches is always OK, so I'll drop this particular one, then.

Thanks for the feedback!

-Dimitry

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 223 bytes
Desc: Message signed with OpenPGP
URL: <http://lists.freebsd.org/pipermail/svn-src-projects/attachments/20200803/1d99c4cd/attachment.sig>


More information about the svn-src-projects mailing list