[llvm] r248074 - [InstCombine] FoldICmpCstShrCst failed for ashr when comparing against -1
David Majnemer via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 18 17:52:50 PDT 2015
This should have been squashed with r248073, the functional change is there.
On Fri, Sep 18, 2015 at 5:48 PM, David Majnemer via llvm-commits <
llvm-commits at lists.llvm.org> wrote:
> Author: majnemer
> Date: Fri Sep 18 19:48:31 2015
> New Revision: 248074
>
> URL: http://llvm.org/viewvc/llvm-project?rev=248074&view=rev
> Log:
> [InstCombine] FoldICmpCstShrCst failed for ashr when comparing against -1
>
> (icmp eq (ashr C1, %V) -1) may have multiple answers if C1 is not a
> power of two and has the sign bit set.
>
> This fixes PR24873.
>
> Modified:
> llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp
> llvm/trunk/test/Transforms/InstCombine/icmp-shr.ll
>
> Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp?rev=248074&r1=248073&r2=248074&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp
> (original)
> +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp Fri Sep
> 18 19:48:31 2015
> @@ -1083,7 +1083,7 @@ Instruction *InstCombiner::FoldICmpCstSh
> if (Shift > 0) {
> if (IsAShr && AP1 == AP2.ashr(Shift)) {
> // There are multiple solutions if we are comparing against -1 and
> the LHS
> - // of the ashr is not a power of two..
> + // of the ashr is not a power of two.
> if (AP1.isAllOnesValue() && !AP2.isPowerOf2())
> return getICmp(I.ICMP_UGE, A, ConstantInt::get(A->getType(),
> Shift));
> return getICmp(I.ICMP_EQ, A, ConstantInt::get(A->getType(), Shift));
>
> Modified: llvm/trunk/test/Transforms/InstCombine/icmp-shr.ll
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/icmp-shr.ll?rev=248074&r1=248073&r2=248074&view=diff
>
> ==============================================================================
> --- llvm/trunk/test/Transforms/InstCombine/icmp-shr.ll (original)
> +++ llvm/trunk/test/Transforms/InstCombine/icmp-shr.ll Fri Sep 18 19:48:31
> 2015
> @@ -376,3 +376,12 @@ define i1 @PR21222(i32 %B) {
> %cmp = icmp eq i32 %shr, -2
> ret i1 %cmp
> }
> +
> +; CHECK-LABEL: @PR24873(
> +; CHECK: %[[icmp:.*]] = icmp ugt i64 %V, 61
> +; CHECK-NEXT: ret i1 %[[icmp]]
> +define i1 @PR24873(i64 %V) {
> + %ashr = ashr i64 -4611686018427387904, %V
> + %icmp = icmp eq i64 %ashr, -1
> + ret i1 %icmp
> +}
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150918/9eed80c3/attachment.html>
More information about the llvm-commits
mailing list