CCTLib
Calling-context and data-object attribution library for Intel Pin
rvn_repeated_add.c
Go to the documentation of this file.
1 // RVN ISA test: repeated identical scalar ADD on same operands. The
2 // second addq should get the same value number as the first (both
3 // compute a+b for the same a, b).
4 #include <stdint.h>
5 static volatile uint64_t sink;
6 int main(int argc, char** argv) {
7  (void)argc; (void)argv;
8  uint64_t s = 0;
9  uint64_t a = 0x1234, b = 0x5678;
10  for (int i = 0; i < 100000; ++i) {
11  uint64_t r1, r2;
12  __asm__ __volatile__(
13  "movq %[a], %[r1]\n\t"
14  "addq %[b], %[r1]\n\t"
15  "movq %[a], %[r2]\n\t"
16  "addq %[b], %[r2]\n\t" // same value as r1 -- redundant
17  : [r1] "=&r"(r1), [r2] "=&r"(r2)
18  : [a] "r"(a), [b] "r"(b)
19  :
20  );
21  s += r1 + r2;
22  }
23  sink = s;
24  return 0;
25 }
int main(int argc, char **argv)
static volatile uint64_t sink
int a[1000]
Definition: testArray.c:5