patch: convert scalar literals to vector constants (PR/7277)

Aldy Hernandez aldyh@redhat.com
Tue Jun 3 21:38:00 GMT 2003


>> !       cst[0] = INTVAL (x);
>> !       cst[1] = 0;
>
> CONST_INT sign-extends.

How about:?

       if (INTVAL (x) < 0)
         cst[1] = (unsigned HOST_WIDE_INT) -1;

> Well, that works for integer vector modes.  What about
> fp vector modes?  And how about

Hadn't thought of that.  What do you suggest gets generated for this?:

	typedef int v __attribute__((mode(V2SF)));

	v null(void)
	{
   	return (v) 0x1234LL;
	}

Right now we are generating:

(const_vector:V2SF [
         (const_int 0 [0x0])
         (const_int 4660 [0x1234])
     ])

Which I'm not particularly fond of.  Perhaps:?

(const_vector:V2SF [
         (const_double 0 0)
         (const_double 0 0x1234)
     ])

> 	(v4sf)(v8hi)-1
>
> where this routine should be called twice, the second
> time to convert one vector mode to another?

Ok, I'm adding:

   if (VECTOR_MODE_P (mode) && CONSTANT_P (x)
 >>>   && GET_CODE (x) != CONST_VECTOR
     return convert_const_to_vector (mode, x);

...the code will drop through and convert_mode() below can handle 
vector conversions.

Aldy



More information about the Gcc-patches mailing list