[test-suite] r179113 - Fix accesses to uninitialized stack space in alti.isamax.c.

Bill Schmidt wschmidt at linux.vnet.ibm.com
Tue Apr 9 11:27:31 PDT 2013


Author: wschmidt
Date: Tue Apr  9 13:27:31 2013
New Revision: 179113

URL: http://llvm.org/viewvc/llvm-project?rev=179113&view=rev
Log:
Fix accesses to uninitialized stack space in alti.isamax.c.

Hal Finkel recently discovered this test could fail when stack pages
are not pre-initialized to zero.  We eventually traced it down to a
loop in the source that accessed values outside the initialized
portion of an array.  With that fixed, we found another problem in the
epilogue of the same loop that caused some elements of the array to be
wrongly ignored.  The test now passes.

Modified:
    test-suite/trunk/SingleSource/UnitTests/Vector/Altivec/alti.isamax.c

Modified: test-suite/trunk/SingleSource/UnitTests/Vector/Altivec/alti.isamax.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/UnitTests/Vector/Altivec/alti.isamax.c?rev=179113&r1=179112&r2=179113&view=diff
==============================================================================
--- test-suite/trunk/SingleSource/UnitTests/Vector/Altivec/alti.isamax.c (original)
+++ test-suite/trunk/SingleSource/UnitTests/Vector/Altivec/alti.isamax.c Tue Apr  9 13:27:31 2013
@@ -72,8 +72,8 @@ int isamax(int n, float *x)
      return(ibig);
   }
 // n >= NS case done with altivec 
-  nsegs = (n >> 2) - 1;
-  nres  = n - ((nsegs+1) << 2);    // nres = n mod 4
+  nsegs = (n >> 2) - 2;
+  nres = n & 3;                    // nres = n mod 4
   V2 = vec_add(V2,incr_4);         // increment next index
   xp = x;
   V0 = vec_ld(0,xp); xp += 4;      // first four 
@@ -87,7 +87,7 @@ int isamax(int n, float *x)
      V1 = vec_ld(0,xp); xp += 4;   // bottom load next 4
      V2 = vec_add(V2,incr_4);
   }
-  V1 = vec_ld(0,xp); xp += 4;  // bottom load next four
+  V1 = vec_abs(V1);
   V3 = vec_cmpgt(V1,V0);      // compare accumulated to last 4
   V0 = vec_sel(V0,V1,V3);     // select accumulation to last 4
   V7 = vec_sel(V7,V2,V3);     // select index of accum. to last 4





More information about the llvm-commits mailing list