From: mengqinggang Date: Fri, 23 Jan 2026 07:00:58 +0000 (+0800) Subject: LoongArch: Fix movsf in lp64s abi X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=599659fb1006eb628b3d271cc77a3cc69ec436c1;p=thirdparty%2Fgcc.git LoongArch: Fix movsf in lp64s abi When adding LoongArch32 ilp32s abi support, add TARGET_HARD_FLOAT condition for movsf to prevent matching in target without FPU. But movsf also needs to be used in lp64s abi, it can expand to some non float instructions. Delete TARGET_HARD_FLOAT condition. gcc/ChangeLog: * config/loongarch/loongarch.md: Delete movsf TARGET_HARD_FLOAT condition. gcc/testsuite/ChangeLog: * gcc.target/loongarch/la64/movsf.c: New test. --- diff --git a/gcc/config/loongarch/loongarch.md b/gcc/config/loongarch/loongarch.md index 9dc9d6dffad..77b3298078a 100644 --- a/gcc/config/loongarch/loongarch.md +++ b/gcc/config/loongarch/loongarch.md @@ -2540,7 +2540,7 @@ (define_expand "movsf" [(set (match_operand:SF 0 "") (match_operand:SF 1 ""))] - "TARGET_HARD_FLOAT" + "" { if (loongarch_legitimize_move (SFmode, operands[0], operands[1])) DONE; diff --git a/gcc/testsuite/gcc.target/loongarch/la64/movsf.c b/gcc/testsuite/gcc.target/loongarch/la64/movsf.c new file mode 100644 index 00000000000..efe979c5289 --- /dev/null +++ b/gcc/testsuite/gcc.target/loongarch/la64/movsf.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-mabi=lp64s" } */ + +float +__powisf2 (float x, int m) +{ + unsigned int n = m < 0 ? -(unsigned int) m : (unsigned int) m; + float y = n % 2 ? x : 1; + while (n >>= 1) + { + x = x * x; + if (n % 2) + y = y * x; + } + return m < 0 ? 1/y : y; +}