CCTLib
Calling-context and data-object attribution library for Intel Pin
loadspy_repmovs_tp.c
Go to the documentation of this file.
1
// loadspy ISA test: rep movsq -- string-move that both loads and stores
2
// the same buffer over itself. Second iteration's loads are all redundant
3
// with the first iteration's writes (which just wrote the same values
4
// back).
5
#include <stdint.h>
6
#include <stddef.h>
7
#define N 512
8
static
volatile
uint64_t
sink
;
9
static
uint64_t
src
[
N
];
10
static
uint64_t
dst
[
N
];
11
int
main
(
int
argc,
char
** argv) {
12
(void)argc; (void)argv;
13
for
(
int
i = 0; i <
N
; ++i)
src
[i] = i;
14
for
(
int
iter = 0; iter < 100; ++iter) {
15
// First: copy src -> dst (loads from src, stores to dst)
16
__asm__ __volatile__(
17
"cld\n\t"
18
"rep movsq"
19
:
20
:
"S"
(
src
),
"D"
(
dst
),
"c"
((
size_t
)
N
)
21
:
"memory"
,
"cc"
);
22
// Second: same rep movsq -- reads the SAME src values again.
23
// Each load is redundant with the previous iteration's load.
24
__asm__ __volatile__(
25
"cld\n\t"
26
"rep movsq"
27
:
28
:
"S"
(
src
),
"D"
(
dst
),
"c"
((
size_t
)
N
)
29
:
"memory"
,
"cc"
);
30
}
31
sink
=
dst
[0];
32
return
0;
33
}
N
#define N
Definition:
loadspy_repmovs_tp.c:7
src
static uint64_t src[N]
Definition:
loadspy_repmovs_tp.c:9
main
int main(int argc, char **argv)
Definition:
loadspy_repmovs_tp.c:11
dst
static uint64_t dst[N]
Definition:
loadspy_repmovs_tp.c:10
sink
static volatile uint64_t sink
Definition:
loadspy_repmovs_tp.c:8
tests
gtest
apps
isa
loadspy_repmovs_tp.c
Generated on Wed Jul 15 2026 04:51:30 for CCTLib by
1.9.1