llvm-project/llvm/test/CodeGen/WebAssembly/fast-isel-pr138479.ll
Pavel Verigo 9d89b05f11
[WebAssembly] Fix trunc in FastISel (#138479)
Previous logic did not handle the case where the result bit size was
between 32 and 64 bits inclusive. I updated the if-statements for more
precise handling.

An alternative solution would have been to abort FastISel in case the
result type is not legal for FastISel.

Resolves: #64222.

This PR began as an investigation into the root cause of
https://github.com/ziglang/zig/issues/20966.

Godbolt link showing incorrect codegen on 20.1.0:
https://godbolt.org/z/cEr4vY7d4.
2025-05-06 14:16:35 -07:00

16 lines
415 B
LLVM

; RUN: llc < %s -asm-verbose=false -fast-isel -fast-isel-abort=1 -verify-machineinstrs | FileCheck %s
target triple = "wasm32-unknown-unknown"
declare void @extern48(i48)
; CHECK-LABEL: call_trunc_i64_to_i48:
; CHECK: local.get 0
; CHECK-NEXT: call extern48
; CHECK-NEXT: end_function
define void @call_trunc_i64_to_i48(i64 %x) {
%x48 = trunc i64 %x to i48
call void @extern48(i48 %x48)
ret void
}