aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVikram S. Adve <vadve@cs.uiuc.edu>2002-03-24 13:22:04 +0000
committerVikram S. Adve <vadve@cs.uiuc.edu>2002-03-24 13:22:04 +0000
commit12bcf84e53417d784b22103bfaed8d5170245edd (patch)
tree3fd3100bea7215689f548fa2204436110e0fa525
parentdea73e5ca848da44f583ae66247c2d067947d7bb (diff)
Make test more rigorous. It was never reading the non-scalar variables
from memory! Also, separate the writing and reading routines. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1983 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--test/Transforms/DecomposeMultiDimRefs/mixedindices.c50
1 files changed, 30 insertions, 20 deletions
diff --git a/test/Transforms/DecomposeMultiDimRefs/mixedindices.c b/test/Transforms/DecomposeMultiDimRefs/mixedindices.c
index b2d2e11077..01a1588461 100644
--- a/test/Transforms/DecomposeMultiDimRefs/mixedindices.c
+++ b/test/Transforms/DecomposeMultiDimRefs/mixedindices.c
@@ -25,35 +25,42 @@ typedef struct Mixed_struct {
double
-InitializeMixed(Mixed_t* M, int base)
+AddMixed(Mixed_t* M)
{
double sum = 0;
int i, j;
+ for (i=0; i < 10; ++i)
+ sum += M->A[i];
+
+ for (i=0; i < 10; ++i)
+ for (j=0; j < 10; ++j)
+ sum += M->B[i][j];
+
for (i=0; i < 10; ++i) {
- int coord;
- coord = i + base;
- M->A[i] = coord;
- sum += coord;
+ sum += (double) M->F[i].c;
+ sum += M->F[i].x;
}
+ return sum;
+}
+
+void
+InitializeMixed(Mixed_t* M, int base)
+{
+ int i, j;
+
for (i=0; i < 10; ++i)
- for (j=0; j < 10; ++j) {
- int coord;
- coord = i*10 + j + base;
- M->B[i][j] = coord;
- sum += coord;
- }
+ M->A[i] = i + base;
+
+ for (i=0; i < 10; ++i)
+ for (j=0; j < 10; ++j)
+ M->B[i][j] = i*10 + j + base;
for (i=0; i < 10; ++i) {
- double ratio;
M->F[i].c = 'Q';
- ratio = i / 10 + base;
- M->F[i].x = ratio;
- sum += ratio;
+ M->F[i].x = i / 10 + base;
}
-
- return sum;
}
int
@@ -63,10 +70,13 @@ main(int argc, char** argv)
Mixed_t MA[4];
int i;
- printf("Sum(M) = %.2f\n", InitializeMixed(&M, 100));
+ InitializeMixed(&M, 100);
+ printf("Sum(M) = %.2f\n", AddMixed(&M));
- for (i=0; i < 4; i++)
- printf("Sum(MA[%d]) = %.2f\n", i, InitializeMixed(&MA[i], 400));
+ for (i=0; i < 4; i++) {
+ InitializeMixed(&MA[i], 100 * (i+2));
+ printf("Sum(MA[%d]) = %.2f\n", i, AddMixed(&MA[i]));
+ }
return 0;
}