public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: chenglulu <chenglulu@loongson.cn>
To: Xi Ruoyao <xry111@xry111.site>, gcc-patches@gcc.gnu.org
Cc: i@xen0n.name, xuchenghua@loongson.cn
Subject: Re: [PATCH v3 1/5] LoongArch: Fix usage of LSX and LASX frint/ftint instructions [PR112578]
Date: Thu, 23 Nov 2023 16:13:38 +0800	[thread overview]
Message-ID: <9ce7e0b2-eeeb-a8c5-2cc7-e9b65b1b2a6b@loongson.cn> (raw)
In-Reply-To: <a7a141d4-e01b-9539-cd45-1c32866fe186@loongson.cn>


在 2023/11/23 下午3:31, chenglulu 写道:
>
> 在 2023/11/23 下午3:11, Xi Ruoyao 写道:
>> On Thu, 2023-11-23 at 14:35 +0800, chenglulu wrote:
>>> Hi,
>>>
>>>    I don’t quite understand this part. Is it because define_insn 
>>> would be
>>> duplicated with the above implementation,
>>>
>>> so define_insn_and_split is used?
>> Yes, but if you think duplicating the above implementation is better I
>> can dup it as well (as it's just a single line).
>>
>> (I wrote it as a define_expand but it didn't work, then I modified it to
>> define_insn_and_split).
>>
> I just thought it was weird when I was looking at the code.
>
> I modified this code to use define_expand:
>
>     (define_expand "fix_trunc<mode><vimode>2"
>       [(set (match_operand:<VIMODE> 0 "register_operand" "=f")
>             (fix:<VIMODE> (match_operand:FVEC 1 "register_operand" 
> "f")))]
>       ""
>       {
>         emit_insn 
> (gen_<simd_isa>_<x>vftintrz_<simdifmt_for_f>_<simdfmt> (
>           operands[0], operands[1]));
>         DONE;
>       }
>       [(set_attr "type" "simd_fcvt")
>        (set_attr "mode" "<MODE>")])
>
> Here are my test cases:
>
>     typedef float __attribute__ ((mode (SF))) float_t;
>     typedef int __attribute__ ((mode (SI))) int_t;
>
>     extern int_t v[4];
>     int_t
>     lt_fixdfsi (float_t *x)
>     {
>
>       for (int i=0;i<4;i++)
>         v[i] = x[i];
>     }
>
> This still achieves the desired effect, generating the following 
> assembly code:
>
> lt_fixdfsi:
> .LFB0 = .
>     .cfi_startproc
>
>     or    $r13,$r4,$r0     # 16    [c=4 l=4]  *movdi_64bit/0
>     la.global    $r12,v     # 8    [c=4 l=12]  *movdi_64bit/1
>     vld    $vr0,$r13,0     # 6    [c=12 l=4]  movv4sf_lsx/1
>     vftintrz.w.s    $vr0,$vr0     # 7    [c=12 l=4] lsx_vftintrz_w_s
>     vst    $vr0,$r12,0     # 9    [c=4 l=4]  movv4si_lsx/2
>
> So I don't know if I'm getting it right?:-(
>
The fix_truncv4sfv4si2 template is indeed called when debugging with gdb.

So I think we can use define_expand here.

>>>> +(define_insn_and_split "fix_trunc<mode><vimode>2"
>>>> +  [(set (match_operand:<VIMODE> 0 "register_operand" "=f")
>>>> +    (fix:<VIMODE> (match_operand:FVEC 1 "register_operand" "f")))]
>>>> +  ""
>>>> +  "#"
>>>> +  ""
>>>> +  [(const_int 0)]
>>>> +  {
>>>> +    emit_insn 
>>>> (gen_<simd_isa>_<x>vftintrz_<simdifmt_for_f>_<simdfmt> (
>>>> +      operands[0], operands[1]));
>>>> +    DONE;
>>>> +  }
>>>> +  [(set_attr "type" "simd_fcvt")
>>>> +   (set_attr "mode" "<MODE>")])


  reply	other threads:[~2023-11-23  8:13 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-20  0:47 [PATCH v3 0/5] LoongArch: SIMD fixes and optimizations Xi Ruoyao
2023-11-20  0:47 ` [PATCH v3 1/5] LoongArch: Fix usage of LSX and LASX frint/ftint instructions [PR112578] Xi Ruoyao
2023-11-23  6:35   ` chenglulu
2023-11-23  7:11     ` Xi Ruoyao
2023-11-23  7:31       ` chenglulu
2023-11-23  8:13         ` chenglulu [this message]
2023-11-23  9:02           ` Xi Ruoyao
2023-11-23  9:12             ` chenglulu
2023-11-23 10:12               ` Xi Ruoyao
2023-11-23 12:06                 ` Xi Ruoyao
2023-11-23 18:03                 ` Joseph Myers
2023-11-24  2:39                   ` Xi Ruoyao
2023-11-24  8:01                     ` chenglulu
2023-11-24  8:26                       ` Xi Ruoyao
2023-11-24  8:36                         ` chenglulu
2023-11-24  8:42                           ` Xi Ruoyao
2023-11-24  9:46                             ` chenglulu
2023-11-24 10:30                               ` Xi Ruoyao
2023-11-24 14:59                                 ` chenglulu
2023-11-23  8:54         ` Xi Ruoyao
2023-11-20  0:47 ` [PATCH v3 2/5] LoongArch: Use standard pattern name and RTX code for LSX/LASX muh instructions Xi Ruoyao
2023-11-23 12:08   ` chenglulu
2023-11-20  0:47 ` [PATCH v3 3/5] LoongArch: Use standard pattern name and RTX code for LSX/LASX rotate shift Xi Ruoyao
2023-11-23  8:42   ` chenglulu
2023-11-20  0:47 ` [PATCH v3 4/5] LoongArch: Remove lrint_allow_inexact Xi Ruoyao
2023-11-23  8:23   ` chenglulu
2023-11-23  8:58     ` Xi Ruoyao
2023-11-23  9:14       ` chenglulu
2023-11-23 12:24         ` Xi Ruoyao
2023-11-23 14:39           ` chenglulu
2023-11-20  0:47 ` [PATCH v3 5/5] LoongArch: Use LSX for scalar FP rounding with explicit rounding mode Xi Ruoyao
2023-11-29  7:12 ` Pushed: [PATCH v3 0/5] LoongArch: SIMD fixes and optimizations Xi Ruoyao
2023-11-29  7:45   ` chenglulu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9ce7e0b2-eeeb-a8c5-2cc7-e9b65b1b2a6b@loongson.cn \
    --to=chenglulu@loongson.cn \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=i@xen0n.name \
    --cc=xry111@xry111.site \
    --cc=xuchenghua@loongson.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).