diff --git a/llvm/lib/CodeGen/TargetLoweringBase.cpp b/llvm/lib/CodeGen/TargetLoweringBase.cpp index ff684c7cb6bba..c1a4e5d198ac4 100644 --- a/llvm/lib/CodeGen/TargetLoweringBase.cpp +++ b/llvm/lib/CodeGen/TargetLoweringBase.cpp @@ -1057,8 +1057,7 @@ EVT TargetLoweringBase::getShiftAmountTy(EVT LHSTy, const DataLayout &DL, assert(LHSTy.isInteger() && "Shift amount is not an integer type!"); if (LHSTy.isVector()) return LHSTy; - MVT ShiftVT = - LegalTypes ? getScalarShiftAmountTy(DL, LHSTy) : getPointerTy(DL); + MVT ShiftVT = getScalarShiftAmountTy(DL, LHSTy); // If any possible shift value won't fit in the prefered type, just use // something safe. Assume it will be legalized when the shift is expanded. if (ShiftVT.getSizeInBits() < Log2_32_Ceil(LHSTy.getSizeInBits())) diff --git a/llvm/test/CodeGen/X86/shift-combine.ll b/llvm/test/CodeGen/X86/shift-combine.ll index 30c3d53dd37c9..c9edd3f3e9048 100644 --- a/llvm/test/CodeGen/X86/shift-combine.ll +++ b/llvm/test/CodeGen/X86/shift-combine.ll @@ -444,12 +444,10 @@ define i64 @ashr_add_neg_shl_i32(i64 %r) nounwind { define i64 @ashr_add_neg_shl_i8(i64 %r) nounwind { ; X86-LABEL: ashr_add_neg_shl_i8: ; X86: # %bb.0: -; X86-NEXT: movl {{[0-9]+}}(%esp), %eax -; X86-NEXT: shll $24, %eax -; X86-NEXT: movl $33554432, %edx # imm = 0x2000000 -; X86-NEXT: subl %eax, %edx -; X86-NEXT: movl %edx, %eax -; X86-NEXT: sarl $24, %eax +; X86-NEXT: movb $2, %al +; X86-NEXT: subb {{[0-9]+}}(%esp), %al +; X86-NEXT: movsbl %al, %eax +; X86-NEXT: movl %eax, %edx ; X86-NEXT: sarl $31, %edx ; X86-NEXT: retl ;