Index: lib/Target/AMDGPU/SIFixSGPRCopies.cpp =================================================================== --- lib/Target/AMDGPU/SIFixSGPRCopies.cpp +++ lib/Target/AMDGPU/SIFixSGPRCopies.cpp @@ -604,7 +604,8 @@ // We don't need to fix the PHI if the common dominator of the // two incoming blocks terminates with a uniform branch. - if (MI.getNumExplicitOperands() == 5) { + if (MI.getNumExplicitOperands() == 5 && + !phiHasVGPROperands(MI, MRI, TRI, TII)) { MachineBasicBlock *MBB0 = MI.getOperand(2).getMBB(); MachineBasicBlock *MBB1 = MI.getOperand(4).getMBB(); Index: test/CodeGen/AMDGPU/vgpr-to-sgpr-phi.ll =================================================================== --- /dev/null +++ test/CodeGen/AMDGPU/vgpr-to-sgpr-phi.ll @@ -0,0 +1,40 @@ +; RUN: llc -march=amdgcn -mcpu=fiji -verify-machineinstrs < %s | FileCheck %s + +; CHECK-LABEL: {{^}}vgpr_to_sgpr_phi: +; CHECK: BB0_1: +; CHECK: v_add_i32_e32 +; CHECK: s_branch BB0_1 +define void @vgpr_to_sgpr_phi(i32* nocapture) local_unnamed_addr #0 { + br label %2 + +;