加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
LoongArch-Use-UNSPEC-for-fmin-fmax-RTL-pattern-PR105.patch 2.26 KB
一键复制 编辑 原始数据 按行查看 历史
ticat_fp 提交于 2024-03-26 09:26 . LoongArch: update from gcc upstream
From d6c7fe54314f7633d779da1a635a8f0832b8f4f6 Mon Sep 17 00:00:00 2001
From: Xi Ruoyao <xry111@xry111.site>
Date: Sat, 24 Sep 2022 20:47:22 +0800
Subject: [PATCH 021/124] LoongArch: Use UNSPEC for fmin/fmax RTL pattern
[PR105414]
I made a mistake defining fmin/fmax RTL patterns in r13-2085: I used
smin and smax in the definition mistakenly. This causes the optimizer
to perform constant folding as if fmin/fmax was "really" smin/smax
operations even with -fsignaling-nans. Then pr105414.c fails.
We don't have fmin/fmax RTL codes for now (PR107013) so we can only use
an UNSPEC for fmin and fmax patterns.
gcc/ChangeLog:
PR tree-optimization/105414
* config/loongarch/loongarch.md (UNSPEC_FMAX): New unspec.
(UNSPEC_FMIN): Likewise.
(fmax<mode>3): Use UNSPEC_FMAX instead of smax.
(fmin<mode>3): Use UNSPEC_FMIN instead of smin.
Signed-off-by: Peng Fan <fanpeng@loongson.cn>
Signed-off-by: ticat_fp <fanpeng@loongson.cn>
---
gcc/config/loongarch/loongarch.md | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/gcc/config/loongarch/loongarch.md b/gcc/config/loongarch/loongarch.md
index 3787fd823..214b14bdd 100644
--- a/gcc/config/loongarch/loongarch.md
+++ b/gcc/config/loongarch/loongarch.md
@@ -35,6 +35,8 @@
;; Floating point unspecs.
UNSPEC_FRINT
UNSPEC_FCLASS
+ UNSPEC_FMAX
+ UNSPEC_FMIN
;; Override return address for exception handling.
UNSPEC_EH_RETURN
@@ -1032,8 +1034,9 @@
(define_insn "fmax<mode>3"
[(set (match_operand:ANYF 0 "register_operand" "=f")
- (smax:ANYF (match_operand:ANYF 1 "register_operand" "f")
- (match_operand:ANYF 2 "register_operand" "f")))]
+ (unspec:ANYF [(use (match_operand:ANYF 1 "register_operand" "f"))
+ (use (match_operand:ANYF 2 "register_operand" "f"))]
+ UNSPEC_FMAX))]
""
"fmax.<fmt>\t%0,%1,%2"
[(set_attr "type" "fmove")
@@ -1041,8 +1044,9 @@
(define_insn "fmin<mode>3"
[(set (match_operand:ANYF 0 "register_operand" "=f")
- (smin:ANYF (match_operand:ANYF 1 "register_operand" "f")
- (match_operand:ANYF 2 "register_operand" "f")))]
+ (unspec:ANYF [(use (match_operand:ANYF 1 "register_operand" "f"))
+ (use (match_operand:ANYF 2 "register_operand" "f"))]
+ UNSPEC_FMIN))]
""
"fmin.<fmt>\t%0,%1,%2"
[(set_attr "type" "fmove")
--
2.33.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化