diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp index f7be0f9bc3f3..5e4fd8c26567 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp @@ -818,9 +818,7 @@ Instruction *InstCombiner::transformZExtICmp(ICmpInst *ICI, ZExtInst &CI, if (!Op1CV->isNullValue() && (*Op1CV != KnownZeroMask)) { // (X&4) == 2 --> false // (X&4) != 2 --> true - Constant *Res = ConstantInt::get(Type::getInt1Ty(CI.getContext()), - isNE); - Res = ConstantExpr::getZExt(Res, CI.getType()); + Constant *Res = ConstantInt::get(CI.getType(), isNE); return replaceInstUsesWith(CI, Res); } diff --git a/llvm/test/Transforms/InstCombine/div.ll b/llvm/test/Transforms/InstCombine/div.ll index b323e31e63ec..42da1382f976 100644 --- a/llvm/test/Transforms/InstCombine/div.ll +++ b/llvm/test/Transforms/InstCombine/div.ll @@ -553,3 +553,12 @@ define i32 @shrink_no3(i16 %x) { ret i32 %div } +; This previously crashed when trying to simplify the zext/icmp this becomes. +define <2 x i8> @PR34841(<2 x i8> %x) { +; CHECK-LABEL: @PR34841( +; CHECK-NEXT: ret <2 x i8> zeroinitializer +; + %neg = and <2 x i8> %x, + %div = udiv <2 x i8> , %neg + ret <2 x i8> %div +}