* Inefficient use of 64-bit addresses in Clang
@ 2019-08-06 12:30 Agner Fog
2019-08-12 9:20 ` Mark Geisert
0 siblings, 1 reply; 4+ messages in thread
From: Agner Fog @ 2019-08-06 12:30 UTC (permalink / raw)
To: cygwin
Clang is using 64-bit absolute addresses when accessing static data in
64-bit mode. This is inefficient because it requires an extra 10-bytes
long instruction for loading an address into a register every time it
needs to access static data. All other compilers use relative addresses.
Example:
> #include <immintrin.h>
>
> __m128d test (__m128d a) {
> Â Â Â __m128d b = _mm_add_pd(a, _mm_set1_pd(1.5));
> Â Â Â __m128d c = _mm_mul_pd(b, _mm_set1_pd(2.5));
> Â Â Â return c;
> }
Assembly output:
> .LCPI0_0:
>    .quad   4609434218613702656    # double 1.5
>    .quad   4609434218613702656    # double 1.5
> .LCPI0_1:
>    .quad   4612811918334230528    # double 2.5
>    .quad   4612811918334230528    # double 2.5
> Â Â Â .text
>    .globl   _Z4testDv2_d
>    .p2align   4, 0x90
> _Z4testDv2_d:Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â # @_Z4testDv2_d
> # BB#0:
>    vmovapd   (%rcx), %xmm0
>    movabsq   $.LCPI0_0, %rax
>    vaddpd   (%rax), %xmm0, %xmm0
>    movabsq   $.LCPI0_1, %rax
>    vmulpd   (%rax), %xmm0, %xmm0
> Â Â Â retq
Linux Clang uses 32-bit relative addresses:
>    vaddpd   .LCPI0_0(%rip), %xmm0, %xmm0
>    vmulpd   .LCPI0_1(%rip), %xmm0, %xmm0
> Â Â Â retq
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Inefficient use of 64-bit addresses in Clang
2019-08-06 12:30 Inefficient use of 64-bit addresses in Clang Agner Fog
@ 2019-08-12 9:20 ` Mark Geisert
0 siblings, 0 replies; 4+ messages in thread
From: Mark Geisert @ 2019-08-12 9:20 UTC (permalink / raw)
To: cygwin
Agner Fog wrote:
> Clang is using 64-bit absolute addresses when accessing static data in 64-bit
> mode. This is inefficient because it requires an extra 10-bytes long instruction
> for loading an address into a register every time it needs to access static
> data. All other compilers use relative addresses.
>
> Example:
>
>> #include <immintrin.h>
>>
>> __m128d test (__m128d a) {
>> Â Â Â __m128d b = _mm_add_pd(a, _mm_set1_pd(1.5));
>> Â Â Â __m128d c = _mm_mul_pd(b, _mm_set1_pd(2.5));
>> Â Â Â return c;
>> }
>
> Assembly output:
>
>> .LCPI0_0:
>>    .quad   4609434218613702656    # double 1.5
>>    .quad   4609434218613702656    # double 1.5
>> .LCPI0_1:
>>    .quad   4612811918334230528    # double 2.5
>>    .quad   4612811918334230528    # double 2.5
>> Â Â Â .text
>>    .globl   _Z4testDv2_d
>>    .p2align   4, 0x90
>> _Z4testDv2_d:Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â # @_Z4testDv2_d
>> # BB#0:
>>    vmovapd   (%rcx), %xmm0
>>    movabsq   $.LCPI0_0, %rax
>>    vaddpd   (%rax), %xmm0, %xmm0
>>    movabsq   $.LCPI0_1, %rax
>>    vmulpd   (%rax), %xmm0, %xmm0
>> Â Â Â retq
>
> Linux Clang uses 32-bit relative addresses:
>
>>    vaddpd   .LCPI0_0(%rip), %xmm0, %xmm0
>>    vmulpd   .LCPI0_1(%rip), %xmm0, %xmm0
>> Â Â Â retq
This kind of bug report should probably go to the Clang bugtracker at
https://bugs.llvm.org . On that page you could enter "clang cygwin" in the
Quick Search field and see what known issues there are.
Clang is packaged for Cygwin by a very industrious and busy maintainer, but no
development on Clang is being done here (to my knowledge). So something like a
Cygwin packaging error that breaks Clang on Cygwin would be on-topic for this
list, but a problem at code generation level should go to the Clang developers.
..mark
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Inefficient use of 64-bit addresses in Clang
2019-08-12 9:45 ` falk.tannhauser
@ 2019-08-14 5:51 ` Agner Fog
0 siblings, 0 replies; 4+ messages in thread
From: Agner Fog @ 2019-08-14 5:51 UTC (permalink / raw)
To: cygwin
It's a difference in memory model.
clang 6.0.0 under ubuntu with --target=x86_64-pc-cygwin gives relative
addresses, unless you specify -mcmodel=large.
Cygwin clang with -mcmodel=small does the right thing: use relative
addresses.
The -mcmodel=small option appears to work differently for Linux and for
Windows targets. I cannot find any documentation of this difference. See:
https://bugs.llvm.org/show_bug.cgi?id=42983
On 12/08/2019 11.45, falk.tannhauser@free.fr wrote:
> References: <578eb489-9391-9009-82ad-676eeb4c1c92@agner.org>
> In-Reply-To: <578eb489-9391-9009-82ad-676eeb4c1c92@agner.org>
>
> Could the different behaviour between Cygwin and Linux simply be due to different Clang versions?
> The current version under Cygwin is 5.0.1, while the latest version available under Linux
> appears to be 8.0.1 .
>
> Falk
>
> --
> Problem reports: http://cygwin.com/problems.html
> FAQ: http://cygwin.com/faq/
> Documentation: http://cygwin.com/docs.html
> Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
>
>
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Inefficient use of 64-bit addresses in Clang
[not found] <1436640898.268382790.1565602671940.JavaMail.root@zimbra54-e10.priv.proxad.net>
@ 2019-08-12 9:45 ` falk.tannhauser
2019-08-14 5:51 ` Agner Fog
0 siblings, 1 reply; 4+ messages in thread
From: falk.tannhauser @ 2019-08-12 9:45 UTC (permalink / raw)
To: cygwin
References: <578eb489-9391-9009-82ad-676eeb4c1c92@agner.org>
In-Reply-To: <578eb489-9391-9009-82ad-676eeb4c1c92@agner.org>
Could the different behaviour between Cygwin and Linux simply be due to different Clang versions?
The current version under Cygwin is 5.0.1, while the latest version available under Linux
appears to be 8.0.1 .
Falk
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-08-14 5:51 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-06 12:30 Inefficient use of 64-bit addresses in Clang Agner Fog
2019-08-12 9:20 ` Mark Geisert
[not found] <1436640898.268382790.1565602671940.JavaMail.root@zimbra54-e10.priv.proxad.net>
2019-08-12 9:45 ` falk.tannhauser
2019-08-14 5:51 ` Agner Fog
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).