Index: lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp =================================================================== --- lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp +++ lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp @@ -343,8 +343,8 @@ Op = DAG.getNode(N->getOpcode(), dl, NVT, Op); // Subtract off the extra leading bits in the bigger type. return DAG.getNode(ISD::SUB, dl, NVT, Op, - DAG.getConstant(NVT.getSizeInBits() - - OVT.getSizeInBits(), NVT)); + DAG.getConstant(NVT.getScalarSizeInBits() - + OVT.getScalarSizeInBits(), NVT)); } SDValue DAGTypeLegalizer::PromoteIntRes_CTPOP(SDNode *N) { Index: test/CodeGen/X86/pr20917.ll =================================================================== --- /dev/null +++ test/CodeGen/X86/pr20917.ll @@ -0,0 +1,17 @@ +; RUN: llc < %s -mtriple=i686-none-linux-gnueabi -mattr=+sse2 | FileCheck %s + +; CHECK: .LCPI0_1: +; CHECK-NEXT: .long 32 # 0x20 +; CHECK-NEXT: .long 0 # 0x0 +; CHECK-NEXT: .long 32 # 0x20 +; CHECK-NEXT: .long 0 # 0x0 +; CHECK: psubq .LCPI0_1 + +define <2 x i32> @test(<2 x i32> %x) { + %1 = call <2 x i32> @llvm.ctlz.v2i32(<2 x i32> %x, i1 false) + ret <2 x i32> %1 +} + +declare <2 x i32> @llvm.ctlz.v2i32(<2 x i32>, i1) + +