[llvm-commits] [test-suite] r105418 - /test-suite/trunk/MultiSource/Benchmarks/VersaBench/bmm/bmm.c
Jakob Stoklund Olesen
stoklund at 2pi.dk
Thu Jun 3 14:50:54 PDT 2010
Author: stoklund
Date: Thu Jun 3 16:50:54 2010
New Revision: 105418
URL: http://llvm.org/viewvc/llvm-project?rev=105418&view=rev
Log:
Avoid undefined behaviour from signed overflows and shifts >= type size.
This makes ARM and X86 produce identical results.
Modified:
test-suite/trunk/MultiSource/Benchmarks/VersaBench/bmm/bmm.c
Modified: test-suite/trunk/MultiSource/Benchmarks/VersaBench/bmm/bmm.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/VersaBench/bmm/bmm.c?rev=105418&r1=105417&r2=105418&view=diff
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/VersaBench/bmm/bmm.c (original)
+++ test-suite/trunk/MultiSource/Benchmarks/VersaBench/bmm/bmm.c Thu Jun 3 16:50:54 2010
@@ -148,10 +148,10 @@
/* Use Linear congruential PRNG */
-int my_rand_r(int *seedp)
+unsigned my_rand_r(unsigned *seedp)
{
/* Knuth & Lewis */
- unsigned x = *seedp * 1664525 + 1013904223;
+ unsigned x = *seedp * 1664525u + 1013904223u;
*seedp = x;
return (x >> 16) & 0x7fff;
}
@@ -159,11 +159,11 @@
void init() {
int i,j;
- int random_seed = 1;
+ unsigned random_seed = 1;
for (i=0 ; i < SIZE ; i++) {
for (j=0 ; j < SIZE; j++) {
- a[i][j] = (my_rand_r(&random_seed) >> j-i) & 0xF;
- b[i][j] = (my_rand_r(&random_seed) << i+j) & 0xF;
+ a[i][j] = (my_rand_r(&random_seed) >> ((j-i) & 31)) & 0xF;
+ b[i][j] = (my_rand_r(&random_seed) << ((i+j) & 31)) & 0xF;
}
}
}
More information about the llvm-commits
mailing list