Index: lib/Target/X86/X86InstrCompiler.td =================================================================== --- lib/Target/X86/X86InstrCompiler.td +++ lib/Target/X86/X86InstrCompiler.td @@ -1191,6 +1191,7 @@ return N->getOpcode() != ISD::TRUNCATE && N->getOpcode() != TargetOpcode::EXTRACT_SUBREG && N->getOpcode() != ISD::CopyFromReg && + N->getOpcode() != ISD::AssertSext && N->getOpcode() != X86ISD::CMOV; }]>; Index: test/CodeGen/X86/2014-11-04-TruncZext.ll =================================================================== --- test/CodeGen/X86/2014-11-04-TruncZext.ll +++ test/CodeGen/X86/2014-11-04-TruncZext.ll @@ -0,0 +1,18 @@ +; RUN: llc < %s -O2 -march=x86-64 | FileCheck %s +; Checks that a zeroing mov is inserted for the trunc/zext pair even when +; the source of the zext is an AssertSext node +; PR20494 + +define i64 @main(i64 %b) { +; CHECK-LABEL: main +; CHECK: movl + %or = or i64 %b, -2 + %trunc = trunc i64 %or to i32 + br label %l +l: + %ext = zext i32 %trunc to i64 + %mul = mul i64 %ext, 7 + %shr = lshr i64 %mul, 32 + trunc i64 %or to i32 + ret i64 %shr +}