From: Sanjay Patel Date: Wed, 31 Aug 2016 22:18:43 +0000 (+0000) Subject: [InstCombine] allow icmp (shr exact X, C2), C fold for splat constant vectors X-Git-Tag: llvmorg-4.0.0-rc1~10938 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0d70831d733f89d743ce5e4444796b834ae5797c;p=platform%2Fupstream%2Fllvm.git [InstCombine] allow icmp (shr exact X, C2), C fold for splat constant vectors The enhancement to foldICmpDivConstant ( http://llvm.org/viewvc/llvm-project?view=revision&revision=280299 ) allows us to remove the ConstantInt check; no other changes needed. llvm-svn: 280300 --- diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp index a564771..d05b8d1 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp @@ -1876,11 +1876,6 @@ Instruction *InstCombiner::foldICmpShrConstant(ICmpInst &Cmp, if (IsAShr && (!Shr->isExact() || ShAmtVal == TypeBits - 1)) return nullptr; - // FIXME: This check restricts this fold to scalar types. - ConstantInt *ShAmt = dyn_cast(Shr->getOperand(1)); - if (!ShAmt) - return nullptr; - // Revisit the shift (to delete it). Worklist.Add(Shr); diff --git a/llvm/test/Transforms/InstCombine/exact.ll b/llvm/test/Transforms/InstCombine/exact.ll index f93bc8e..cf10b70 100644 --- a/llvm/test/Transforms/InstCombine/exact.ll +++ b/llvm/test/Transforms/InstCombine/exact.ll @@ -120,11 +120,9 @@ define i1 @ashr_icmp2(i64 %X) { ret i1 %Z } -; FIXME: Vectors should fold the same way. define <2 x i1> @ashr_icmp2_vec(<2 x i64> %X) { ; CHECK-LABEL: @ashr_icmp2_vec( -; CHECK-NEXT: [[Y:%.*]] = ashr exact <2 x i64> %X, -; CHECK-NEXT: [[Z:%.*]] = icmp slt <2 x i64> [[Y]], +; CHECK-NEXT: [[Z:%.*]] = icmp slt <2 x i64> %X, ; CHECK-NEXT: ret <2 x i1> [[Z]] ; %Y = ashr exact <2 x i64> %X,