[llvm] [WebAssembly] Fix trunc in FastISel (PR #138479)
Pavel Verigo via llvm-commits
llvm-commits at lists.llvm.org
Tue May 6 07:58:06 PDT 2025
pavelverigo wrote:
@dschuff
The `trunc` instruction doesn't perform any zero/sign extension, it simply changes the operand's local type if needed. Any zero/sign extension behavior occurs during lowering of specific instructions (like icmp), not at the trunc itself.
Also, note that the `call` instruction here isn't lowered by FastISel, it fails (and therefore being lowered by SelectionDAG) out due to i48 not being in the supported set of "simple types" (i1, i8, i16, i32, i64, etc). However, in `SelectionDAGISel.cpp`, if FastISel fails on a `CallInst`, it still proceeds with selection rather than aborting whole block, which is why my test doesn't just trunc to i48 and return it (this would not make FastISel doing wrong codegen on `trunc`).
As for correctness: I believe SelectionDAG gets it right. You can confirm by removing -fast-isel in the Godbolt link I included. The added test fails without the patch, which I’ve verified.
https://github.com/llvm/llvm-project/pull/138479
More information about the llvm-commits
mailing list