llvm/llvm-project

[AMDGPU][GlobalIsel] ICE: cannot select G_PHI

Open

#200,792 opened on Jun 1, 2026

View on GitHub
 (11 comments) (0 reactions) (1 assignee)C++ (26,378 stars) (10,782 forks)batch import
backend:AMDGPUconfirmedcrash-on-validgood first issuellvm:globalisel

Description

The following bitcode module triggers an internal compiler error for -global-isel -O0 in f68ef5b4303de763ecf37fd57cbefc3891ee48c0:

define i32 @__ockl_get_num_groups() {
  %1 = load i16, ptr addrspace(4) null, align 2
  %2 = icmp ne i16 %1, 0
  br label %3

3:                                                ; preds = %0
  %4 = phi i1 [ %2, %0 ]
  %5 = zext i1 %4 to i32
  ret i32 %5
}

Reproducer: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx90a -O0 -global-isel module.ll

Failure: LLVM ERROR: cannot select: %12:sreg_64_xexec(s1) = G_PHI %11:vcc(s1), %bb.1 (in function: __ockl_get_num_groups

Bug found by @ElliotBLabs.

Contributor guide