[llvm] [InstCombine] Fold select (A & Shift == 0 | B & Shift == 0), 0, Shift to Shift & A & B (PR #212132)
Shengxin Pei via llvm-commits
llvm-commits at lists.llvm.org
Sun Aug 9 12:27:00 PDT 2026
https://github.com/TPPPP72 updated https://github.com/llvm/llvm-project/pull/212132
>From 75d3cd44dc9a0bc56e371162a8c916fdf242a4c7 Mon Sep 17 00:00:00 2001
From: Shengxin Pei <TPPPP72 at outlook.com>
Date: Mon, 10 Aug 2026 03:26:10 +0800
Subject: [PATCH 1/2] [InstCombine][NFC] Add baseline tests for select
power-of-two folds
---
.../InstCombine/select-and-or-powerof2.ll | 178 ++++++++++++++++++
1 file changed, 178 insertions(+)
create mode 100644 llvm/test/Transforms/InstCombine/select-and-or-powerof2.ll
diff --git a/llvm/test/Transforms/InstCombine/select-and-or-powerof2.ll b/llvm/test/Transforms/InstCombine/select-and-or-powerof2.ll
new file mode 100644
index 0000000000000..3403b209618f0
--- /dev/null
+++ b/llvm/test/Transforms/InstCombine/select-and-or-powerof2.ll
@@ -0,0 +1,178 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 6
+; RUN: opt < %s -passes=instcombine -S | FileCheck %s
+
+define i8 @select_or_eq_zero_powerof2(i8 %a, i8 %b, i8 %mask) {
+; CHECK-LABEL: define i8 @select_or_eq_zero_powerof2(
+; CHECK-SAME: i8 [[A:%.*]], i8 [[B:%.*]], i8 [[MASK:%.*]]) {
+; CHECK-NEXT: [[SH:%.*]] = shl nuw i8 1, [[MASK]]
+; CHECK-NEXT: [[AND_1:%.*]] = and i8 [[SH]], [[A]]
+; CHECK-NEXT: [[LSB_1:%.*]] = icmp eq i8 [[AND_1]], 0
+; CHECK-NEXT: [[AND_2:%.*]] = and i8 [[SH]], [[B]]
+; CHECK-NEXT: [[LSB_2:%.*]] = icmp eq i8 [[AND_2]], 0
+; CHECK-NEXT: [[OR:%.*]] = or i1 [[LSB_1]], [[LSB_2]]
+; CHECK-NEXT: [[ZERO_OR_SHIFT:%.*]] = select i1 [[OR]], i8 0, i8 [[SH]]
+; CHECK-NEXT: ret i8 [[ZERO_OR_SHIFT]]
+;
+ %sh = shl nuw i8 1, %mask
+ %and_1 = and i8 %sh, %a
+ %lsb_1 = icmp eq i8 %and_1, 0
+ %and_2 = and i8 %sh, %b
+ %lsb_2 = icmp eq i8 %and_2, 0
+ %or = or i1 %lsb_1, %lsb_2
+ %zero_or_shift = select i1 %or, i8 0, i8 %sh
+ ret i8 %zero_or_shift
+}
+
+define i8 @select_and_ne_zero_powerof2(i8 %a, i8 %b, i8 %mask) {
+; CHECK-LABEL: define i8 @select_and_ne_zero_powerof2(
+; CHECK-SAME: i8 [[A:%.*]], i8 [[B:%.*]], i8 [[MASK:%.*]]) {
+; CHECK-NEXT: [[SH:%.*]] = shl nuw i8 1, [[MASK]]
+; CHECK-NEXT: [[AND_1:%.*]] = and i8 [[SH]], [[A]]
+; CHECK-NEXT: [[LSB_1:%.*]] = icmp ne i8 [[AND_1]], 0
+; CHECK-NEXT: [[AND_2:%.*]] = and i8 [[SH]], [[B]]
+; CHECK-NEXT: [[LSB_2:%.*]] = icmp ne i8 [[AND_2]], 0
+; CHECK-NEXT: [[AND_COND:%.*]] = and i1 [[LSB_1]], [[LSB_2]]
+; CHECK-NEXT: [[ZERO_OR_SHIFT:%.*]] = select i1 [[AND_COND]], i8 [[SH]], i8 0
+; CHECK-NEXT: ret i8 [[ZERO_OR_SHIFT]]
+;
+ %sh = shl nuw i8 1, %mask
+ %and_1 = and i8 %sh, %a
+ %lsb_1 = icmp ne i8 %and_1, 0
+ %and_2 = and i8 %sh, %b
+ %lsb_2 = icmp ne i8 %and_2, 0
+ %and_cond = and i1 %lsb_1, %lsb_2
+ %zero_or_shift = select i1 %and_cond, i8 %sh, i8 0
+ ret i8 %zero_or_shift
+}
+
+define i8 @select_or_eq_zero_powerof2_commuted(i8 %a, i8 %b, i8 %mask) {
+; CHECK-LABEL: define i8 @select_or_eq_zero_powerof2_commuted(
+; CHECK-SAME: i8 [[A:%.*]], i8 [[B:%.*]], i8 [[MASK:%.*]]) {
+; CHECK-NEXT: [[SH:%.*]] = shl nuw i8 1, [[MASK]]
+; CHECK-NEXT: [[AND_1:%.*]] = and i8 [[A]], [[SH]]
+; CHECK-NEXT: [[LSB_1:%.*]] = icmp eq i8 [[AND_1]], 0
+; CHECK-NEXT: [[AND_2:%.*]] = and i8 [[B]], [[SH]]
+; CHECK-NEXT: [[LSB_2:%.*]] = icmp eq i8 [[AND_2]], 0
+; CHECK-NEXT: [[OR:%.*]] = or i1 [[LSB_1]], [[LSB_2]]
+; CHECK-NEXT: [[ZERO_OR_SHIFT:%.*]] = select i1 [[OR]], i8 0, i8 [[SH]]
+; CHECK-NEXT: ret i8 [[ZERO_OR_SHIFT]]
+;
+ %sh = shl nuw i8 1, %mask
+ %and_1 = and i8 %a, %sh
+ %lsb_1 = icmp eq i8 %and_1, 0
+ %and_2 = and i8 %b, %sh
+ %lsb_2 = icmp eq i8 %and_2, 0
+ %or = or i1 %lsb_1, %lsb_2
+ %zero_or_shift = select i1 %or, i8 0, i8 %sh
+ ret i8 %zero_or_shift
+}
+
+define i8 @select_and_ne_zero_powerof2_commuted(i8 %a, i8 %b, i8 %mask) {
+; CHECK-LABEL: define i8 @select_and_ne_zero_powerof2_commuted(
+; CHECK-SAME: i8 [[A:%.*]], i8 [[B:%.*]], i8 [[MASK:%.*]]) {
+; CHECK-NEXT: [[SH:%.*]] = shl nuw i8 1, [[MASK]]
+; CHECK-NEXT: [[AND_1:%.*]] = and i8 [[A]], [[SH]]
+; CHECK-NEXT: [[LSB_1:%.*]] = icmp ne i8 [[AND_1]], 0
+; CHECK-NEXT: [[AND_2:%.*]] = and i8 [[B]], [[SH]]
+; CHECK-NEXT: [[LSB_2:%.*]] = icmp ne i8 [[AND_2]], 0
+; CHECK-NEXT: [[AND_COND:%.*]] = and i1 [[LSB_1]], [[LSB_2]]
+; CHECK-NEXT: [[ZERO_OR_SHIFT:%.*]] = select i1 [[AND_COND]], i8 [[SH]], i8 0
+; CHECK-NEXT: ret i8 [[ZERO_OR_SHIFT]]
+;
+ %sh = shl nuw i8 1, %mask
+ %and_1 = and i8 %a, %sh
+ %lsb_1 = icmp ne i8 %and_1, 0
+ %and_2 = and i8 %b, %sh
+ %lsb_2 = icmp ne i8 %and_2, 0
+ %and_cond = and i1 %lsb_1, %lsb_2
+ %zero_or_shift = select i1 %and_cond, i8 %sh, i8 0
+ ret i8 %zero_or_shift
+}
+
+define <2 x i8> @select_or_eq_zero_powerof2_vec(<2 x i8> %a, <2 x i8> %b, <2 x i8> %mask) {
+; CHECK-LABEL: define <2 x i8> @select_or_eq_zero_powerof2_vec(
+; CHECK-SAME: <2 x i8> [[A:%.*]], <2 x i8> [[B:%.*]], <2 x i8> [[MASK:%.*]]) {
+; CHECK-NEXT: [[SH:%.*]] = shl nuw <2 x i8> splat (i8 1), [[MASK]]
+; CHECK-NEXT: [[AND_1:%.*]] = and <2 x i8> [[SH]], [[A]]
+; CHECK-NEXT: [[LSB_1:%.*]] = icmp eq <2 x i8> [[AND_1]], zeroinitializer
+; CHECK-NEXT: [[AND_2:%.*]] = and <2 x i8> [[SH]], [[B]]
+; CHECK-NEXT: [[LSB_2:%.*]] = icmp eq <2 x i8> [[AND_2]], zeroinitializer
+; CHECK-NEXT: [[OR:%.*]] = or <2 x i1> [[LSB_1]], [[LSB_2]]
+; CHECK-NEXT: [[ZERO_OR_SHIFT:%.*]] = select <2 x i1> [[OR]], <2 x i8> zeroinitializer, <2 x i8> [[SH]]
+; CHECK-NEXT: ret <2 x i8> [[ZERO_OR_SHIFT]]
+;
+ %sh = shl nuw <2 x i8> <i8 1, i8 1>, %mask
+ %and_1 = and <2 x i8> %sh, %a
+ %lsb_1 = icmp eq <2 x i8> %and_1, zeroinitializer
+ %and_2 = and <2 x i8> %sh, %b
+ %lsb_2 = icmp eq <2 x i8> %and_2, zeroinitializer
+ %or = or <2 x i1> %lsb_1, %lsb_2
+ %zero_or_shift = select <2 x i1> %or, <2 x i8> zeroinitializer, <2 x i8> %sh
+ ret <2 x i8> %zero_or_shift
+}
+
+define i8 @negative_not_power_of_two(i8 %a, i8 %b, i8 %sh) {
+; CHECK-LABEL: define i8 @negative_not_power_of_two(
+; CHECK-SAME: i8 [[A:%.*]], i8 [[B:%.*]], i8 [[SH:%.*]]) {
+; CHECK-NEXT: [[AND_1:%.*]] = and i8 [[SH]], [[A]]
+; CHECK-NEXT: [[LSB_1:%.*]] = icmp eq i8 [[AND_1]], 0
+; CHECK-NEXT: [[AND_2:%.*]] = and i8 [[SH]], [[B]]
+; CHECK-NEXT: [[LSB_2:%.*]] = icmp eq i8 [[AND_2]], 0
+; CHECK-NEXT: [[OR:%.*]] = or i1 [[LSB_1]], [[LSB_2]]
+; CHECK-NEXT: [[ZERO_OR_SHIFT:%.*]] = select i1 [[OR]], i8 0, i8 [[SH]]
+; CHECK-NEXT: ret i8 [[ZERO_OR_SHIFT]]
+;
+ %and_1 = and i8 %sh, %a
+ %lsb_1 = icmp eq i8 %and_1, 0
+ %and_2 = and i8 %sh, %b
+ %lsb_2 = icmp eq i8 %and_2, 0
+ %or = or i1 %lsb_1, %lsb_2
+ %zero_or_shift = select i1 %or, i8 0, i8 %sh
+ ret i8 %zero_or_shift
+}
+
+define i8 @negative_mismatched_shift(i8 %a, i8 %b, i8 %mask, i8 %other_val) {
+; CHECK-LABEL: define i8 @negative_mismatched_shift(
+; CHECK-SAME: i8 [[A:%.*]], i8 [[B:%.*]], i8 [[MASK:%.*]], i8 [[OTHER_VAL:%.*]]) {
+; CHECK-NEXT: [[SH:%.*]] = shl nuw i8 1, [[MASK]]
+; CHECK-NEXT: [[AND_1:%.*]] = and i8 [[SH]], [[A]]
+; CHECK-NEXT: [[LSB_1:%.*]] = icmp eq i8 [[AND_1]], 0
+; CHECK-NEXT: [[AND_2:%.*]] = and i8 [[SH]], [[B]]
+; CHECK-NEXT: [[LSB_2:%.*]] = icmp eq i8 [[AND_2]], 0
+; CHECK-NEXT: [[OR:%.*]] = or i1 [[LSB_1]], [[LSB_2]]
+; CHECK-NEXT: [[ZERO_OR_SHIFT:%.*]] = select i1 [[OR]], i8 0, i8 [[OTHER_VAL]]
+; CHECK-NEXT: ret i8 [[ZERO_OR_SHIFT]]
+;
+ %sh = shl nuw i8 1, %mask
+ %and_1 = and i8 %sh, %a
+ %lsb_1 = icmp eq i8 %and_1, 0
+ %and_2 = and i8 %sh, %b
+ %lsb_2 = icmp eq i8 %and_2, 0
+ %or = or i1 %lsb_1, %lsb_2
+ %zero_or_shift = select i1 %or, i8 0, i8 %other_val
+ ret i8 %zero_or_shift
+}
+
+define i8 @negative_multi_use_cond(i8 %a, i8 %b, i8 %mask, ptr %p) {
+; CHECK-LABEL: define i8 @negative_multi_use_cond(
+; CHECK-SAME: i8 [[A:%.*]], i8 [[B:%.*]], i8 [[MASK:%.*]], ptr [[P:%.*]]) {
+; CHECK-NEXT: [[SH:%.*]] = shl nuw i8 1, [[MASK]]
+; CHECK-NEXT: [[AND_1:%.*]] = and i8 [[SH]], [[A]]
+; CHECK-NEXT: [[LSB_1:%.*]] = icmp eq i8 [[AND_1]], 0
+; CHECK-NEXT: [[AND_2:%.*]] = and i8 [[SH]], [[B]]
+; CHECK-NEXT: [[LSB_2:%.*]] = icmp eq i8 [[AND_2]], 0
+; CHECK-NEXT: [[OR:%.*]] = or i1 [[LSB_1]], [[LSB_2]]
+; CHECK-NEXT: store i1 [[OR]], ptr [[P]], align 1
+; CHECK-NEXT: [[ZERO_OR_SHIFT:%.*]] = select i1 [[OR]], i8 0, i8 [[SH]]
+; CHECK-NEXT: ret i8 [[ZERO_OR_SHIFT]]
+;
+ %sh = shl nuw i8 1, %mask
+ %and_1 = and i8 %sh, %a
+ %lsb_1 = icmp eq i8 %and_1, 0
+ %and_2 = and i8 %sh, %b
+ %lsb_2 = icmp eq i8 %and_2, 0
+ %or = or i1 %lsb_1, %lsb_2
+ store i1 %or, ptr %p
+ %zero_or_shift = select i1 %or, i8 0, i8 %sh
+ ret i8 %zero_or_shift
+}
>From 3ae65094d603e3f525708f2c86ea3b12610a4d93 Mon Sep 17 00:00:00 2001
From: Shengxin Pei <TPPPP72 at outlook.com>
Date: Mon, 10 Aug 2026 03:26:31 +0800
Subject: [PATCH 2/2] [InstCombine] Fold select (A & Shift == 0 | B & Shift ==
0), 0, Shift to Shift & A & B
---
.../InstCombine/InstCombineSelect.cpp | 45 +++++++++++++++++++
.../InstCombine/select-and-or-powerof2.ll | 34 +++-----------
2 files changed, 52 insertions(+), 27 deletions(-)
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
index 39f0d11df4db9..558ad2ebccc37 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
@@ -4511,6 +4511,48 @@ static Instruction *foldSelectNegNot(SelectInst &SI,
return nullptr;
}
+/// Fold select (A & Shift == 0 | B & Shift == 0), 0, Shift -> Shift & A & B
+/// where Shift is known to be a power of two.
+static Instruction *foldSelectAndOrPowerOfTwo(SelectInst &SI,
+ InstCombiner::BuilderTy &Builder,
+ const SimplifyQuery &SQ) {
+ Value *Cond = SI.getCondition();
+
+ if (!Cond->hasOneUse())
+ return nullptr;
+
+ Value *TrueVal = SI.getTrueValue();
+ Value *FalseVal = SI.getFalseValue();
+
+ Value *A, *B, *Shift;
+
+ bool Case1 =
+ match(TrueVal, m_Zero()) && match(FalseVal, m_Value(Shift)) &&
+ match(Cond, m_Or(m_SpecificICmp(ICmpInst::ICMP_EQ,
+ m_c_And(m_Specific(Shift), m_Value(A)),
+ m_Zero()),
+ m_SpecificICmp(ICmpInst::ICMP_EQ,
+ m_c_And(m_Specific(Shift), m_Value(B)),
+ m_Zero())));
+
+ bool Case2 =
+ match(FalseVal, m_Zero()) && match(TrueVal, m_Value(Shift)) &&
+ match(Cond, m_And(m_SpecificICmp(ICmpInst::ICMP_NE,
+ m_c_And(m_Specific(Shift), m_Value(A)),
+ m_Zero()),
+ m_SpecificICmp(ICmpInst::ICMP_NE,
+ m_c_And(m_Specific(Shift), m_Value(B)),
+ m_Zero())));
+
+ if ((Case1 || Case2) && isKnownToBeAPowerOfTwo(Shift, /*OrZero=*/true,
+ SQ.getWithInstruction(&SI))) {
+ Value *And1 = Builder.CreateAnd(Shift, A);
+ return BinaryOperator::CreateAnd(And1, B);
+ }
+
+ return nullptr;
+}
+
// Return true if no use can observe the sign of zero of the select result,
// looking through phis, selects and the loop back edge to the select itself.
static bool isSelectZeroSignInsignificant(SelectInst &SI) {
@@ -4631,6 +4673,9 @@ Instruction *InstCombinerImpl::visitSelectInst(SelectInst &SI) {
if (Instruction *I = foldSelectNegNot(SI, Builder))
return I;
+ if (Instruction *I = foldSelectAndOrPowerOfTwo(SI, Builder, SQ))
+ return I;
+
auto *SIFPOp = dyn_cast<FPMathOperator>(&SI);
if (auto *FCmp = dyn_cast<FCmpInst>(CondVal)) {
diff --git a/llvm/test/Transforms/InstCombine/select-and-or-powerof2.ll b/llvm/test/Transforms/InstCombine/select-and-or-powerof2.ll
index 3403b209618f0..3bc6a53d6bf11 100644
--- a/llvm/test/Transforms/InstCombine/select-and-or-powerof2.ll
+++ b/llvm/test/Transforms/InstCombine/select-and-or-powerof2.ll
@@ -6,11 +6,7 @@ define i8 @select_or_eq_zero_powerof2(i8 %a, i8 %b, i8 %mask) {
; CHECK-SAME: i8 [[A:%.*]], i8 [[B:%.*]], i8 [[MASK:%.*]]) {
; CHECK-NEXT: [[SH:%.*]] = shl nuw i8 1, [[MASK]]
; CHECK-NEXT: [[AND_1:%.*]] = and i8 [[SH]], [[A]]
-; CHECK-NEXT: [[LSB_1:%.*]] = icmp eq i8 [[AND_1]], 0
-; CHECK-NEXT: [[AND_2:%.*]] = and i8 [[SH]], [[B]]
-; CHECK-NEXT: [[LSB_2:%.*]] = icmp eq i8 [[AND_2]], 0
-; CHECK-NEXT: [[OR:%.*]] = or i1 [[LSB_1]], [[LSB_2]]
-; CHECK-NEXT: [[ZERO_OR_SHIFT:%.*]] = select i1 [[OR]], i8 0, i8 [[SH]]
+; CHECK-NEXT: [[ZERO_OR_SHIFT:%.*]] = and i8 [[AND_1]], [[B]]
; CHECK-NEXT: ret i8 [[ZERO_OR_SHIFT]]
;
%sh = shl nuw i8 1, %mask
@@ -28,11 +24,7 @@ define i8 @select_and_ne_zero_powerof2(i8 %a, i8 %b, i8 %mask) {
; CHECK-SAME: i8 [[A:%.*]], i8 [[B:%.*]], i8 [[MASK:%.*]]) {
; CHECK-NEXT: [[SH:%.*]] = shl nuw i8 1, [[MASK]]
; CHECK-NEXT: [[AND_1:%.*]] = and i8 [[SH]], [[A]]
-; CHECK-NEXT: [[LSB_1:%.*]] = icmp ne i8 [[AND_1]], 0
-; CHECK-NEXT: [[AND_2:%.*]] = and i8 [[SH]], [[B]]
-; CHECK-NEXT: [[LSB_2:%.*]] = icmp ne i8 [[AND_2]], 0
-; CHECK-NEXT: [[AND_COND:%.*]] = and i1 [[LSB_1]], [[LSB_2]]
-; CHECK-NEXT: [[ZERO_OR_SHIFT:%.*]] = select i1 [[AND_COND]], i8 [[SH]], i8 0
+; CHECK-NEXT: [[ZERO_OR_SHIFT:%.*]] = and i8 [[AND_1]], [[B]]
; CHECK-NEXT: ret i8 [[ZERO_OR_SHIFT]]
;
%sh = shl nuw i8 1, %mask
@@ -49,12 +41,8 @@ define i8 @select_or_eq_zero_powerof2_commuted(i8 %a, i8 %b, i8 %mask) {
; CHECK-LABEL: define i8 @select_or_eq_zero_powerof2_commuted(
; CHECK-SAME: i8 [[A:%.*]], i8 [[B:%.*]], i8 [[MASK:%.*]]) {
; CHECK-NEXT: [[SH:%.*]] = shl nuw i8 1, [[MASK]]
-; CHECK-NEXT: [[AND_1:%.*]] = and i8 [[A]], [[SH]]
-; CHECK-NEXT: [[LSB_1:%.*]] = icmp eq i8 [[AND_1]], 0
-; CHECK-NEXT: [[AND_2:%.*]] = and i8 [[B]], [[SH]]
-; CHECK-NEXT: [[LSB_2:%.*]] = icmp eq i8 [[AND_2]], 0
-; CHECK-NEXT: [[OR:%.*]] = or i1 [[LSB_1]], [[LSB_2]]
-; CHECK-NEXT: [[ZERO_OR_SHIFT:%.*]] = select i1 [[OR]], i8 0, i8 [[SH]]
+; CHECK-NEXT: [[TMP1:%.*]] = and i8 [[SH]], [[A]]
+; CHECK-NEXT: [[ZERO_OR_SHIFT:%.*]] = and i8 [[TMP1]], [[B]]
; CHECK-NEXT: ret i8 [[ZERO_OR_SHIFT]]
;
%sh = shl nuw i8 1, %mask
@@ -71,12 +59,8 @@ define i8 @select_and_ne_zero_powerof2_commuted(i8 %a, i8 %b, i8 %mask) {
; CHECK-LABEL: define i8 @select_and_ne_zero_powerof2_commuted(
; CHECK-SAME: i8 [[A:%.*]], i8 [[B:%.*]], i8 [[MASK:%.*]]) {
; CHECK-NEXT: [[SH:%.*]] = shl nuw i8 1, [[MASK]]
-; CHECK-NEXT: [[AND_1:%.*]] = and i8 [[A]], [[SH]]
-; CHECK-NEXT: [[LSB_1:%.*]] = icmp ne i8 [[AND_1]], 0
-; CHECK-NEXT: [[AND_2:%.*]] = and i8 [[B]], [[SH]]
-; CHECK-NEXT: [[LSB_2:%.*]] = icmp ne i8 [[AND_2]], 0
-; CHECK-NEXT: [[AND_COND:%.*]] = and i1 [[LSB_1]], [[LSB_2]]
-; CHECK-NEXT: [[ZERO_OR_SHIFT:%.*]] = select i1 [[AND_COND]], i8 [[SH]], i8 0
+; CHECK-NEXT: [[TMP1:%.*]] = and i8 [[SH]], [[A]]
+; CHECK-NEXT: [[ZERO_OR_SHIFT:%.*]] = and i8 [[TMP1]], [[B]]
; CHECK-NEXT: ret i8 [[ZERO_OR_SHIFT]]
;
%sh = shl nuw i8 1, %mask
@@ -94,11 +78,7 @@ define <2 x i8> @select_or_eq_zero_powerof2_vec(<2 x i8> %a, <2 x i8> %b, <2 x i
; CHECK-SAME: <2 x i8> [[A:%.*]], <2 x i8> [[B:%.*]], <2 x i8> [[MASK:%.*]]) {
; CHECK-NEXT: [[SH:%.*]] = shl nuw <2 x i8> splat (i8 1), [[MASK]]
; CHECK-NEXT: [[AND_1:%.*]] = and <2 x i8> [[SH]], [[A]]
-; CHECK-NEXT: [[LSB_1:%.*]] = icmp eq <2 x i8> [[AND_1]], zeroinitializer
-; CHECK-NEXT: [[AND_2:%.*]] = and <2 x i8> [[SH]], [[B]]
-; CHECK-NEXT: [[LSB_2:%.*]] = icmp eq <2 x i8> [[AND_2]], zeroinitializer
-; CHECK-NEXT: [[OR:%.*]] = or <2 x i1> [[LSB_1]], [[LSB_2]]
-; CHECK-NEXT: [[ZERO_OR_SHIFT:%.*]] = select <2 x i1> [[OR]], <2 x i8> zeroinitializer, <2 x i8> [[SH]]
+; CHECK-NEXT: [[ZERO_OR_SHIFT:%.*]] = and <2 x i8> [[AND_1]], [[B]]
; CHECK-NEXT: ret <2 x i8> [[ZERO_OR_SHIFT]]
;
%sh = shl nuw <2 x i8> <i8 1, i8 1>, %mask
More information about the llvm-commits
mailing list