[llvm] 6de741d - Revert "[InstCombine] Fold (sext bool X) * (sext bool X) to zext (and X, X)"
Daniil Seredkin via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 18 00:21:23 PDT 2021
Author: Daniil Seredkin
Date: 2021-06-18T14:21:02+07:00
New Revision: 6de741de08a11048027cb4d4e4d5d4bd067319fa
URL: https://github.com/llvm/llvm-project/commit/6de741de08a11048027cb4d4e4d5d4bd067319fa
DIFF: https://github.com/llvm/llvm-project/commit/6de741de08a11048027cb4d4e4d5d4bd067319fa.diff
LOG: Revert "[InstCombine] Fold (sext bool X) * (sext bool X) to zext (and X, X)"
This reverts commit 31053338c97b36ffb582f9c04a74cec69cce3e70.
Added:
Modified:
llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
llvm/test/Transforms/InstCombine/mul.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp b/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
index 6f2a8ebf839a7..4e7b8d0ddb341 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
@@ -328,7 +328,7 @@ Instruction *InstCombinerImpl::visitMul(BinaryOperator &I) {
if (((match(Op0, m_ZExt(m_Value(X))) && match(Op1, m_ZExt(m_Value(Y)))) ||
(match(Op0, m_SExt(m_Value(X))) && match(Op1, m_SExt(m_Value(Y))))) &&
X->getType()->isIntOrIntVectorTy(1) && X->getType() == Y->getType() &&
- (Op0->hasOneUse() || Op1->hasOneUse() || X == Y)) {
+ (Op0->hasOneUse() || Op1->hasOneUse())) {
Value *And = Builder.CreateAnd(X, Y, "mulbool");
return CastInst::Create(Instruction::ZExt, And, I.getType());
}
diff --git a/llvm/test/Transforms/InstCombine/mul.ll b/llvm/test/Transforms/InstCombine/mul.ll
index b3b94760523a8..8a279f1e10347 100644
--- a/llvm/test/Transforms/InstCombine/mul.ll
+++ b/llvm/test/Transforms/InstCombine/mul.ll
@@ -318,76 +318,6 @@ define i32 @mul_bool_zext_one_extra_user(i1 %x) {
ret i32 %r
}
-define i32 @mul_bools_sext_one_use_per_op(i1 %x, i1 %y) {
-; CHECK-LABEL: @mul_bools_sext_one_use_per_op(
-; CHECK-NEXT: [[MULBOOL:%.*]] = and i1 [[X:%.*]], [[Y:%.*]]
-; CHECK-NEXT: [[R:%.*]] = zext i1 [[MULBOOL]] to i32
-; CHECK-NEXT: ret i32 [[R]]
-;
- %sx = sext i1 %x to i32
- %sy = sext i1 %y to i32
- %r = mul i32 %sx, %sy
- ret i32 %r
-}
-
-define i32 @mul_bool_sext_one_user(i1 %x) {
-; CHECK-LABEL: @mul_bool_sext_one_user(
-; CHECK-NEXT: [[R:%.*]] = zext i1 [[X:%.*]] to i32
-; CHECK-NEXT: ret i32 [[R]]
-;
- %sx = sext i1 %x to i32
- %r = mul i32 %sx, %sx
- ret i32 %r
-}
-
-define i32 @mul_bools_zext_one_use_per_op(i1 %x, i1 %y) {
-; CHECK-LABEL: @mul_bools_zext_one_use_per_op(
-; CHECK-NEXT: [[MULBOOL:%.*]] = and i1 [[X:%.*]], [[Y:%.*]]
-; CHECK-NEXT: [[R:%.*]] = zext i1 [[MULBOOL]] to i32
-; CHECK-NEXT: ret i32 [[R]]
-;
- %zx = zext i1 %x to i32
- %zy = zext i1 %y to i32
- %r = mul i32 %zx, %zy
- ret i32 %r
-}
-
-define i32 @mul_bool_zext_one_user(i1 %x) {
-; CHECK-LABEL: @mul_bool_zext_one_user(
-; CHECK-NEXT: [[R:%.*]] = zext i1 [[X:%.*]] to i32
-; CHECK-NEXT: ret i32 [[R]]
-;
- %sx = zext i1 %x to i32
- %r = mul i32 %sx, %sx
- ret i32 %r
-}
-
-define i32 @mul_bool_sext_one_extra_user(i1 %x) {
-; CHECK-LABEL: @mul_bool_sext_one_extra_user(
-; CHECK-NEXT: [[SX:%.*]] = sext i1 [[X:%.*]] to i32
-; CHECK-NEXT: call void @use32(i32 [[SX]])
-; CHECK-NEXT: [[R:%.*]] = zext i1 [[X]] to i32
-; CHECK-NEXT: ret i32 [[R]]
-;
- %sx = sext i1 %x to i32
- call void @use32(i32 %sx)
- %r = mul i32 %sx, %sx
- ret i32 %r
-}
-
-define i32 @mul_bool_zext_one_extra_user(i1 %x) {
-; CHECK-LABEL: @mul_bool_zext_one_extra_user(
-; CHECK-NEXT: [[SX:%.*]] = zext i1 [[X:%.*]] to i32
-; CHECK-NEXT: call void @use32(i32 [[SX]])
-; CHECK-NEXT: [[R:%.*]] = zext i1 [[X]] to i32
-; CHECK-NEXT: ret i32 [[R]]
-;
- %sx = zext i1 %x to i32
- call void @use32(i32 %sx)
- %r = mul i32 %sx, %sx
- ret i32 %r
-}
-
define <3 x i32> @mul_bools_mixed_ext(<3 x i1> %x, <3 x i1> %y) {
; CHECK-LABEL: @mul_bools_mixed_ext(
; CHECK-NEXT: [[MULBOOL:%.*]] = and <3 x i1> [[X:%.*]], [[Y:%.*]]
More information about the llvm-commits
mailing list