diff --git a/lib/Transforms/InstCombine/InstCombineCalls.cpp b/lib/Transforms/InstCombine/InstCombineCalls.cpp index b44499ec4be..644dfd50adc 100644 --- a/lib/Transforms/InstCombine/InstCombineCalls.cpp +++ b/lib/Transforms/InstCombine/InstCombineCalls.cpp @@ -1373,10 +1373,6 @@ static Instruction *foldCttzCtlz(IntrinsicInst &II, InstCombiner &IC) { II.getIntrinsicID() == Intrinsic::ctlz) && "Expected cttz or ctlz intrinsic"); Value *Op0 = II.getArgOperand(0); - // FIXME: Try to simplify vectors of integers. - auto *IT = dyn_cast(Op0->getType()); - if (!IT) - return nullptr; KnownBits Known = IC.computeKnownBits(Op0, 0, &II); @@ -1392,7 +1388,7 @@ static Instruction *foldCttzCtlz(IntrinsicInst &II, InstCombiner &IC) { // FIXME: This should be in InstSimplify because we're replacing an // instruction with a constant. if (PossibleZeros == DefiniteZeros) { - auto *C = ConstantInt::get(IT, DefiniteZeros); + auto *C = ConstantInt::get(Op0->getType(), DefiniteZeros); return IC.replaceInstUsesWith(II, C); } diff --git a/test/Transforms/InstCombine/intrinsics.ll b/test/Transforms/InstCombine/intrinsics.ll index abe0c784754..1b1ed606868 100644 --- a/test/Transforms/InstCombine/intrinsics.ll +++ b/test/Transforms/InstCombine/intrinsics.ll @@ -285,10 +285,7 @@ define i32 @cttz(i32 %a) { define <2 x i32> @cttz_vec(<2 x i32> %a) { ; CHECK-LABEL: @cttz_vec( -; CHECK-NEXT: [[OR:%.*]] = or <2 x i32> [[A:%.*]], -; CHECK-NEXT: [[AND:%.*]] = and <2 x i32> [[OR]], -; CHECK-NEXT: [[COUNT:%.*]] = tail call <2 x i32> @llvm.cttz.v2i32(<2 x i32> [[AND]], i1 true) -; CHECK-NEXT: ret <2 x i32> [[COUNT]] +; CHECK-NEXT: ret <2 x i32> ; %or = or <2 x i32> %a, %and = and <2 x i32> %or, @@ -382,10 +379,7 @@ define i8 @ctlz(i8 %a) { define <2 x i8> @ctlz_vec(<2 x i8> %a) { ; CHECK-LABEL: @ctlz_vec( -; CHECK-NEXT: [[OR:%.*]] = or <2 x i8> [[A:%.*]], -; CHECK-NEXT: [[AND:%.*]] = and <2 x i8> [[OR]], -; CHECK-NEXT: [[COUNT:%.*]] = tail call <2 x i8> @llvm.ctlz.v2i8(<2 x i8> [[AND]], i1 true) -; CHECK-NEXT: ret <2 x i8> [[COUNT]] +; CHECK-NEXT: ret <2 x i8> ; %or = or <2 x i8> %a, %and = and <2 x i8> %or, @@ -556,7 +550,7 @@ define i32 @ctlz_make_undef(i32 %a) { define <2 x i32> @ctlz_make_undef_vec(<2 x i32> %a) { ; CHECK-LABEL: @ctlz_make_undef_vec( ; CHECK-NEXT: [[OR:%.*]] = or <2 x i32> [[A:%.*]], -; CHECK-NEXT: [[CTLZ:%.*]] = tail call <2 x i32> @llvm.ctlz.v2i32(<2 x i32> [[OR]], i1 false) +; CHECK-NEXT: [[CTLZ:%.*]] = tail call <2 x i32> @llvm.ctlz.v2i32(<2 x i32> [[OR]], i1 true) ; CHECK-NEXT: ret <2 x i32> [[CTLZ]] ; %or = or <2 x i32> %a, @@ -593,7 +587,7 @@ define i32 @cttz_make_undef(i32 %a) { define <2 x i32> @cttz_make_undef_vec(<2 x i32> %a) { ; CHECK-LABEL: @cttz_make_undef_vec( ; CHECK-NEXT: [[OR:%.*]] = or <2 x i32> [[A:%.*]], -; CHECK-NEXT: [[CTTZ:%.*]] = tail call <2 x i32> @llvm.cttz.v2i32(<2 x i32> [[OR]], i1 false) +; CHECK-NEXT: [[CTTZ:%.*]] = tail call <2 x i32> @llvm.cttz.v2i32(<2 x i32> [[OR]], i1 true) ; CHECK-NEXT: ret <2 x i32> [[CTTZ]] ; %or = or <2 x i32> %a,