[test-suite] r210658 - [PPC64LE] Fix Altivec 'test1.c' test to be endian-tolerant
Bill Schmidt
wschmidt at linux.vnet.ibm.com
Wed Jun 11 08:56:24 PDT 2014
Author: wschmidt
Date: Wed Jun 11 10:56:24 2014
New Revision: 210658
URL: http://llvm.org/viewvc/llvm-project?rev=210658&view=rev
Log:
[PPC64LE] Fix Altivec 'test1.c' test to be endian-tolerant
The test1.c test in the SingleSource/UnitTests/Vector/Altivec
directory makes use of the vec_sld interface. Unlike most of the
vector interfaces, vec_sld's behavior is not automatically modified
by the compiler for little endian. (A programmer might use it to
multiply by a power of 2, for example, in which case it should not be
changed.) Thus code using vec_sld must sometimes be modified when
porting to little endian. This patch replaces two of the vec_sld
calls with replacement code appropriate for little endian. A third
instance is correct for both big and little endian and doesn't need to
be modified. A fourth instance is dead code and therefore doesn't
need to be modified.
Modified:
test-suite/trunk/SingleSource/UnitTests/Vector/Altivec/test1.c
Modified: test-suite/trunk/SingleSource/UnitTests/Vector/Altivec/test1.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/UnitTests/Vector/Altivec/test1.c?rev=210658&r1=210657&r2=210658&view=diff
==============================================================================
--- test-suite/trunk/SingleSource/UnitTests/Vector/Altivec/test1.c (original)
+++ test-suite/trunk/SingleSource/UnitTests/Vector/Altivec/test1.c Wed Jun 11 10:56:24 2014
@@ -11,7 +11,12 @@ void func(vector float *arg){
vector float vres;
vector int vmask;
+#ifdef __LITTLE_ENDIAN__
+ vmask = vec_slo(vec_splat_s32(-1),
+ vec_splat_u8(12) * vec_splat_u8(8));
+#else
vmask = vec_sld(vec_splat_s32(0), vec_splat_s32(-1), 4);
+#endif
vi = vec_sel(vi, vzero, (vector unsigned int)vmask); /* (x, y, z, 0) */
vres = vec_madd(vi, vi, vzero); /* (x^2, y^2, z^2, 0) */
if(vec_all_eq(vres, vzero)) /* Is squared vec equal to the zero vec? */
@@ -21,7 +26,12 @@ void func(vector float *arg){
else
{
vector float vtmp;
+#ifdef __LITTLE_ENDIAN__
+ vtmp = vec_sld(vres, vres, 12); /* (y^2, z^2, 0, x^2) */
+ vtmp[3] = 0.0f; /* (y^2, z^2, 0, 0) */
+#else
vtmp = vec_sld(vres, vres, 4);
+#endif
vtmp = vec_add(vtmp, vres); /* (x^2 + y^2, y^2 + z^2, z^2, x^2) */
vtmp = vec_sld(vtmp, vtmp, 8); /* (z^2, x^2, x^2 + y^2, y^2 + z^2) */
vtmp = vec_add(vtmp, vres); /* (x^2 + z^2, x^2 + y^2, x^2 + y^2 + z^2, y^2 + z^2) */
More information about the llvm-commits
mailing list