]> git.ipfire.org Git - thirdparty/gcc.git/commit
LoongArch: Optimize fixed-point and floating-point conversion operations.
authorLulu Cheng <chenglulu@loongson.cn>
Thu, 31 Aug 2023 11:11:23 +0000 (19:11 +0800)
committerLulu Cheng <chenglulu@loongson.cn>
Mon, 4 Sep 2023 01:34:46 +0000 (09:34 +0800)
commit26aa5d9017104ee3a72de418e9a0a1e5c1e30313
tree39243c07dad638b879d47cff8fad369fb714930a
parent124749a0f681cc20f7977708d5010174a20eb92e
LoongArch: Optimize fixed-point and floating-point conversion operations.

Before optimization, the operation of taking fixed-point numbers from memory
and then forcing type conversion needs to be loaded into fixed-point registers
before conversion. After the optimization is completed, the fixed-point value
is directly transferred to the floating-point register for type conversion.

eg:
    extern int a;
    float
    test(void)
    {
      return (float)a;
    }

Assembly code before optimization:
pcalau12i $r12,%got_pc_hi20(a)
ld.d $r12,$r12,%got_pc_lo12(a)
ldptr.w $r12,$r12,0
movgr2fr.w $f0,$r12
ffint.s.w $f0,$f0

Optimized assembly code:
pcalau12i $r12,%got_pc_hi20(a)
ld.d $r12,$r12,%got_pc_lo12(a)
fld.s $f0,$r12,0
ffint.s.w $f0,$f0

gcc/ChangeLog:

* config/loongarch/loongarch.md: Allows fixed-point values to be loaded
from memory into floating-point registers.

gcc/testsuite/ChangeLog:

* gcc.target/loongarch/float-load.c: New test.
gcc/config/loongarch/loongarch.md
gcc/testsuite/gcc.target/loongarch/float-load.c [new file with mode: 0644]