diff --git a/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp b/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp index c69b305dfa7b..9c6bc1a1044d 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp @@ -811,15 +811,6 @@ Instruction *InstCombiner::visitLShr(BinaryOperator &I) { return &I; } } - - // Transform (x << y) >> y to x & (-1 >> y) - Value *X; - if (match(Op0, m_OneUse(m_Shl(m_Value(X), m_Specific(Op1))))) { - Constant *AllOnes = ConstantInt::getAllOnesValue(Ty); - Value *Mask = Builder.CreateLShr(AllOnes, Op1); - return BinaryOperator::CreateAnd(Mask, X); - } - return nullptr; } diff --git a/llvm/test/Transforms/InstCombine/canonicalize-shl-lshr-to-masking.ll b/llvm/test/Transforms/InstCombine/canonicalize-shl-lshr-to-masking.ll index 9de0b337de28..81af5a7979e7 100644 --- a/llvm/test/Transforms/InstCombine/canonicalize-shl-lshr-to-masking.ll +++ b/llvm/test/Transforms/InstCombine/canonicalize-shl-lshr-to-masking.ll @@ -14,8 +14,8 @@ define i32 @positive_samevar(i32 %x, i32 %y) { ; CHECK-LABEL: @positive_samevar( -; CHECK-NEXT: [[TMP1:%.*]] = lshr i32 -1, [[Y:%.*]] -; CHECK-NEXT: [[RET:%.*]] = and i32 [[TMP1]], [[X:%.*]] +; CHECK-NEXT: [[TMP0:%.*]] = shl i32 [[X:%.*]], [[Y:%.*]] +; CHECK-NEXT: [[RET:%.*]] = lshr i32 [[TMP0]], [[Y]] ; CHECK-NEXT: ret i32 [[RET]] ; %tmp0 = shl i32 %x, %y @@ -124,8 +124,8 @@ define i32 @positive_biggerLshr_shlnuw_lshrexact(i32 %x) { define <2 x i32> @positive_samevar_vec(<2 x i32> %x, <2 x i32> %y) { ; CHECK-LABEL: @positive_samevar_vec( -; CHECK-NEXT: [[TMP1:%.*]] = lshr <2 x i32> , [[Y:%.*]] -; CHECK-NEXT: [[RET:%.*]] = and <2 x i32> [[TMP1]], [[X:%.*]] +; CHECK-NEXT: [[TMP0:%.*]] = shl <2 x i32> [[X:%.*]], [[Y:%.*]] +; CHECK-NEXT: [[RET:%.*]] = lshr <2 x i32> [[TMP0]], [[Y]] ; CHECK-NEXT: ret <2 x i32> [[RET]] ; %tmp0 = shl <2 x i32> %x, %y @@ -171,7 +171,8 @@ define <3 x i32> @positive_sameconst_vec_undef1(<3 x i32> %x) { define <3 x i32> @positive_sameconst_vec_undef2(<3 x i32> %x) { ; CHECK-LABEL: @positive_sameconst_vec_undef2( -; CHECK-NEXT: [[RET:%.*]] = and <3 x i32> [[X:%.*]], +; CHECK-NEXT: [[TMP0:%.*]] = shl <3 x i32> [[X:%.*]], +; CHECK-NEXT: [[RET:%.*]] = lshr <3 x i32> [[TMP0]], ; CHECK-NEXT: ret <3 x i32> [[RET]] ; %tmp0 = shl <3 x i32> %x,