[llvm-commits] [test-suite] r91673 - /test-suite/trunk/SingleSource/Benchmarks/Misc/fp-convert.c

Evan Cheng evan.cheng at apple.com
Thu Dec 17 23:48:44 PST 2009


Author: evancheng
Date: Fri Dec 18 01:48:44 2009
New Revision: 91673

URL: http://llvm.org/viewvc/llvm-project?rev=91673&view=rev
Log:
Add a small test case to show the benefit of not folding load into cvtss2sd.

Added:
    test-suite/trunk/SingleSource/Benchmarks/Misc/fp-convert.c

Added: test-suite/trunk/SingleSource/Benchmarks/Misc/fp-convert.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Benchmarks/Misc/fp-convert.c?rev=91673&view=auto

==============================================================================
--- test-suite/trunk/SingleSource/Benchmarks/Misc/fp-convert.c (added)
+++ test-suite/trunk/SingleSource/Benchmarks/Misc/fp-convert.c Fri Dec 18 01:48:44 2009
@@ -0,0 +1,39 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+double loop(float *x, float *y, long length) {
+  long i;
+  double accumulator = 0.0;
+  for (i=0; i<length; ++i) {
+    accumulator += (double)x[i] * (double)y[i];
+  }
+  return accumulator;
+}
+
+int main(int argc, char *argv[]) {
+  int i, j;
+  float x[2048];
+  float y[2048];
+  double total = 0.0;
+  float a = 0.0f;
+  float b = 1.0f;
+    
+  for (i=0; i<500000; ++i) {
+    if (i % 10) {
+      a = 0.0f;
+      b = 1.0f;
+    } else {
+      a += 0.1f;
+      b += 0.2f;
+    }
+    for (j=0; j<2048; ++j) {
+      x[j] = a + (float)j;
+      y[j] = b + (float)j;
+    }
+    total += loop(x, y, 2048);
+  }
+  
+  printf("Total is %g\n", total);
+    
+  return 0;
+}





More information about the llvm-commits mailing list