From: Roman Lebedev Date: Sat, 10 Aug 2019 19:28:44 +0000 (+0000) Subject: [InstCombine] Shift amount reassociation in bittest: drop pointless one-use restriction X-Git-Tag: llvmorg-11-init~12191 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=64fe806c4e11d90d8abaed65b659673be677b856;p=platform%2Fupstream%2Fllvm.git [InstCombine] Shift amount reassociation in bittest: drop pointless one-use restriction That one-use restriction is not needed for correctness - we have already ensured that one of the shifts will go away, so we know we won't increase the instruction count. So there is no need for that restriction. llvm-svn: 368518 --- diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp index ddbc170..edad6a4 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp @@ -3318,8 +3318,8 @@ foldShiftIntoShiftInAnotherHandOfAndInICmp(ICmpInst &I, const SimplifyQuery SQ, m_CombineAnd(m_AnyLogicalShift, m_Value(YShift))))) return nullptr; - // If YShift is a single-use 'lshr', swap the shifts around. - if (match(YShift, m_OneUse(m_AnyLShr))) + // If YShift is a 'lshr', swap the shifts around. + if (match(YShift, m_AnyLShr)) std::swap(XShift, YShift); // The shifts must be in opposite directions. diff --git a/llvm/test/Transforms/InstCombine/shift-amount-reassociation-in-bittest.ll b/llvm/test/Transforms/InstCombine/shift-amount-reassociation-in-bittest.ll index b2c0012..18e8cfa 100644 --- a/llvm/test/Transforms/InstCombine/shift-amount-reassociation-in-bittest.ll +++ b/llvm/test/Transforms/InstCombine/shift-amount-reassociation-in-bittest.ll @@ -279,8 +279,8 @@ define i1 @t18_const_oneuse0(i32 %x, i32 %y) { ; CHECK-LABEL: @t18_const_oneuse0( ; CHECK-NEXT: [[T0:%.*]] = lshr i32 [[X:%.*]], 1 ; CHECK-NEXT: call void @use32(i32 [[T0]]) -; CHECK-NEXT: [[TMP1:%.*]] = shl i32 [[Y:%.*]], 2 -; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], [[X]] +; CHECK-NEXT: [[TMP1:%.*]] = lshr i32 [[X]], 2 +; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], [[Y:%.*]] ; CHECK-NEXT: [[TMP3:%.*]] = icmp ne i32 [[TMP2]], 0 ; CHECK-NEXT: ret i1 [[TMP3]] ; @@ -585,8 +585,8 @@ define i1 @t34_commutativity0_oneuse0(i32 %x) { ; CHECK-NEXT: [[Y:%.*]] = call i32 @gen32() ; CHECK-NEXT: [[T0:%.*]] = lshr i32 [[X:%.*]], 1 ; CHECK-NEXT: call void @use32(i32 [[T0]]) -; CHECK-NEXT: [[TMP1:%.*]] = shl i32 [[Y]], 2 -; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], [[X]] +; CHECK-NEXT: [[TMP1:%.*]] = lshr i32 [[X]], 2 +; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], [[Y]] ; CHECK-NEXT: [[TMP3:%.*]] = icmp ne i32 [[TMP2]], 0 ; CHECK-NEXT: ret i1 [[TMP3]] ; @@ -622,8 +622,8 @@ define i1 @t36_commutativity1_oneuse0(i32 %y) { ; CHECK-NEXT: [[X:%.*]] = call i32 @gen32() ; CHECK-NEXT: [[T0:%.*]] = lshr i32 [[X]], 1 ; CHECK-NEXT: call void @use32(i32 [[T0]]) -; CHECK-NEXT: [[TMP1:%.*]] = shl i32 [[Y:%.*]], 2 -; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], [[X]] +; CHECK-NEXT: [[TMP1:%.*]] = lshr i32 [[X]], 2 +; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], [[Y:%.*]] ; CHECK-NEXT: [[TMP3:%.*]] = icmp ne i32 [[TMP2]], 0 ; CHECK-NEXT: ret i1 [[TMP3]] ;