[loongarch][DAG][FREEZE] Fix crash when FREEZE a half(f16) type on loongarch by yxd-ym · Pull Request #107791 · llvm/llvm-project (original) (raw)
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
[ Show hidden characters]({{ revealButtonHref }})
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 @
followed by their GitHub username.
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)
Changes
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.
See: loongarch's handling of half
:
- loongarch64 half (f16) failure to select with +f and +d #93894
- [LoongArch] Allow f16 codegen with expansion to libcalls #94456
Also see: other float promotion FREEZE handling
Full diff: https://github.com/llvm/llvm-project/pull/107791.diff
2 Files Affected:
- (modified) llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp (+1)
- (modified) llvm/test/CodeGen/LoongArch/fp16-promote.ll (+15)
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,fa0, $fa0 +; LA32-NEXT: ret +; +; LA64-LABEL: freeze_half: +; LA64: # %bb.0: +; LA64-NEXT: fadd.s fa0,fa0, fa0,fa0, $fa0 +; LA64-NEXT: ret
- %y1 = freeze half undef
- %t1 = fadd half %y1, %y1
- ret half %t1 +}
Thanks.
Perhaps we should override this interface.
bool softPromoteHalfType() const override { return true; }
We currently do not have any parameter passing specifications for f16 types,this may also cause the generated code to not meet expectations.
Thanks. Perhaps we should override this interface.
bool softPromoteHalfType() const override { return true; }
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?
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?
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!
yxd-ym deleted the fix-loongarch-freeze-f16 branch
/cherry-pick 13280d9
Error: Command failed due to missing milestone.
Does this also fix #97975 on loongarch?
llvmbot pushed a commit to llvmbot/llvm-project that referenced this pull request
…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
:
Also see: other float promotion FREEZE handling
(cherry picked from commit 13280d9)
andrewrk added a commit to ziglang/zig-bootstrap that referenced this pull request
Does this also fix #97975 on loongarch?
Yes. it also fix #97981
This was referenced
Sep 20, 2024
nikic mentioned this pull request
heiher pushed a commit to llvmbot/llvm-project that referenced this pull request
…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
:
Also see: other float promotion FREEZE handling
(cherry picked from commit 13280d9)
This was referenced
Nov 18, 2024
andrewrk added a commit to ziglang/zig-bootstrap that referenced this pull request