* Fwd: Help to understand instructions
[not found] ` <CAJCbrz6n6V2OaXhJ+mRwsMZEwoyLGqV-znufOAKir78tcK_QWg@mail.gmail.com>
@ 2012-11-07 12:49 ` Sergey Ivanov
2012-11-07 19:24 ` Kalle Olavi Niemitalo
0 siblings, 1 reply; 2+ messages in thread
From: Sergey Ivanov @ 2012-11-07 12:49 UTC (permalink / raw)
To: gcc-help
Have compiled program with -g O3 together.
Now learn it output via objdump (with code mixed format) and see
(sorry for rather long one, just environment for question):
..........
inline void Box::MinCoordDistance(double &r, const int i) const
{
if (r >= halfL[i])
41f06d: f2 0f 10 48 38 movsd xmm1,QWORD PTR [rax+0x38]
*/
inline double Box::distanceSq(const Vec r1, const Vec r2, Vec dr) const
{
for (int i = 0; i < 3; i++)
{
dr[i] = r1[i] - r2[i];
41f072: f2 41 0f 5c 40 10 subsd xmm0,QWORD PTR [r8+0x10]
return distanceSq(r1, r2, dr);
}
inline void Box::MinCoordDistance(double &r, const int i) const
{
if (r >= halfL[i])
41f078: 66 0f 2e c1 ucomisd xmm0,xmm1
*/
inline double Box::distanceSq(const Vec r1, const Vec r2, Vec dr) const
{
for (int i = 0; i < 3; i++)
{
dr[i] = r1[i] - r2[i];
41f07c: f2 0f 11 44 24 18 movsd QWORD PTR [rsp+0x18],xmm0
return distanceSq(r1, r2, dr);
}
inline void Box::MinCoordDistance(double &r, const int i) const
{
if (r >= halfL[i])
41f082: 0f 83 50 01 00 00 jae 41f1d8
<CbDoubleBridgeBase<EnsembleNVT,
Homopolymer>::scanBridgingForwardOne(int)+0x258>
r -= L[i];
else if (r < -halfL[i])
41f088: f2 0f 10 15 90 55 02 movsd xmm2,QWORD PTR
[rip+0x25590] # 444620 <typeinfo name for
SpeciesDependedMove<GeneralPolymerChain>+0x80> <<<<<<<<<<<<<<<question
is here
41f08f: 00
41f090: 66 0f 57 ca xorpd xmm1,xmm2
41f094: 66 0f 2e c8 ucomisd xmm1,xmm0
41f098: 76 0b jbe 41f0a5
<CbDoubleBridgeBase<EnsembleNVT,
Homopolymer>::scanBridgingForwardOne(int)+0x125>
r += L[i];
41f09a: f2 0f 58 40 20 addsd xmm0,QWORD PTR [rax+0x20]
41f09f: f2 0f 11 44 24 18 movsd QWORD PTR [rsp+0x18],xmm0
*/
inline double Box::distanceSq(const Vec r1, const Vec r2, Vec dr) const
{
for (int i = 0; i < 3; i++)
{
dr[i] = r1[i] - r2[i];
41f0a5: f2 0f 10 47 18 movsd xmm0,QWORD PTR [rdi+0x18]
return distanceSq(r1, r2, dr);
}
inline void Box::MinCoordDistance(double &r, const int i) const
{
if (r >= halfL[i])
41f0aa: f2 0f 10 48 40 movsd xmm1,QWORD PTR [rax+0x40]
*/
inline double Box::distanceSq(const Vec r1, const Vec r2, Vec dr) const
{
for (int i = 0; i < 3; i++)
{
dr[i] = r1[i] - r2[i];
41f0af: f2 41 0f 5c 40 18 subsd xmm0,QWORD PTR [r8+0x18]
return distanceSq(r1, r2, dr);
}
.................
What implicit addressation via rip means? Is it kind of protection or
is it bug of objdump?
--
Kind regards,
Sergey Ivanov
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Fwd: Help to understand instructions
2012-11-07 12:49 ` Fwd: Help to understand instructions Sergey Ivanov
@ 2012-11-07 19:24 ` Kalle Olavi Niemitalo
0 siblings, 0 replies; 2+ messages in thread
From: Kalle Olavi Niemitalo @ 2012-11-07 19:24 UTC (permalink / raw)
To: Sergey Ivanov; +Cc: gcc-help
Sergey Ivanov <icegood1980@gmail.com> writes:
> else if (r < -halfL[i])
> 41f088: f2 0f 10 15 90 55 02 movsd xmm2,QWORD PTR
> [rip+0x25590] # 444620 <typeinfo name for
> SpeciesDependedMove<GeneralPolymerChain>+0x80> <<<<<<<<<<<<<<<question
> is here
[...]
> What implicit addressation via rip means? Is it kind of protection or
> is it bug of objdump?
It just loads some constant from memory. I suppose the compiler
did not emit a name for the constant in the debug information, so
objdump displays the nearest preceding symbol, which happens to be
typeinfo name for SpeciesDependedMove<GeneralPolymerChain>.
Somewhat reproduced like this:
#include <typeinfo>
struct Box
{
double L[4];
double halfL[4];
void MinCoordDistance(double &r, const int i) const;
};
const std::type_info &dummy = typeid(Box);
void Box::MinCoordDistance(double &r, const int i) const
{
if (r >= halfL[i])
r -= L[i];
else if (r < -halfL[i])
r += L[i];
}
Compiling this with g++ (Debian 4.7.1-7) 4.7.1, options -m64 -O3 -g -S:
.file "xmm.c"
.text
.Ltext0:
.align 2
.p2align 4,,15
.globl _ZNK3Box16MinCoordDistanceERdi
.type _ZNK3Box16MinCoordDistanceERdi, @function
_ZNK3Box16MinCoordDistanceERdi:
.LFB19:
.file 1 "xmm.c"
.loc 1 13 0
.cfi_startproc
.LVL0:
.loc 1 14 0
movslq %edx, %rdx
movsd (%rsi), %xmm0
movsd 32(%rdi,%rdx,8), %xmm1
ucomisd %xmm1, %xmm0
jae .L10
.loc 1 16 0
movsd .LC0(%rip), %xmm2 <<<<<<<<<<<<<<<question is here
xorpd %xmm2, %xmm1
ucomisd %xmm0, %xmm1
jbe .L1
.loc 1 17 0
addsd (%rdi,%rdx,8), %xmm0
movsd %xmm0, (%rsi)
.L1:
rep
ret
.p2align 4,,10
.p2align 3
.L10:
.loc 1 15 0
subsd (%rdi,%rdx,8), %xmm0
movsd %xmm0, (%rsi)
ret
.cfi_endproc
.LFE19:
.size _ZNK3Box16MinCoordDistanceERdi, .-_ZNK3Box16MinCoordDistanceERdi
.globl dummy
.section .rodata
.align 8
.type dummy, @object
.size dummy, 8
dummy:
.quad _ZTI3Box
.weak _ZTI3Box
.section .rodata._ZTI3Box,"aG",@progbits,_ZTI3Box,comdat
.align 16
.type _ZTI3Box, @object
.size _ZTI3Box, 16
_ZTI3Box:
.quad _ZTVN10__cxxabiv117__class_type_infoE+16
.quad _ZTS3Box
.weak _ZTS3Box
.section .rodata._ZTS3Box,"aG",@progbits,_ZTS3Box,comdat
.type _ZTS3Box, @object
.size _ZTS3Box, 5
_ZTS3Box:
.string "3Box"
.section .rodata.cst16,"aM",@progbits,16
.align 16
.LC0:
.long 0
.long -2147483648
.long 0
.long 0
.text
... the rest omitted for brevity.
The "movsd .LC0(%rip), %xmm2" instruction loads a value from
.LC0, which is in the rodata.cst16 section and is thus a constant.
It looks like this constant is double[2] { -0.0, 0.0 } and the
function computes -halfL[i] by toggling the sign bit with xor.
The debug information in the assembly file does not refer to .LC0.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-11-07 19:24 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <CAJCbrz5L5YabB5BEeS4gi-ybbZxNqggKqTknTaeU6SswM5hz0Q@mail.gmail.com>
[not found] ` <CAJCbrz6n6V2OaXhJ+mRwsMZEwoyLGqV-znufOAKir78tcK_QWg@mail.gmail.com>
2012-11-07 12:49 ` Fwd: Help to understand instructions Sergey Ivanov
2012-11-07 19:24 ` Kalle Olavi Niemitalo
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).