From 52533b52b868e055fe86061cf71a49601d0cbeb9 Mon Sep 17 00:00:00 2001 From: Roman Lebedev Date: Tue, 1 Dec 2020 15:47:04 +0300 Subject: [PATCH] Revert "[InstCombine] Improve vector undef handling for sext(ashr(shl(trunc()))) fold" It seems i have missed checklines, temporairly reverting, will reland momentairly.. This reverts commit aa1aa135097ecfab6d9917a435142030eff0a226. --- llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp | 4 +--- llvm/test/Transforms/InstCombine/sext.ll | 16 ++++++++++------ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp index 6e94e582343..59dae932ae4 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp @@ -1520,15 +1520,13 @@ Instruction *InstCombinerImpl::visitSExt(SExtInst &CI) { Constant *BA = nullptr, *CA = nullptr; if (match(Src, m_AShr(m_Shl(m_Trunc(m_Value(A)), m_Constant(BA)), m_Constant(CA))) && - BA->isElementWiseEqual(CA) && A->getType() == DestTy) { + BA == CA && A->getType() == DestTy) { Constant *WideCurrShAmt = ConstantExpr::getSExt(CA, DestTy); Constant *NumLowbitsLeft = ConstantExpr::getSub( ConstantInt::get(DestTy, SrcTy->getScalarSizeInBits()), WideCurrShAmt); Constant *NewShAmt = ConstantExpr::getSub( ConstantInt::get(DestTy, DestTy->getScalarSizeInBits()), NumLowbitsLeft); - NewShAmt = - Constant::mergeUndefsWith(Constant::mergeUndefsWith(NewShAmt, BA), CA); A = Builder.CreateShl(A, NewShAmt, CI.getName()); return BinaryOperator::CreateAShr(A, NewShAmt); } diff --git a/llvm/test/Transforms/InstCombine/sext.ll b/llvm/test/Transforms/InstCombine/sext.ll index ebab23a1952..319c07d9f8a 100644 --- a/llvm/test/Transforms/InstCombine/sext.ll +++ b/llvm/test/Transforms/InstCombine/sext.ll @@ -167,8 +167,10 @@ define <2 x i32> @test10_vec_nonuniform(<2 x i32> %i) { define <2 x i32> @test10_vec_undef0(<2 x i32> %i) { ; CHECK-LABEL: @test10_vec_undef0( -; CHECK-NEXT: [[D1:%.*]] = shl <2 x i32> [[I:%.*]], -; CHECK-NEXT: [[D:%.*]] = ashr <2 x i32> [[D1]], +; CHECK-NEXT: [[A:%.*]] = trunc <2 x i32> [[I:%.*]] to <2 x i8> +; CHECK-NEXT: [[B:%.*]] = shl <2 x i8> [[A]], +; CHECK-NEXT: [[C:%.*]] = ashr <2 x i8> [[B]], +; CHECK-NEXT: [[D:%.*]] = sext <2 x i8> [[C]] to <2 x i32> ; CHECK-NEXT: ret <2 x i32> [[D]] ; %A = trunc <2 x i32> %i to <2 x i8> @@ -179,8 +181,10 @@ define <2 x i32> @test10_vec_undef0(<2 x i32> %i) { } define <2 x i32> @test10_vec_undef1(<2 x i32> %i) { ; CHECK-LABEL: @test10_vec_undef1( -; CHECK-NEXT: [[D1:%.*]] = shl <2 x i32> [[I:%.*]], -; CHECK-NEXT: [[D:%.*]] = ashr <2 x i32> [[D1]], +; CHECK-NEXT: [[A:%.*]] = trunc <2 x i32> [[I:%.*]] to <2 x i8> +; CHECK-NEXT: [[B:%.*]] = shl <2 x i8> [[A]], +; CHECK-NEXT: [[C:%.*]] = ashr <2 x i8> [[B]], +; CHECK-NEXT: [[D:%.*]] = sext <2 x i8> [[C]] to <2 x i32> ; CHECK-NEXT: ret <2 x i32> [[D]] ; %A = trunc <2 x i32> %i to <2 x i8> @@ -191,8 +195,8 @@ define <2 x i32> @test10_vec_undef1(<2 x i32> %i) { } define <2 x i32> @test10_vec_undef2(<2 x i32> %i) { ; CHECK-LABEL: @test10_vec_undef2( -; CHECK-NEXT: [[D1:%.*]] = shl <2 x i32> [[I:%.*]], -; CHECK-NEXT: [[D:%.*]] = ashr <2 x i32> [[D1]], +; CHECK-NEXT: [[D1:%.*]] = shl <2 x i32> [[I:%.*]], +; CHECK-NEXT: [[D:%.*]] = ashr <2 x i32> [[D1]], ; CHECK-NEXT: ret <2 x i32> [[D]] ; %A = trunc <2 x i32> %i to <2 x i8> -- 2.11.0