Index: lib/Target/X86/X86ISelLowering.cpp =================================================================== --- lib/Target/X86/X86ISelLowering.cpp +++ lib/Target/X86/X86ISelLowering.cpp @@ -12677,7 +12677,6 @@ break; SDValue New = DAG.getNode(ISD::AND, dl, VT, Op->getOperand(0), DAG.getConstant(Mask, dl, VT)); - DAG.ReplaceAllUsesWith(Op, New); Op = New; } break; Index: test/CodeGen/X86/icmp-lowering-crash.ll =================================================================== --- test/CodeGen/X86/icmp-lowering-crash.ll +++ test/CodeGen/X86/icmp-lowering-crash.ll @@ -0,0 +1,19 @@ +; RUN: llc < %s > /dev/null +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +@a = external global i32, align 4 +@b = external global i1, align 4 + +define i1 @f() { +entry: + %load = load i32, i32* @a, align 4 + %trunc = trunc i32 %load to i8 + %mul = mul i8 %trunc, 2 + %icmp1 = icmp ne i8 %mul, 0 + store i1 %icmp1, i1* @b, align 4 + %and = and i8 %trunc, 127 + %icmp2 = icmp ne i8 %and, 0 + ret i1 %icmp2 +} +