Index: lib/CodeGen/MachineInstr.cpp =================================================================== --- lib/CodeGen/MachineInstr.cpp +++ lib/CodeGen/MachineInstr.cpp @@ -1309,7 +1309,7 @@ unsigned Reg, bool isKill, const TargetRegisterInfo *TRI) const { for (unsigned i = 0, e = getNumOperands(); i != e; ++i) { const MachineOperand &MO = getOperand(i); - if (!MO.isReg() || !MO.isUse()) + if (!MO.isReg() || !MO.isUse() || MO.isUndef()) continue; unsigned MOReg = MO.getReg(); if (!MOReg) Index: test/CodeGen/X86/pr31143.ll =================================================================== --- test/CodeGen/X86/pr31143.ll +++ test/CodeGen/X86/pr31143.ll @@ -0,0 +1,31 @@ +; RUN: llc --mattr=+sse4.1 %s -o - | FileCheck %s + +target triple = "x86_64-pc-linux-gnu" + + +; CHECK: xorps [[XMM1:%xmm[0-9]+]], [[XMM1]] +; CHECK-NEXT: roundss $9, [[XMM0:%xmm[0-9]+]], [[XMM1]] + +define void @test(float* nocapture %a, <4 x float>* nocapture %b, i32 %k) { +entry: + br label %for.body + +for.body: + %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ] + %arrayidx = getelementptr inbounds float, float* %a, i64 %indvars.iv + %v = load float, float* %arrayidx, align 4 + %floor = call float @floorf(float %v) + %sub = fsub float %floor, %v + %v1 = insertelement <4 x float> undef, float %sub, i32 0 + %br = shufflevector <4 x float> %v1, <4 x float> undef, <4 x i32> + store volatile <4 x float> %br, <4 x float>* %b, align 4 + %indvars.iv.next = add i64 %indvars.iv, 1 + %lftr.wideiv = trunc i64 %indvars.iv.next to i32 + %exitcond = icmp eq i32 %lftr.wideiv, %k + br i1 %exitcond, label %for.end, label %for.body + +for.end: + ret void +} + +declare float @floorf(float) nounwind readnone