diff mbox series

[rs6000] Change word selector to prefered location for vec_insert builtin

Message ID 1529677967.7264.8.camel@us.ibm.com
State New
Headers show
Series [rs6000] Change word selector to prefered location for vec_insert builtin | expand

Commit Message

Carl Love June 22, 2018, 2:32 p.m. UTC
GCC Maintainers:

The following patch changes the word selected when extracting the word
from the second vector to insert into the first vector by the
vec_insert() builtin.  

Specifically, the test case

vector float                                                                    
fn2 (float a, vector float b)                                                   
{                                                                               
  return vec_insert (a, b, 1);                                                  
}   

without the patch  generates the code sequence 

     xscvdpspn vs0,vs1
     xxextractuw vs0,vs0,4            
     xxinsertw vs34,vs0,8

The xscvdpspn places the extracted word into words 0 and 1 of the
destination.  The xxextractuw extracts word 1 (offset of 4 bytes)from
the source.  The patch changes the offset so that the xxexractuw will
extract word 0 (offset 0 bytes) instead of word 1.  The values are the
same so there is no functional change. But it was decided that using
word 0 was preferred choice.

                 Carl Love

-----------------------------------------------------

gcc/ChangeLog:

2018-06-19  Carl Love  <cel@us.ibm.com>

	* config/rs6000/vsx.md: Change word selector to prefered location.

Signed-off-by: Carl Love <cel@us.ibm.com>
---
 gcc/config/rs6000/vsx.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Segher Boessenkool June 23, 2018, 12:56 a.m. UTC | #1
Hi Carl,

On Fri, Jun 22, 2018 at 07:32:47AM -0700, Carl Love wrote:
> The following patch changes the word selected when extracting the word
> from the second vector to insert into the first vector by the
> vec_insert() builtin.
> 
> Specifically, the test case
> 
> vector float
> fn2 (float a, vector float b)
> {
>   return vec_insert (a, b, 1);
> }
> 
> without the patch  generates the code sequence 
> 
>      xscvdpspn vs0,vs1
>      xxextractuw vs0,vs0,4            
>      xxinsertw vs34,vs0,8

[ For -mcpu=power9 -mlittle ]

Is this from something in the testsuite?  I can't find it.

> The xscvdpspn places the extracted word into words 0 and 1 of the
> destination.  The xxextractuw extracts word 1 (offset of 4 bytes)from
> the source.  The patch changes the offset so that the xxexractuw will
> extract word 0 (offset 0 bytes) instead of word 1.  The values are the
> same so there is no functional change. But it was decided that using
> word 0 was preferred choice.

The patch looks fine.  Okay for trunk.  Thanks!


Segher
Bill Schmidt June 25, 2018, 1:25 p.m. UTC | #2
> On Jun 22, 2018, at 7:56 PM, Segher Boessenkool <segher@kernel.crashing.org> wrote:
> 
> Hi Carl,
> 
> On Fri, Jun 22, 2018 at 07:32:47AM -0700, Carl Love wrote:
>> The following patch changes the word selected when extracting the word
>> from the second vector to insert into the first vector by the
>> vec_insert() builtin.
>> 
>> Specifically, the test case
>> 
>> vector float
>> fn2 (float a, vector float b)
>> {
>>   return vec_insert (a, b, 1);
>> }
>> 
>> without the patch  generates the code sequence 
>> 
>>      xscvdpspn vs0,vs1
>>      xxextractuw vs0,vs0,4            
>>      xxinsertw vs34,vs0,8
> 
> [ For -mcpu=power9 -mlittle ]
> 
> Is this from something in the testsuite?  I can't find it.

It's not from the testsuite.  I found the problem while working on some
vector intrinsic documentation and alerted Carl.

Thanks,
Bill
> 
>> The xscvdpspn places the extracted word into words 0 and 1 of the
>> destination.  The xxextractuw extracts word 1 (offset of 4 bytes)from
>> the source.  The patch changes the offset so that the xxexractuw will
>> extract word 0 (offset 0 bytes) instead of word 1.  The values are the
>> same so there is no functional change. But it was decided that using
>> word 0 was preferred choice.
> 
> The patch looks fine.  Okay for trunk.  Thanks!
> 
> 
> Segher
>
diff mbox series

Patch

diff --git a/gcc/config/rs6000/vsx.md b/gcc/config/rs6000/vsx.md
index a528ef2e8..6e7a4277f 100644
--- a/gcc/config/rs6000/vsx.md
+++ b/gcc/config/rs6000/vsx.md
@@ -3934,7 +3934,7 @@ 
 
   operands[5] = gen_rtx_REG (V4SFmode, tmp_regno);
   operands[6] = gen_rtx_REG (V4SImode, tmp_regno);
-  operands[7] = GEN_INT (BYTES_BIG_ENDIAN ? 1 : 2);
+  operands[7] = GEN_INT (BYTES_BIG_ENDIAN ? 0 : 3);
   operands[8] = gen_rtx_REG (V4SImode, reg_or_subregno (operands[0]));
 }
   [(set_attr "type" "vecperm")