[PATCH] rs6000: Support doubleword swaps removal in rot64 load store [PR100085]

Xionghu Luo luoxhu@linux.ibm.com
Wed Jun 9 03:20:20 GMT 2021



On 2021/6/9 04:11, Segher Boessenkool wrote:
> Hi!
> 
> On Fri, Jun 04, 2021 at 09:40:58AM +0800, Xionghu Luo wrote:
>>>> Combine still fail to merge the two instructions:
>>>>
>>>> Trying 6 -> 7:
>>>>       6: r120:KF#0=r125:KF#0<-<0x40
>>>>         REG_DEAD r125:KF
>>>>       7: [sfp:DI+r123:DI]=r120:KF#0<-<0x40
>>>>         REG_DEAD r120:KF
>>>> Successfully matched this instruction:
>>>> (set (mem/c:V1TI (plus:DI (reg/f:DI 110 sfp)
>>>>               (reg:DI 123)) [1  S16 A128])
>>>>       (subreg:V1TI (reg:KF 125) 0))
>>>> rejecting combination of insns 6 and 7
>>>> original costs 4 + 4 = 8
>>>> replacement cost 12
>>>
>>> So what instructions were these?  Why did the store cost 4 but the new
>>> one costs 12?
> 
> The *vsx_le_perm_store_<mode> instruction has the *preferred*
> alternative with cost 12, while the other alternative has cost 8.  Why
> is that?  That looks like a bug.
>     (set_attr "length" "12,8")

12 was introduced by Mike's commit c477a6674364(r6-2577), and all the 5
vsx_le_perm_store_<mode> are set to 12 for modes VSX_D/VSX_W/V8HI/V16QI
/VSX_LE_128, I guess it is split to two rs6000_emit_le_vsx_permute before
reload, but 3 rs6000_emit_le_vsx_permute after reload, so the length is
12, then it seems also not reasonable to change it from 12 to 8?  And I am
not sure when the alternative 1 will be chosen?

vsx.md:
;; The post-reload split requires that we re-permute the source
;; register in case it is still live.
(define_split
  [(set (match_operand:VSX_LE_128 0 "memory_operand")
        (match_operand:VSX_LE_128 1 "vsx_register_operand"))]
  "!BYTES_BIG_ENDIAN && TARGET_VSX && reload_completed && !TARGET_P9_VECTOR
   && !altivec_indexed_or_indirect_operand (operands[0], <MODE>mode)"
  [(const_int 0)]
{
  rs6000_emit_le_vsx_permute (operands[1], operands[1], <MODE>mode);
  rs6000_emit_le_vsx_permute (operands[0], operands[1], <MODE>mode);
  rs6000_emit_le_vsx_permute (operands[1], operands[1], <MODE>mode);
  DONE;
}) 

> 
>>>> By hacking the vsx_le_perm_store_v1ti INSN_COST from 12 to 8,
>>>
>>> It should be the same cost as the other store!
>>
>> vsx_le_permute_v1ti's cost is defined to 4 in vsx.md:
> 
> Yes.  Why is alternative 0 of *vsx_le_perm_store_<mode> said to have a
> length of 3 insns?
> 
> 
> Segher
> 

-- 
Thanks,
Xionghu


More information about the Gcc-patches mailing list