From 92c2acd055885e7e329fca25b9233fadd0da0dd0 Mon Sep 17 00:00:00 2001 From: NAKAMURA Takumi Date: Fri, 21 Aug 2015 07:46:07 +0000 Subject: [PATCH] Revert r245635, "[InstCombine] Transform A & (L - 1) u< L --> L != 0" It caused miscompilation in clang. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@245678 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../InstCombine/InstCombineCompares.cpp | 13 ------------ test/Transforms/InstCombine/icmp.ll | 20 ------------------- 2 files changed, 33 deletions(-) diff --git a/lib/Transforms/InstCombine/InstCombineCompares.cpp b/lib/Transforms/InstCombine/InstCombineCompares.cpp index dbf43f7769c..9ce1c3fc41b 100644 --- a/lib/Transforms/InstCombine/InstCombineCompares.cpp +++ b/lib/Transforms/InstCombine/InstCombineCompares.cpp @@ -3490,19 +3490,6 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) { } } } - - if (BO0) { - // Transform A & (L - 1) `ult` L --> L != 0 - Value *L; - auto LSubOne = m_Add(m_Value(L), m_AllOnes()); - auto BitwiseAnd = - m_CombineOr(m_And(m_Value(), LSubOne), m_And(LSubOne, m_Value())); - - if (match(BO0, BitwiseAnd) && I.getPredicate() == ICmpInst::ICMP_ULT) { - auto *Zero = Constant::getNullValue(BO0->getType()); - return new ICmpInst(ICmpInst::ICMP_NE, L, Zero); - } - } } { Value *A, *B; diff --git a/test/Transforms/InstCombine/icmp.ll b/test/Transforms/InstCombine/icmp.ll index 5d97411625e..edcf76d5a7d 100644 --- a/test/Transforms/InstCombine/icmp.ll +++ b/test/Transforms/InstCombine/icmp.ll @@ -1603,23 +1603,3 @@ define i32 @f7(i32 %a, i32 %b) { %s = select i1 %cmp, i32 10000, i32 0 ret i32 %s } - -; CHECK: @f8( -; CHECK-NEXT: [[RESULT:%[a-z0-9]+]] = icmp ne i32 %lim, 0 -; CHECK-NEXT: ret i1 [[RESULT]] -define i1 @f8(i32 %val, i32 %lim) { - %lim.sub = add i32 %lim, -1 - %val.and = and i32 %val, %lim.sub - %r = icmp ult i32 %val.and, %lim - ret i1 %r -} - -; CHECK: @f9( -; CHECK-NEXT: [[RESULT:%[a-z0-9]+]] = icmp ne i32 %lim, 0 -; CHECK-NEXT: ret i1 [[RESULT]] -define i1 @f9(i32 %val, i32 %lim) { - %lim.sub = sub i32 %lim, 1 - %val.and = and i32 %val, %lim.sub - %r = icmp ult i32 %val.and, %lim - ret i1 %r -} -- 2.34.1