This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH]: all ones m128i constant


Uros, thanks for the suggestion. The attached is the revised patch.

Rebuild and testing done on linux i686.

Ok to checkin?

Thanks,

David

On Tue, Mar 31, 2009 at 3:28 AM, Uros Bizjak <ubizjak@gmail.com> wrote:
> Hello!
>
>> Hi, all one m128i constant can be materialized using pcmpeqd
>> instruction (compared with a memory load from rodata). This patch
>> implements this.
>>
>> Index: config/i386/i386.c
>> ===================================================================
>> --- config/i386/i386.c        (revision 145332)
>> +++ config/i386/i386.c        (working copy)
>> @@ -8951,7 +8951,8 @@ legitimate_constant_p (rtx x)
>>        break;
>>
>>      case CONST_VECTOR:
>> -      if (x == CONST0_RTX (GET_MODE (x)))
>> +      if (x == CONST0_RTX (GET_MODE (x))
>> +          || (vector_all_ones_operand (x, GET_MODE (x)) && TARGET_SSE))
>>       return true;
>>        return false;
>
> We can use standard_sse_constant_p function, this function will cover
> all supported constants in all supported modes.
>
>> Index: testsuite/gcc.dg/all_one_m128i.c
>> ===================================================================
>> --- testsuite/gcc.dg/all_one_m128i.c  (revision 0)
>> +++ testsuite/gcc.dg/all_one_m128i.c  (revision 0)
>
> Uh, there many problems with this testcase:
>
> - it belongs to gcc.target/i386 directory since it is clearly testing
> target-dependent feature.
> - it is in fact a compile testcase. Runtime testcases that depend on a
> non-default feature are a bit more complicated since they should check
> for supported processor features. Please see many examples in
> gcc.target/i386 directory.
>
> Attached to this message, please find a patch that implements all
> above suggestions. The include testcase checks just for the change
> that was added by the patch, so since it is a compile time feature,
> the testcase can be pretty short, without any runtime complications.
>
> Thanks,
> Uros.
>
Index: config/i386/i386.c
===================================================================
--- config/i386/i386.c	(revision 145364)
+++ config/i386/i386.c	(working copy)
@@ -8951,9 +8951,8 @@ legitimate_constant_p (rtx x)
       break;
 
     case CONST_VECTOR:
-      if (x == CONST0_RTX (GET_MODE (x)))
-	return true;
-      return false;
+      if (!standard_sse_constant_p (x))
+	return false;
 
     default:
       break;
Index: testsuite/gcc.target/i386/all_one_m128i.c
===================================================================
--- testsuite/gcc.target/i386/all_one_m128i.c	(revision 0)
+++ testsuite/gcc.target/i386/all_one_m128i.c	(revision 0)
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -msse2" } */
+
+typedef long long __m128i __attribute__ ((__vector_size__ (16)));
+typedef int __v4si __attribute__ ((__vector_size__ (16)));
+
+__attribute__ ((noinline)) __m128i
+foo ()
+{
+  __m128i minus_1 = (__m128i) (__v4si) { -1, -1, -1, -1 };
+
+  return minus_1;
+}
+
+/* { dg-final { scan-assembler "pcmpeqd" } } */

Attachment: cl5
Description: Binary data

Attachment: cl5
Description: Binary data


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]