Skip to content

[AMDGPU] GlobalISel fails to select G_TRUNC #166501

@chinmaydd

Description

@chinmaydd

Godbolt: https://godbolt.org/z/jEdY3aGWo

IR:

declare i16 @external_i16_func_void()

define amdgpu_kernel void @test_call_external_i16_func_void() {
  %val = call i16 @external_i16_func_void()
  store volatile i16 %val, ptr addrspace(1) poison
  ret void
}

Command:

$ llc -global-isel=1 -mtriple=amdgcn-amd-amdhsa -mcpu=gfx1100 -mattr=-flat-for-global 

Error:

Select:  %13:vgpr_32(s16) = G_TRUNC %26:vgpr(s32)
Failed to constrain G_TRUNC
Selection failed!
Created no instructions.
LLVM ERROR: cannot select: %13:vgpr_32(s16) = G_TRUNC %26:vgpr_32(s32) (in function: test_call_external_i16_func_void)
Compiler returned: 1

The IR is valid and works for global-isel=0 and global-isel=1 but without the -mattr=-flat-for-global restriction.

I also note that the issue is specific to gfx11. I see a crash for gfx12, but that could be related to something else.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions