Skip to content
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

loongarch64 half (f16) failure to select with +f and +d #93894

Closed
tgross35 opened this issue May 30, 2024 · 2 comments · Fixed by #94456
Closed

loongarch64 half (f16) failure to select with +f and +d #93894

tgross35 opened this issue May 30, 2024 · 2 comments · Fixed by #94456
Labels
backend:loongarch crash Prefer [crash-on-valid] or [crash-on-invalid]

Comments

@tgross35
Copy link

define half @half_add(half %a, half %b) unnamed_addr #0 {
start:
  %_0 = fadd half %a, %b
  ret half %_0
}

With -mtriple=loongarch64-unknown-linux-gnu -mattr=+f,+d:

LLVM ERROR: Cannot select: t23: f32 = fp16_to_fp t21
  t21: i64 = fp_to_fp16 t4
    t4: f32,ch = CopyFromReg t0, Register:f32 %1
      t3: f32 = Register %1
In function: half_add
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.	Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/llc -o /app/output.s -x86-asm-syntax=intel -mtriple=loongarch64-unknown-linux-gnu -mattr=+f,+d <source>
1.	Running pass 'Function Pass Manager' on module '<source>'.
2.	Running pass 'LoongArch DAG->DAG Pattern Instruction Selection' on function '@half_add'
 #0 0x00000000039e9678 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x39e9678)
 #1 0x00000000039e6dbc SignalHandler(int) Signals.cpp:0:0
 #2 0x00007e2b90a42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #3 0x00007e2b90a969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #4 0x00007e2b90a42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #5 0x00007e2b90a287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #6 0x0000000000720e07 (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x720e07)
 #7 0x000000000379ccad llvm::SelectionDAGISel::CannotYetSelect(llvm::SDNode*) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x379ccad)
 #8 0x00000000037a1c9a llvm::SelectionDAGISel::SelectCodeCommon(llvm::SDNode*, unsigned char const*, unsigned int) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x37a1c9a)
 #9 0x00000000016a2837 llvm::LoongArchDAGToDAGISel::Select(llvm::SDNode*) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x16a2837)
#10 0x0000000003799aee llvm::SelectionDAGISel::DoInstructionSelection() (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x3799aee)
#11 0x00000000037a7db6 llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x37a7db6)
#12 0x00000000037ab0bd llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x37ab0bd)
#13 0x00000000037acaff llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (.part.0) SelectionDAGISel.cpp:0:0
#14 0x00000000029e6721 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0
#15 0x0000000002fad603 llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x2fad603)
#16 0x0000000002fad841 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x2fad841)
#17 0x0000000002fae0a5 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x2fae0a5)
#18 0x000000000083129c compileModule(char**, llvm::LLVMContext&) llc.cpp:0:0
#19 0x0000000000728536 main (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x728536)
#20 0x00007e2b90a29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#21 0x00007e2b90a29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#22 0x000000000082804e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x82804e)
Program terminated with signal: SIGSEGV
Compiler returned: 139

There is no error if the -mattr flag is omitted

Reproduction: https://llvm.godbolt.org/z/faenafnzh

@tgross35
Copy link
Author

tgross35 commented Jun 4, 2024

The other variants of this fail here as well, e.g. i64 = fp_to_fp16, rust-lang/rust#125016 (comment)

@andrewrk
Copy link
Member

andrewrk commented Jun 5, 2024

Zig blocker too ziglang/zig#20193

xen0n added a commit to xen0n/llvm-project that referenced this issue Jun 5, 2024
The test case is adapted from llvm/test/CodeGen/RISCV/fp16-promote.ll,
because it covers some more IR patterns that ought to be common.

Fixes llvm#93894
heiher pushed a commit that referenced this issue Jun 6, 2024
The test case is adapted from llvm/test/CodeGen/RISCV/fp16-promote.ll,
because it covers some more IR patterns that ought to be common.

Fixes #93894
@EugeneZelenko EugeneZelenko removed the llvm:SelectionDAG SelectionDAGISel as well label Jun 6, 2024
tgross35 added a commit to tgross35/rust that referenced this issue Aug 22, 2024
Loongarch previously had a selection failure for `f16` math [1]. This
was fixed in [2], which Rust got with the update to LLVM19.

Enable it in `std/build.rs` so we start running tests.

[1]: llvm/llvm-project#93894
[2]: llvm/llvm-project#94456
tgross35 added a commit to tgross35/rust that referenced this issue Aug 22, 2024
Loongarch previously had a selection failure for `f16` math [1]. This
was fixed in [2], which Rust got with the update to LLVM 19 [3].

Enable loongarch in `std/build.rs` so we start running tests.

[1]: llvm/llvm-project#93894
[2]: llvm/llvm-project#94456
[3]: rust-lang#127513
bors added a commit to rust-lang-ci/rust that referenced this issue Aug 22, 2024
Enable `f16` tests on loongarch

Loongarch previously had a selection failure for `f16` math llvm/llvm-project#93894. This was fixed in llvm/llvm-project#94456, which Rust got with the update to LLVM 19 rust-lang#127513.

Enable loongarch in `std/build.rs` so we start running tests.

try-job: dist-loongarch64-linux
try-job: dist-loongarch64-musl
SixWeining pushed a commit that referenced this issue Sep 13, 2024
…ongarch (#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`:
- #93894
- #94456

Also see: other float promotion FREEZE handling
-
0019c2f
llvmbot pushed a commit to llvmbot/llvm-project that referenced this issue Sep 18, 2024
…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)
heiher pushed a commit to llvmbot/llvm-project that referenced this issue Oct 19, 2024
…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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:loongarch crash Prefer [crash-on-valid] or [crash-on-invalid]
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants