CCTLib
Calling-context and data-object attribution library for Intel Pin
rvn_tp_repeated.c
Go to the documentation of this file.
1 // runtime_value_numbering victim: recompute the SAME arithmetic expression
2 // twice with the same operands. RVN should identify the second computation
3 // as producing the same value number as the first -- redundant.
4 //
5 // Inline asm keeps the compiler from folding the two operations into one.
6 #include <stdint.h>
7 
8 static volatile uint64_t sink;
9 
10 int main(int argc, char** argv) {
11  (void)argc; (void)argv;
12  uint64_t a = 0x1234, b = 0x5678;
13  uint64_t sum1 = 0, sum2 = 0;
14  for (int i = 0; i < 100000; ++i) {
15  // Two identical add-lea instructions on identical operands.
16  // rvn should notice sum2 comes out with the same value number as sum1.
17  __asm__ __volatile__ (
18  "leaq (%[a], %[b]), %[s1]\n\t"
19  "leaq (%[a], %[b]), %[s2]\n\t"
20  : [s1] "=r"(sum1), [s2] "=r"(sum2)
21  : [a] "r"(a), [b] "r"(b)
22  :
23  );
24  sink = sum1 + sum2;
25  }
26  return 0;
27 }
int main(int argc, char **argv)
static volatile uint64_t sink
int a[1000]
Definition: testArray.c:5