Index: llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp =================================================================== --- llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp +++ llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp @@ -1102,7 +1102,18 @@ const DebugLoc &DL = I.getDebugLoc(); Register SrcReg = I.getOperand(2).getReg(); unsigned Size = RBI.getSizeInBits(SrcReg, *MRI, TRI); + auto Pred = static_cast(I.getOperand(4).getImm()); + if (!ICmpInst::isIntPredicate(static_cast(Pred))) { + MachineInstr *ICmp = + BuildMI(*BB, &I, DL, TII.get(AMDGPU::IMPLICIT_DEF), Dst); + + if (!RBI.constrainGenericRegister(ICmp->getOperand(0).getReg(), + *TRI.getBoolRC(), *MRI)) + return false; + I.eraseFromParent(); + return true; + } int Opcode = getV_CMPOpcode(Pred, Size); if (Opcode == -1) Index: llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.icmp.ll =================================================================== --- llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.icmp.ll +++ llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.icmp.ll @@ -25,6 +25,17 @@ store i32 %result, i32 addrspace(1)* %out ret void } + +define amdgpu_ps void @test_intr_icmp_i32_invalid_cc(i32 addrspace(1)* %out, i32 %src) #1 { +; GCN-LABEL: test_intr_icmp_i32_invalid_cc: +; GCN: ; %bb.0: +; GCN-NEXT: global_store_dword v[0:1], v0, off +; GCN-NEXT: s_endpgm + %result = call i32 @llvm.amdgcn.icmp.i32.i32(i32 %src, i32 100, i32 9999) + store i32 %result, i32 addrspace(1)* %out + ret void +} + declare i64 @llvm.amdgcn.icmp.i64.i32(i32, i32, i32) declare i32 @llvm.amdgcn.icmp.i32.i32(i32, i32, i32) attributes #0 = { "target-features"="+wavefrontsize64" }