Index: lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp =================================================================== --- lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp +++ lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp @@ -1550,6 +1550,9 @@ CurDAG->UpdateNodeOperands(M, makeArrayRef(NewOps, OpN)); } + + if (EffectiveFI->use_empty()) + CurDAG->RemoveDeadNode(EffectiveFI.getNode()); } } } Index: test/CodeGen/AMDGPU/captured-frame-index.ll =================================================================== --- test/CodeGen/AMDGPU/captured-frame-index.ll +++ test/CodeGen/AMDGPU/captured-frame-index.ll @@ -163,4 +163,23 @@ ret void } +@g1 = external addrspace(1) global i32* + +; This was leaving a dead node around resulting in failing to select +; on the leftover AssertZext's ValueType operand. + +; GCN-LABEL: {{^}}cannot_select_assertzext_valuetype: +; GCN: s_add_u32 s{{[0-9]+}}, s{{[0-9]+}}, g1@GOTPCREL+4 +; GCN: v_mov_b32_e32 [[FI:v[0-9]+]], 0{{$}} +; GCN: buffer_store_dword [[FI]] +define void @cannot_select_assertzext_valuetype(i32 addrspace(1)* %out, i32 %idx) #0 { +entry: + %b = alloca i32, align 4 + %tmp1 = load volatile i32*, i32* addrspace(1)* @g1, align 4 + %arrayidx = getelementptr inbounds i32, i32* %tmp1, i32 %idx + %tmp2 = load i32, i32* %arrayidx, align 4 + store volatile i32* %b, i32* addrspace(1)* undef + ret void +} + attributes #0 = { nounwind }