Commit 526ed6c2 by Ulrich Weigand Committed by Ulrich Weigand

divmovti4.c (union qword_UTItype): New data type.

	* config/spu/divmovti4.c (union qword_UTItype): New data type.
	(si_from_UTItype, si_to_UTItype): New functions.
	(__udivmodti4): Use them to implement type-punning.
	* config/spu/multi3.c (union qword_TItype): New data type.
	(si_from_TItype, si_to_TItype): New functions.
	(__multi3): Use them to implement type-punning.

From-SVN: r173029
parent c187d33c
2011-04-27 Ulrich Weigand <Ulrich.Weigand@de.ibm.com> 2011-04-27 Ulrich Weigand <Ulrich.Weigand@de.ibm.com>
* config/spu/divmovti4.c (union qword_UTItype): New data type.
(si_from_UTItype, si_to_UTItype): New functions.
(__udivmodti4): Use them to implement type-punning.
* config/spu/multi3.c (union qword_TItype): New data type.
(si_from_TItype, si_to_TItype): New functions.
(__multi3): Use them to implement type-punning.
2011-04-27 Ulrich Weigand <Ulrich.Weigand@de.ibm.com>
* config/spu/spu.c (spu_expand_epilogue): Do not emit barrier. * config/spu/spu.c (spu_expand_epilogue): Do not emit barrier.
2011-04-27 Jan Hubicka <jh@suse.cz> 2011-04-27 Jan Hubicka <jh@suse.cz>
......
...@@ -29,6 +29,28 @@ UTItype __udivti3 (UTItype u, UTItype v); ...@@ -29,6 +29,28 @@ UTItype __udivti3 (UTItype u, UTItype v);
UTItype __umodti3 (UTItype u, UTItype v); UTItype __umodti3 (UTItype u, UTItype v);
UTItype __udivmodti4 (UTItype u, UTItype v, UTItype *w); UTItype __udivmodti4 (UTItype u, UTItype v, UTItype *w);
union qword_UTItype
{
qword q;
UTItype t;
};
inline static qword
si_from_UTItype (UTItype t)
{
union qword_UTItype u;
u.t = t;
return u.q;
}
inline static UTItype
si_to_UTItype (qword q)
{
union qword_UTItype u;
u.q = q;
return u.t;
}
inline static unsigned int inline static unsigned int
count_leading_zeros (UTItype x) count_leading_zeros (UTItype x)
{ {
...@@ -67,8 +89,8 @@ __udivmodti4 (UTItype num, UTItype den, UTItype * rp) ...@@ -67,8 +89,8 @@ __udivmodti4 (UTItype num, UTItype den, UTItype * rp)
{ {
qword shift = qword shift =
si_from_uint (count_leading_zeros (den) - count_leading_zeros (num)); si_from_uint (count_leading_zeros (den) - count_leading_zeros (num));
qword n0 = *(qword *) & num; qword n0 = si_from_UTItype (num);
qword d0 = *(qword *) & den; qword d0 = si_from_UTItype (den);
qword bit = si_andi (si_fsmbi (1), 1); qword bit = si_andi (si_fsmbi (1), 1);
qword r0 = si_il (0); qword r0 = si_il (0);
qword m1 = si_fsmbi (0x000f); qword m1 = si_fsmbi (0x000f);
...@@ -101,8 +123,8 @@ __udivmodti4 (UTItype num, UTItype den, UTItype * rp) ...@@ -101,8 +123,8 @@ __udivmodti4 (UTItype num, UTItype den, UTItype * rp)
} }
while (si_to_uint (si_orx (bit))); while (si_to_uint (si_orx (bit)));
if (rp) if (rp)
*rp = *(UTItype *) & n0; *rp = si_to_UTItype (n0);
return *(UTItype *) & r0; return si_to_UTItype (r0);
} }
UTItype UTItype
......
...@@ -23,6 +23,28 @@ ...@@ -23,6 +23,28 @@
typedef int TItype __attribute__ ((mode (TI))); typedef int TItype __attribute__ ((mode (TI)));
union qword_TItype
{
qword q;
TItype t;
};
inline static qword
si_from_TItype (TItype t)
{
union qword_TItype u;
u.t = t;
return u.q;
}
inline static TItype
si_to_TItype (qword q)
{
union qword_TItype u;
u.q = q;
return u.t;
}
/* A straight forward vectorization and unrolling of /* A straight forward vectorization and unrolling of
* short l[8], r[8]; * short l[8], r[8];
* TItype total = 0; * TItype total = 0;
...@@ -33,8 +55,8 @@ typedef int TItype __attribute__ ((mode (TI))); ...@@ -33,8 +55,8 @@ typedef int TItype __attribute__ ((mode (TI)));
TItype TItype
__multi3 (TItype l, TItype r) __multi3 (TItype l, TItype r)
{ {
qword u = *(qword *) & l; qword u = si_from_TItype (l);
qword v = *(qword *) & r; qword v = si_from_TItype (r);
qword splat0 = si_shufb (v, v, si_ilh (0x0001)); qword splat0 = si_shufb (v, v, si_ilh (0x0001));
qword splat1 = si_shufb (v, v, si_ilh (0x0203)); qword splat1 = si_shufb (v, v, si_ilh (0x0203));
qword splat2 = si_shufb (v, v, si_ilh (0x0405)); qword splat2 = si_shufb (v, v, si_ilh (0x0405));
...@@ -93,5 +115,5 @@ __multi3 (TItype l, TItype r) ...@@ -93,5 +115,5 @@ __multi3 (TItype l, TItype r)
total = si_cgx (total10, carry, total); total = si_cgx (total10, carry, total);
total = si_shlqbyi (total, 4); total = si_shlqbyi (total, 4);
total = si_addx (total10, carry, total); total = si_addx (total10, carry, total);
return *(TItype *) & total; return si_to_TItype (total);
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment