]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
LoongArch: Fix movsf in lp64s abi
authormengqinggang <mengqinggang@loongson.cn>
Fri, 23 Jan 2026 07:00:58 +0000 (15:00 +0800)
committerLulu Cheng <chenglulu@loongson.cn>
Fri, 30 Jan 2026 01:21:21 +0000 (09:21 +0800)
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.

gcc/config/loongarch/loongarch.md
gcc/testsuite/gcc.target/loongarch/la64/movsf.c [new file with mode: 0644]

index 9dc9d6dffad153bb7ac944fae3abaec622201632..77b3298078af55544531dcba3fda259f15035702 100644 (file)
 (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 (file)
index 0000000..efe979c
--- /dev/null
@@ -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;                                                        
+}