[llvm] r334373 - Revert rL334371 / D47980: "[InstCombine] Fold (x << y) >> y -> x & (-1 >> y)"
Roman Lebedev via llvm-commits
llvm-commits at lists.llvm.org
Sun Jun 10 13:32:03 PDT 2018
Author: lebedevri
Date: Sun Jun 10 13:32:03 2018
New Revision: 334373
URL: http://llvm.org/viewvc/llvm-project?rev=334373&view=rev
Log:
Revert rL334371 / D47980: "[InstCombine] Fold (x << y) >> y -> x & (-1 >> y)"
test/Transforms/InstCombine/AMDGPU/amdgcn-intrinsics.ll broke,
and i did not notice because i did not build that backend.
Modified:
llvm/trunk/lib/Transforms/InstCombine/InstCombineShifts.cpp
llvm/trunk/test/Transforms/InstCombine/canonicalize-shl-lshr-to-masking.ll
Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineShifts.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineShifts.cpp?rev=334373&r1=334372&r2=334373&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineShifts.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineShifts.cpp Sun Jun 10 13:32:03 2018
@@ -811,15 +811,6 @@ Instruction *InstCombiner::visitLShr(Bin
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;
}
Modified: llvm/trunk/test/Transforms/InstCombine/canonicalize-shl-lshr-to-masking.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/canonicalize-shl-lshr-to-masking.ll?rev=334373&r1=334372&r2=334373&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/canonicalize-shl-lshr-to-masking.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/canonicalize-shl-lshr-to-masking.ll Sun Jun 10 13:32:03 2018
@@ -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_l
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> <i32 -1, i32 -1>, [[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
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:%.*]], <i32 134217727, i32 undef, i32 134217727>
+; CHECK-NEXT: [[TMP0:%.*]] = shl <3 x i32> [[X:%.*]], <i32 5, i32 undef, i32 5>
+; CHECK-NEXT: [[RET:%.*]] = lshr <3 x i32> [[TMP0]], <i32 5, i32 undef, i32 5>
; CHECK-NEXT: ret <3 x i32> [[RET]]
;
%tmp0 = shl <3 x i32> %x, <i32 5, i32 undef, i32 5>
More information about the llvm-commits
mailing list