Fix PR target/42881 (vec_init_dupl miscompiles)
H.J. Lu
hjl.tools@gmail.com
Thu Jan 28 23:22:00 GMT 2010
On Thu, Jan 28, 2010 at 10:08 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Wed, Jan 27, 2010 at 9:30 AM, Michael Matz <matz@suse.de> wrote:
>> Hi,
>>
>> ix86_expand_vector_init_duplicate sometimes tries to force an operand into
>> registers, after the instuction using the operand is already emitted,
>> resulting in he above PR. This is the obvious fix for it. Okay for
>> trunk if regstrapping on x86_64-linux passes?
>>
>>
>> Ciao,
>> Michael.
>> --
>> PR target/42881
>> * config/i386/i386.c (ix86_expand_vector_init_duplicate):
>> Wrap force_reg into a sequence, emit it before user.
>>
>> testsuite/
>> * gcc.target/i386/pr42881.c: New test.
>>
>> Index: config/i386/i386.c
>> ===================================================================
>> --- config/i386/i386.c (revision 156295)
>> +++ config/i386/i386.c (working copy)
>> @@ -26644,8 +26644,16 @@ ix86_expand_vector_init_duplicate (bool
>> insn = emit_insn (gen_rtx_SET (VOIDmode, target, dup));
>> if (recog_memoized (insn) < 0)
>> {
>> + rtx seq;
>> /* If that fails, force VAL into a register. */
>> +
>> + start_sequence ();
>> XEXP (dup, 0) = force_reg (GET_MODE_INNER (mode), val);
>> + seq = get_insns ();
>> + end_sequence ();
>> + if (seq)
>> + emit_insn_before (seq, insn);
>> +
>> ok = recog_memoized (insn) >= 0;
>> gcc_assert (ok);
>> }
>> Index: testsuite/gcc.target/i386/pr42881.c
>> ===================================================================
>> --- testsuite/gcc.target/i386/pr42881.c (revision 0)
>> +++ testsuite/gcc.target/i386/pr42881.c (revision 0)
>> @@ -0,0 +1,14 @@
>> +/* PR target/42881 */
>> +/* { dg-do run } */
>> +/* { dg-options "-O0 -msse" } */
>> +#include "sse-check.h"
>> +#include <xmmintrin.h>
>> +static void
>> +sse_test (void)
>> +{
>> + double a[2];
>> + __m128d x = _mm_set1_pd(3);
>> + _mm_storeu_pd(a,x);
>> + if (a[0] != 3.0 || a[1] != 3.0)
>> + __builtin_abort ();
>> +}
>>
>
> You need -msse2 for __m128d. You don't need to include <xmmintrin.h>
> since "sse-check.h" does it if -msse2 iss used.
>
>
I checked in this patch as an obvious fix.
--
H.J.
---
Index: gcc.target/i386/pr42881.c
===================================================================
--- gcc.target/i386/pr42881.c (revision 156332)
+++ gcc.target/i386/pr42881.c (working copy)
@@ -1,10 +1,9 @@
/* PR target/42881 */
/* { dg-do run } */
-/* { dg-options "-O0 -msse" } */
-#include "sse-check.h"
-#include <xmmintrin.h>
+/* { dg-options "-O0 -msse2" } */
+#include "sse2-check.h"
static void
-sse_test (void)
+sse2_test (void)
{
double a[2];
__m128d x = _mm_set1_pd(3);
Index: ChangeLog
===================================================================
--- ChangeLog (revision 156332)
+++ ChangeLog (working copy)
@@ -1,3 +1,7 @@
+2010-01-28 H.J. Lu <hongjiu.lu@intel.com>
+
+ * gcc.target/i386/pr42881.c: Use SSE2.
+
2010-01-28 Uros Bizjak <ubizjak@gmail.com>
PR target/42891
More information about the Gcc-patches
mailing list