-
Notifications
You must be signed in to change notification settings - Fork 11.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[loongarch][DAG][FREEZE] Fix crash when FREEZE a half(f16) type on loongarch #107791
Conversation
Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the LLVM GitHub User Guide. You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums. |
@llvm/pr-subscribers-llvm-selectiondag @llvm/pr-subscribers-backend-loongarch Author: YANG Xudong (yxd-ym) ChangesFor zig with LLVM 19.1.0rc4, we are seeing the following error when bootstrapping a ziglang/zig-bootstrap#164 (comment) It seems that this issue is caused by Here is the reproduction of the error: https://godbolt.org/z/PPfvWjjG5 This patch adds the FREEZE OP handling with See: loongarch's handling of
Also see: other float promotion FREEZE handling Full diff: https://github.com/llvm/llvm-project/pull/107791.diff 2 Files Affected:
diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
index b5c80005a0ecc1..51357dad5b30ec 100644
--- a/llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
@@ -2655,6 +2655,7 @@ void DAGTypeLegalizer::PromoteFloatResult(SDNode *N, unsigned ResNo) {
case ISD::FLOG10:
case ISD::FNEARBYINT:
case ISD::FNEG:
+ case ISD::FREEZE:
case ISD::FRINT:
case ISD::FROUND:
case ISD::FROUNDEVEN:
diff --git a/llvm/test/CodeGen/LoongArch/fp16-promote.ll b/llvm/test/CodeGen/LoongArch/fp16-promote.ll
index 75f920b43a06ce..a139428f2d61e9 100644
--- a/llvm/test/CodeGen/LoongArch/fp16-promote.ll
+++ b/llvm/test/CodeGen/LoongArch/fp16-promote.ll
@@ -324,3 +324,18 @@ define void @test_fmul_mem(ptr %p, ptr %q) nounwind {
store half %r, ptr %p
ret void
}
+
+define half @freeze_half() nounwind {
+; LA32-LABEL: freeze_half:
+; LA32: # %bb.0:
+; LA32-NEXT: fadd.s $fa0, $fa0, $fa0
+; LA32-NEXT: ret
+;
+; LA64-LABEL: freeze_half:
+; LA64: # %bb.0:
+; LA64-NEXT: fadd.s $fa0, $fa0, $fa0
+; LA64-NEXT: ret
+ %y1 = freeze half undef
+ %t1 = fadd half %y1, %y1
+ ret half %t1
+}
|
Thanks.
We currently do not have any parameter passing specifications for f16 types,this may also cause the generated code to not meet expectations. |
@wangleiat Changed the fix according to your suggestion and updated the tests. Would you please check it? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Also, is it possible to add this fix to release 19? Thanks! |
Yes, this patch is also applicable to release 19.x. Thanks. |
Should the commit message be updated? |
Updated. |
@yxd-ym Congratulations on having your first Pull Request (PR) merged into the LLVM Project! Your changes will be combined with recent changes from other authors, then tested by our build bots. If there is a problem with a build, you may receive a report in an email or a comment on this PR. Please check whether problems have been caused by your change specifically, as the builds can include changes from many authors. It is not uncommon for your change to be included in a build that fails due to someone else's changes, or infrastructure issues. How to do this, and the rest of the post-merge process, is covered in detail here. If your change does cause a problem, it may be reverted, or you can revert it yourself. This is a normal part of LLVM development. You can fix your changes and open a new PR to merge them again. If you don't get any reports, no action is required from you. Your changes are working as expected, well done! |
/cherry-pick 13280d9 |
Error: Command failed due to missing milestone. |
/cherry-pick 13280d9 |
Does this also fix #97975 on loongarch? |
…ongarch (llvm#107791) For zig with LLVM 19.1.0rc4, we are seeing the following error when bootstrapping a `loongarch64-linux-musl` target. ziglang/zig-bootstrap#164 (comment) It seems that this issue is caused by `PromoteFloatResult` is not handling FREEZE OP on loongarch. Here is the reproduction of the error: https://godbolt.org/z/PPfvWjjG5 ~~This patch adds the FREEZE OP handling with `PromoteFloatRes_UnaryOp` and adds a test case.~~ This patch changes loongarch's way of floating point promotion to soft promotion to avoid this problem. See: loongarch's handling of `half`: - llvm#93894 - llvm#94456 Also see: other float promotion FREEZE handling - llvm@0019c2f (cherry picked from commit 13280d9)
/pull-request #109093 |
…ongarch (llvm#107791) For zig with LLVM 19.1.0rc4, we are seeing the following error when bootstrapping a `loongarch64-linux-musl` target. ziglang/zig-bootstrap#164 (comment) It seems that this issue is caused by `PromoteFloatResult` is not handling FREEZE OP on loongarch. Here is the reproduction of the error: https://godbolt.org/z/PPfvWjjG5 ~~This patch adds the FREEZE OP handling with `PromoteFloatRes_UnaryOp` and adds a test case.~~ This patch changes loongarch's way of floating point promotion to soft promotion to avoid this problem. See: loongarch's handling of `half`: - llvm#93894 - llvm#94456 Also see: other float promotion FREEZE handling - llvm@0019c2f (cherry picked from commit 13280d9)
Download |
For zig with LLVM 19.1.0rc4, we are seeing the following error when bootstrapping a
loongarch64-linux-musl
target.ziglang/zig-bootstrap#164 (comment)
It seems that this issue is caused by
PromoteFloatResult
is not handling FREEZE OP on loongarch.Here is the reproduction of the error: https://godbolt.org/z/PPfvWjjG5
This patch adds the FREEZE OP handling withPromoteFloatRes_UnaryOp
and adds a test case.This patch changes loongarch's way of floating point promotion to soft promotion to avoid this problem.
See: loongarch's handling of
half
:+f
and+d
#93894Also see: other float promotion FREEZE handling