[llvm] [MIPS] Fix miscompiles consecutive half operations (PR #110199)

via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 26 19:41:14 PDT 2024


https://github.com/yingopq created https://github.com/llvm/llvm-project/pull/110199

Use softPromoteHalf legalization for fp16 rather than PromoteFloat.

Fix #97975.

>From 2ffa43edc3b4ada75d120ad9a4a9d31d32dd1326 Mon Sep 17 00:00:00 2001
From: Ying Huang <ying.huang at oss.cipunited.com>
Date: Thu, 26 Sep 2024 22:39:13 -0400
Subject: [PATCH] [MIPS] Fix miscompiles consecutive half operations

Use softPromoteHalf legalization for fp16 rather than PromoteFloat.

Fix #97975.
---
 llvm/lib/Target/Mips/MipsISelLowering.h | 2 ++
 llvm/test/CodeGen/Mips/fp16-promote.ll  | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/llvm/lib/Target/Mips/MipsISelLowering.h b/llvm/lib/Target/Mips/MipsISelLowering.h
index 2b18b299180926..1e35e87b6f2b36 100644
--- a/llvm/lib/Target/Mips/MipsISelLowering.h
+++ b/llvm/lib/Target/Mips/MipsISelLowering.h
@@ -373,6 +373,8 @@ class TargetRegisterClass;
 
    CCAssignFn *CCAssignFnForReturn() const;
 
+   bool softPromoteHalfType() const override { return true; }
+
   protected:
     SDValue getGlobalReg(SelectionDAG &DAG, EVT Ty) const;
 
diff --git a/llvm/test/CodeGen/Mips/fp16-promote.ll b/llvm/test/CodeGen/Mips/fp16-promote.ll
index 6cbfab5f776698..e6e39c0f1b5aaa 100644
--- a/llvm/test/CodeGen/Mips/fp16-promote.ll
+++ b/llvm/test/CodeGen/Mips/fp16-promote.ll
@@ -62,8 +62,8 @@ define <4 x float> @test_vec_fpext_float(ptr %p) #0 {
 ; CHECK-LIBCALL-LABEL: test_vec_fpext_double:
 ; CHECK-LIBCALL: %call16(__gnu_h2f_ieee)
 ; CHECK-LIBCALL: %call16(__gnu_h2f_ieee)
-; CHECK-LIBCALL: %call16(__gnu_h2f_ieee)
 ; CHECK-LIBCALL: cvt.d.s
+; CHECK-LIBCALL: %call16(__gnu_h2f_ieee)
 ; CHECK-LIBCALL: cvt.d.s
 ; CHECK-LIBCALL: cvt.d.s
 ; CHECK-LIBCALL: %call16(__gnu_h2f_ieee)



More information about the llvm-commits mailing list