CCTLib
Calling-context and data-object attribution library for Intel Pin
redspy_scalar_sse_tp.c
Go to the documentation of this file.
1 // Redspy ISA edge case: scalar SSE movsd (double-precision scalar move).
2 // movsd writes 8 bytes; two identical movsd to same address is redundant.
3 // Different instruction encoding path from the general-purpose movq;
4 // exercises the SSE scalar path.
5 #include <stdint.h>
6 #define WORK_COUNT 10000
7 static volatile uint64_t sink;
8 static double buf[WORK_COUNT] __attribute__((aligned(16)));
9 int main(int argc, char** argv) {
10  (void)argc; (void)argv;
11  for (int i = 0; i < WORK_COUNT; ++i) {
12  // Load 3.14 into xmm0, store it twice via scalar movsd.
13  __asm__ __volatile__(
14  "movsd %[val], %%xmm0\n\t" // xmm0 = val
15  "movsd %%xmm0, (%[p])\n\t" // 8B write
16  "movsd %%xmm0, (%[p])\n\t" // 8B write same value -- redundant
17  :
18  : [val] "m"(buf[i]), [p] "r"(&buf[i])
19  : "memory", "xmm0");
20  }
21  sink = (uint64_t)buf[0];
22  return 0;
23 }
static uint64_t buf[ITERS]
#define WORK_COUNT
int main(int argc, char **argv)
static double buf[WORK_COUNT] __attribute__((aligned(16)))
static volatile uint64_t sink