diff --git a/llvm/include/llvm/Analysis/ValueTracking.h b/llvm/include/llvm/Analysis/ValueTracking.h --- a/llvm/include/llvm/Analysis/ValueTracking.h +++ b/llvm/include/llvm/Analysis/ValueTracking.h @@ -871,6 +871,13 @@ /// impliesPoison returns true. bool impliesPoison(const Value *ValAssumedPoison, const Value *V); +/// Return true if V is poison given that ValAssumedPoison is already poison. +/// Poison generating flags or metadatas are ignored in the process of implying. +/// And the instructions ignored will be recorded in IgnoredInsts. +bool impliesPoisonIgnoreFlagsOrMetadatas( + Value *ValAssumedPoison, const Value *V, + SmallVectorImpl &IgnoredInsts); + /// Return true if this function can prove that V does not have undef bits /// and is never poison. If V is an aggregate value or vector, check whether /// all elements (except padding) are not undef or poison. diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp --- a/llvm/lib/Analysis/ValueTracking.cpp +++ b/llvm/lib/Analysis/ValueTracking.cpp @@ -6532,8 +6532,9 @@ return false; } -static bool impliesPoison(const Value *ValAssumedPoison, const Value *V, - unsigned Depth) { +static bool +impliesPoison(Value *ValAssumedPoison, const Value *V, unsigned Depth, + SmallVectorImpl *IgnoredInsts = nullptr) { if (isGuaranteedNotToBeUndefOrPoison(ValAssumedPoison)) return true; @@ -6544,17 +6545,30 @@ if (Depth >= MaxDepth) return false; - const auto *I = dyn_cast(ValAssumedPoison); - if (I && !canCreatePoison(cast(I))) { - return all_of(I->operands(), [=](const Value *Op) { - return impliesPoison(Op, V, Depth + 1); - }); - } - return false; + auto *I = dyn_cast(ValAssumedPoison); + if (!I || canCreatePoison(cast(I), + /*ConsiderFlagsAndMetadata*/ !IgnoredInsts)) + return false; + + for (Value *Op : I->operands()) + if (!impliesPoison(Op, V, Depth + 1, IgnoredInsts)) + return false; + + if (IgnoredInsts && I->hasPoisonGeneratingFlagsOrMetadata()) + IgnoredInsts->push_back(I); + + return true; } bool llvm::impliesPoison(const Value *ValAssumedPoison, const Value *V) { - return ::impliesPoison(ValAssumedPoison, V, /* Depth */ 0); + return ::impliesPoison(const_cast(ValAssumedPoison), V, + /* Depth */ 0); +} + +bool llvm::impliesPoisonIgnoreFlagsOrMetadatas( + Value *ValAssumedPoison, const Value *V, + SmallVectorImpl &IgnoredInsts) { + return ::impliesPoison(ValAssumedPoison, V, /* Depth */ 0, &IgnoredInsts); } static bool programUndefinedIfUndefOrPoison(const Value *V, diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp --- a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp @@ -2927,7 +2927,10 @@ // checks whether folding it does not convert a well-defined value into // poison. if (match(TrueVal, m_One())) { - if (impliesPoison(FalseVal, CondVal)) { + SmallVector DropFlags; + if (impliesPoisonIgnoreFlagsOrMetadatas(FalseVal, CondVal, DropFlags)) { + for (Instruction *I : DropFlags) + I->dropPoisonGeneratingFlagsAndMetadata(); // Change: A = select B, true, C --> A = or B, C return BinaryOperator::CreateOr(CondVal, FalseVal); } @@ -2968,7 +2971,10 @@ } if (match(FalseVal, m_Zero())) { - if (impliesPoison(TrueVal, CondVal)) { + SmallVector DropFlags; + if (impliesPoisonIgnoreFlagsOrMetadatas(TrueVal, CondVal, DropFlags)) { + for (Instruction *I : DropFlags) + I->dropPoisonGeneratingFlagsAndMetadata(); // Change: A = select B, C, false --> A = and B, C return BinaryOperator::CreateAnd(CondVal, TrueVal); } diff --git a/llvm/test/Transforms/InstCombine/and-fcmp.ll b/llvm/test/Transforms/InstCombine/and-fcmp.ll --- a/llvm/test/Transforms/InstCombine/and-fcmp.ll +++ b/llvm/test/Transforms/InstCombine/and-fcmp.ll @@ -390,7 +390,7 @@ define i1 @auto_gen_5_logical_fmf(double %a, double %b) { ; CHECK-LABEL: @auto_gen_5_logical_fmf( -; CHECK-NEXT: [[RETVAL:%.*]] = fcmp fast ogt double [[A:%.*]], [[B:%.*]] +; CHECK-NEXT: [[RETVAL:%.*]] = fcmp reassoc nsz arcp contract afn ogt double [[A:%.*]], [[B:%.*]] ; CHECK-NEXT: ret i1 [[RETVAL]] ; %cmp = fcmp fast ogt double %a, %b @@ -453,7 +453,7 @@ define i1 @auto_gen_7_logical_fmf(double %a, double %b) { ; CHECK-LABEL: @auto_gen_7_logical_fmf( -; CHECK-NEXT: [[RETVAL:%.*]] = fcmp fast oeq double [[A:%.*]], [[B:%.*]] +; CHECK-NEXT: [[RETVAL:%.*]] = fcmp reassoc nsz arcp contract afn oeq double [[A:%.*]], [[B:%.*]] ; CHECK-NEXT: ret i1 [[RETVAL]] ; %cmp = fcmp fast oge double %a, %b @@ -519,7 +519,7 @@ define i1 @auto_gen_9_logical_fmf(double %a, double %b) { ; CHECK-LABEL: @auto_gen_9_logical_fmf( -; CHECK-NEXT: [[RETVAL:%.*]] = fcmp fast oge double [[A:%.*]], [[B:%.*]] +; CHECK-NEXT: [[RETVAL:%.*]] = fcmp reassoc nsz arcp contract afn oge double [[A:%.*]], [[B:%.*]] ; CHECK-NEXT: ret i1 [[RETVAL]] ; %cmp = fcmp fast oge double %a, %b @@ -831,7 +831,7 @@ define i1 @auto_gen_19_logical_fmf(double %a, double %b) { ; CHECK-LABEL: @auto_gen_19_logical_fmf( -; CHECK-NEXT: [[RETVAL:%.*]] = fcmp fast olt double [[A:%.*]], [[B:%.*]] +; CHECK-NEXT: [[RETVAL:%.*]] = fcmp reassoc nsz arcp contract afn olt double [[A:%.*]], [[B:%.*]] ; CHECK-NEXT: ret i1 [[RETVAL]] ; %cmp = fcmp fast ole double %a, %b @@ -957,7 +957,7 @@ define i1 @auto_gen_23_logical_fmf(double %a, double %b) { ; CHECK-LABEL: @auto_gen_23_logical_fmf( -; CHECK-NEXT: [[RETVAL:%.*]] = fcmp fast ogt double [[A:%.*]], [[B:%.*]] +; CHECK-NEXT: [[RETVAL:%.*]] = fcmp reassoc nsz arcp contract afn ogt double [[A:%.*]], [[B:%.*]] ; CHECK-NEXT: ret i1 [[RETVAL]] ; %cmp = fcmp fast one double %a, %b @@ -1023,7 +1023,7 @@ define i1 @auto_gen_25_logical_fmf(double %a, double %b) { ; CHECK-LABEL: @auto_gen_25_logical_fmf( -; CHECK-NEXT: [[RETVAL:%.*]] = fcmp fast olt double [[A:%.*]], [[B:%.*]] +; CHECK-NEXT: [[RETVAL:%.*]] = fcmp reassoc nsz arcp contract afn olt double [[A:%.*]], [[B:%.*]] ; CHECK-NEXT: ret i1 [[RETVAL]] ; %cmp = fcmp fast one double %a, %b @@ -1089,7 +1089,7 @@ define i1 @auto_gen_27_logical_fmf(double %a, double %b) { ; CHECK-LABEL: @auto_gen_27_logical_fmf( -; CHECK-NEXT: [[RETVAL:%.*]] = fcmp fast one double [[A:%.*]], [[B:%.*]] +; CHECK-NEXT: [[RETVAL:%.*]] = fcmp reassoc nsz arcp contract afn one double [[A:%.*]], [[B:%.*]] ; CHECK-NEXT: ret i1 [[RETVAL]] ; %cmp = fcmp fast one double %a, %b @@ -1412,7 +1412,7 @@ define i1 @auto_gen_37_logical_fmf(double %a, double %b) { ; CHECK-LABEL: @auto_gen_37_logical_fmf( -; CHECK-NEXT: [[RETVAL:%.*]] = fcmp fast oeq double [[A:%.*]], [[B:%.*]] +; CHECK-NEXT: [[RETVAL:%.*]] = fcmp reassoc nsz arcp contract afn oeq double [[A:%.*]], [[B:%.*]] ; CHECK-NEXT: ret i1 [[RETVAL]] ; %cmp = fcmp fast ueq double %a, %b @@ -1475,7 +1475,7 @@ define i1 @auto_gen_39_logical_fmf(double %a, double %b) { ; CHECK-LABEL: @auto_gen_39_logical_fmf( -; CHECK-NEXT: [[RETVAL:%.*]] = fcmp fast oeq double [[A:%.*]], [[B:%.*]] +; CHECK-NEXT: [[RETVAL:%.*]] = fcmp reassoc nsz arcp contract afn oeq double [[A:%.*]], [[B:%.*]] ; CHECK-NEXT: ret i1 [[RETVAL]] ; %cmp = fcmp fast ueq double %a, %b @@ -1538,7 +1538,7 @@ define i1 @auto_gen_41_logical_fmf(double %a, double %b) { ; CHECK-LABEL: @auto_gen_41_logical_fmf( -; CHECK-NEXT: [[RETVAL:%.*]] = fcmp fast oeq double [[A:%.*]], [[B:%.*]] +; CHECK-NEXT: [[RETVAL:%.*]] = fcmp reassoc nsz arcp contract afn oeq double [[A:%.*]], [[B:%.*]] ; CHECK-NEXT: ret i1 [[RETVAL]] ; %cmp = fcmp fast ueq double %a, %b @@ -1727,7 +1727,7 @@ define i1 @auto_gen_47_logical_fmf(double %a, double %b) { ; CHECK-LABEL: @auto_gen_47_logical_fmf( -; CHECK-NEXT: [[RETVAL:%.*]] = fcmp fast ogt double [[A:%.*]], [[B:%.*]] +; CHECK-NEXT: [[RETVAL:%.*]] = fcmp reassoc nsz arcp contract afn ogt double [[A:%.*]], [[B:%.*]] ; CHECK-NEXT: ret i1 [[RETVAL]] ; %cmp = fcmp fast ugt double %a, %b @@ -1853,7 +1853,7 @@ define i1 @auto_gen_51_logical_fmf(double %a, double %b) { ; CHECK-LABEL: @auto_gen_51_logical_fmf( -; CHECK-NEXT: [[RETVAL:%.*]] = fcmp fast ogt double [[A:%.*]], [[B:%.*]] +; CHECK-NEXT: [[RETVAL:%.*]] = fcmp reassoc nsz arcp contract afn ogt double [[A:%.*]], [[B:%.*]] ; CHECK-NEXT: ret i1 [[RETVAL]] ; %cmp = fcmp fast ugt double %a, %b @@ -1919,7 +1919,8 @@ define i1 @auto_gen_53_logical_fmf(double %a, double %b) { ; CHECK-LABEL: @auto_gen_53_logical_fmf( -; CHECK-NEXT: ret i1 false +; CHECK-NEXT: [[RETVAL:%.*]] = fcmp reassoc nsz arcp contract afn uno double [[A:%.*]], [[B:%.*]] +; CHECK-NEXT: ret i1 [[RETVAL]] ; %cmp = fcmp fast ugt double %a, %b %cmp1 = fcmp fast ueq double %a, %b @@ -2047,7 +2048,7 @@ define i1 @auto_gen_57_logical_fmf(double %a, double %b) { ; CHECK-LABEL: @auto_gen_57_logical_fmf( -; CHECK-NEXT: [[RETVAL:%.*]] = fcmp fast ogt double [[A:%.*]], [[B:%.*]] +; CHECK-NEXT: [[RETVAL:%.*]] = fcmp reassoc nsz arcp contract afn ogt double [[A:%.*]], [[B:%.*]] ; CHECK-NEXT: ret i1 [[RETVAL]] ; %cmp = fcmp fast uge double %a, %b @@ -2176,7 +2177,7 @@ define i1 @auto_gen_61_logical_fmf(double %a, double %b) { ; CHECK-LABEL: @auto_gen_61_logical_fmf( -; CHECK-NEXT: [[RETVAL:%.*]] = fcmp fast ogt double [[A:%.*]], [[B:%.*]] +; CHECK-NEXT: [[RETVAL:%.*]] = fcmp reassoc nsz arcp contract afn ogt double [[A:%.*]], [[B:%.*]] ; CHECK-NEXT: ret i1 [[RETVAL]] ; %cmp = fcmp fast uge double %a, %b @@ -2242,7 +2243,7 @@ define i1 @auto_gen_63_logical_fmf(double %a, double %b) { ; CHECK-LABEL: @auto_gen_63_logical_fmf( -; CHECK-NEXT: [[RETVAL:%.*]] = fcmp fast ueq double [[A:%.*]], [[B:%.*]] +; CHECK-NEXT: [[RETVAL:%.*]] = fcmp reassoc nsz arcp contract afn ueq double [[A:%.*]], [[B:%.*]] ; CHECK-NEXT: ret i1 [[RETVAL]] ; %cmp = fcmp fast uge double %a, %b @@ -2308,7 +2309,7 @@ define i1 @auto_gen_65_logical_fmf(double %a, double %b) { ; CHECK-LABEL: @auto_gen_65_logical_fmf( -; CHECK-NEXT: [[RETVAL:%.*]] = fcmp fast uge double [[A:%.*]], [[B:%.*]] +; CHECK-NEXT: [[RETVAL:%.*]] = fcmp reassoc nsz arcp contract afn uge double [[A:%.*]], [[B:%.*]] ; CHECK-NEXT: ret i1 [[RETVAL]] ; %cmp = fcmp fast uge double %a, %b @@ -2494,7 +2495,7 @@ define i1 @auto_gen_71_logical_fmf(double %a, double %b) { ; CHECK-LABEL: @auto_gen_71_logical_fmf( -; CHECK-NEXT: [[RETVAL:%.*]] = fcmp fast olt double [[A:%.*]], [[B:%.*]] +; CHECK-NEXT: [[RETVAL:%.*]] = fcmp reassoc nsz arcp contract afn olt double [[A:%.*]], [[B:%.*]] ; CHECK-NEXT: ret i1 [[RETVAL]] ; %cmp = fcmp fast ult double %a, %b @@ -2626,7 +2627,8 @@ define i1 @auto_gen_75_logical_fmf(double %a, double %b) { ; CHECK-LABEL: @auto_gen_75_logical_fmf( -; CHECK-NEXT: ret i1 false +; CHECK-NEXT: [[RETVAL:%.*]] = fcmp reassoc nsz arcp contract afn uno double [[A:%.*]], [[B:%.*]] +; CHECK-NEXT: ret i1 [[RETVAL]] ; %cmp = fcmp fast ult double %a, %b %cmp1 = fcmp fast ugt double %a, %b @@ -2691,7 +2693,7 @@ define i1 @auto_gen_77_logical_fmf(double %a, double %b) { ; CHECK-LABEL: @auto_gen_77_logical_fmf( -; CHECK-NEXT: [[RETVAL:%.*]] = fcmp fast ult double [[A:%.*]], [[B:%.*]] +; CHECK-NEXT: [[RETVAL:%.*]] = fcmp reassoc nsz arcp contract afn ult double [[A:%.*]], [[B:%.*]] ; CHECK-NEXT: ret i1 [[RETVAL]] ; %cmp = fcmp fast ult double %a, %b @@ -2754,7 +2756,7 @@ define i1 @auto_gen_79_logical_fmf(double %a, double %b) { ; CHECK-LABEL: @auto_gen_79_logical_fmf( -; CHECK-NEXT: [[RETVAL:%.*]] = fcmp fast oeq double [[A:%.*]], [[B:%.*]] +; CHECK-NEXT: [[RETVAL:%.*]] = fcmp reassoc nsz arcp contract afn oeq double [[A:%.*]], [[B:%.*]] ; CHECK-NEXT: ret i1 [[RETVAL]] ; %cmp = fcmp fast ule double %a, %b @@ -2817,7 +2819,7 @@ define i1 @auto_gen_81_logical_fmf(double %a, double %b) { ; CHECK-LABEL: @auto_gen_81_logical_fmf( -; CHECK-NEXT: [[RETVAL:%.*]] = fcmp fast oeq double [[A:%.*]], [[B:%.*]] +; CHECK-NEXT: [[RETVAL:%.*]] = fcmp reassoc nsz arcp contract afn oeq double [[A:%.*]], [[B:%.*]] ; CHECK-NEXT: ret i1 [[RETVAL]] ; %cmp = fcmp fast ule double %a, %b @@ -2883,7 +2885,7 @@ define i1 @auto_gen_83_logical_fmf(double %a, double %b) { ; CHECK-LABEL: @auto_gen_83_logical_fmf( -; CHECK-NEXT: [[RETVAL:%.*]] = fcmp fast ole double [[A:%.*]], [[B:%.*]] +; CHECK-NEXT: [[RETVAL:%.*]] = fcmp reassoc nsz arcp contract afn ole double [[A:%.*]], [[B:%.*]] ; CHECK-NEXT: ret i1 [[RETVAL]] ; %cmp = fcmp fast ule double %a, %b @@ -3015,7 +3017,8 @@ define i1 @auto_gen_87_logical_fmf(double %a, double %b) { ; CHECK-LABEL: @auto_gen_87_logical_fmf( -; CHECK-NEXT: ret i1 false +; CHECK-NEXT: [[RETVAL:%.*]] = fcmp reassoc nsz arcp contract afn uno double [[A:%.*]], [[B:%.*]] +; CHECK-NEXT: ret i1 [[RETVAL]] ; %cmp = fcmp fast ule double %a, %b %cmp1 = fcmp fast ugt double %a, %b @@ -3080,7 +3083,7 @@ define i1 @auto_gen_89_logical_fmf(double %a, double %b) { ; CHECK-LABEL: @auto_gen_89_logical_fmf( -; CHECK-NEXT: [[RETVAL:%.*]] = fcmp fast ult double [[A:%.*]], [[B:%.*]] +; CHECK-NEXT: [[RETVAL:%.*]] = fcmp reassoc nsz arcp contract afn ult double [[A:%.*]], [[B:%.*]] ; CHECK-NEXT: ret i1 [[RETVAL]] ; %cmp = fcmp fast ule double %a, %b @@ -3206,7 +3209,7 @@ define i1 @auto_gen_93_logical_fmf(double %a, double %b) { ; CHECK-LABEL: @auto_gen_93_logical_fmf( -; CHECK-NEXT: [[RETVAL:%.*]] = fcmp fast ogt double [[A:%.*]], [[B:%.*]] +; CHECK-NEXT: [[RETVAL:%.*]] = fcmp reassoc nsz arcp contract afn ogt double [[A:%.*]], [[B:%.*]] ; CHECK-NEXT: ret i1 [[RETVAL]] ; %cmp = fcmp fast une double %a, %b @@ -3272,7 +3275,7 @@ define i1 @auto_gen_95_logical_fmf(double %a, double %b) { ; CHECK-LABEL: @auto_gen_95_logical_fmf( -; CHECK-NEXT: [[RETVAL:%.*]] = fcmp fast olt double [[A:%.*]], [[B:%.*]] +; CHECK-NEXT: [[RETVAL:%.*]] = fcmp reassoc nsz arcp contract afn olt double [[A:%.*]], [[B:%.*]] ; CHECK-NEXT: ret i1 [[RETVAL]] ; %cmp = fcmp fast une double %a, %b @@ -3338,7 +3341,7 @@ define i1 @auto_gen_97_logical_fmf(double %a, double %b) { ; CHECK-LABEL: @auto_gen_97_logical_fmf( -; CHECK-NEXT: [[RETVAL:%.*]] = fcmp fast one double [[A:%.*]], [[B:%.*]] +; CHECK-NEXT: [[RETVAL:%.*]] = fcmp reassoc nsz arcp contract afn one double [[A:%.*]], [[B:%.*]] ; CHECK-NEXT: ret i1 [[RETVAL]] ; %cmp = fcmp fast une double %a, %b @@ -3404,7 +3407,8 @@ define i1 @auto_gen_99_logical_fmf(double %a, double %b) { ; CHECK-LABEL: @auto_gen_99_logical_fmf( -; CHECK-NEXT: ret i1 false +; CHECK-NEXT: [[RETVAL:%.*]] = fcmp reassoc nsz arcp contract afn uno double [[A:%.*]], [[B:%.*]] +; CHECK-NEXT: ret i1 [[RETVAL]] ; %cmp = fcmp fast une double %a, %b %cmp1 = fcmp fast ueq double %a, %b @@ -3469,7 +3473,7 @@ define i1 @auto_gen_101_logical_fmf(double %a, double %b) { ; CHECK-LABEL: @auto_gen_101_logical_fmf( -; CHECK-NEXT: [[RETVAL:%.*]] = fcmp fast ugt double [[A:%.*]], [[B:%.*]] +; CHECK-NEXT: [[RETVAL:%.*]] = fcmp reassoc nsz arcp contract afn ugt double [[A:%.*]], [[B:%.*]] ; CHECK-NEXT: ret i1 [[RETVAL]] ; %cmp = fcmp fast une double %a, %b @@ -3535,7 +3539,7 @@ define i1 @auto_gen_103_logical_fmf(double %a, double %b) { ; CHECK-LABEL: @auto_gen_103_logical_fmf( -; CHECK-NEXT: [[RETVAL:%.*]] = fcmp fast ult double [[A:%.*]], [[B:%.*]] +; CHECK-NEXT: [[RETVAL:%.*]] = fcmp reassoc nsz arcp contract afn ult double [[A:%.*]], [[B:%.*]] ; CHECK-NEXT: ret i1 [[RETVAL]] ; %cmp = fcmp fast une double %a, %b diff --git a/llvm/test/Transforms/InstCombine/ispow2.ll b/llvm/test/Transforms/InstCombine/ispow2.ll --- a/llvm/test/Transforms/InstCombine/ispow2.ll +++ b/llvm/test/Transforms/InstCombine/ispow2.ll @@ -282,7 +282,7 @@ ; CHECK-NEXT: [[T0:%.*]] = tail call i32 @llvm.ctpop.i32(i32 [[X:%.*]]), !range [[RNG0]] ; CHECK-NEXT: [[CMP:%.*]] = icmp ult i32 [[T0]], 3 ; CHECK-NEXT: [[NOTZERO:%.*]] = icmp ne i32 [[X]], 0 -; CHECK-NEXT: [[R:%.*]] = select i1 [[NOTZERO]], i1 [[CMP]], i1 false +; CHECK-NEXT: [[R:%.*]] = and i1 [[NOTZERO]], [[CMP]] ; CHECK-NEXT: ret i1 [[R]] ; %t0 = tail call i32 @llvm.ctpop.i32(i32 %x) @@ -314,7 +314,7 @@ ; CHECK-NEXT: [[T0:%.*]] = tail call i32 @llvm.ctpop.i32(i32 [[X:%.*]]), !range [[RNG0]] ; CHECK-NEXT: [[CMP:%.*]] = icmp ult i32 [[T0]], 2 ; CHECK-NEXT: [[NOTZERO:%.*]] = icmp ne i32 [[X]], 1 -; CHECK-NEXT: [[R:%.*]] = select i1 [[NOTZERO]], i1 [[CMP]], i1 false +; CHECK-NEXT: [[R:%.*]] = and i1 [[NOTZERO]], [[CMP]] ; CHECK-NEXT: ret i1 [[R]] ; %t0 = tail call i32 @llvm.ctpop.i32(i32 %x) @@ -346,7 +346,7 @@ ; CHECK-NEXT: [[T0:%.*]] = tail call i32 @llvm.ctpop.i32(i32 [[X:%.*]]), !range [[RNG0]] ; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i32 [[T0]], 2 ; CHECK-NEXT: [[NOTZERO:%.*]] = icmp ne i32 [[X]], 0 -; CHECK-NEXT: [[R:%.*]] = select i1 [[NOTZERO]], i1 [[CMP]], i1 false +; CHECK-NEXT: [[R:%.*]] = and i1 [[NOTZERO]], [[CMP]] ; CHECK-NEXT: ret i1 [[R]] ; %t0 = tail call i32 @llvm.ctpop.i32(i32 %x) @@ -378,7 +378,7 @@ ; CHECK-NEXT: [[T0:%.*]] = tail call i32 @llvm.ctpop.i32(i32 [[X:%.*]]), !range [[RNG0]] ; CHECK-NEXT: [[CMP:%.*]] = icmp ult i32 [[T0]], 2 ; CHECK-NEXT: [[CMP2:%.*]] = icmp sgt i32 [[X]], 0 -; CHECK-NEXT: [[R:%.*]] = select i1 [[CMP2]], i1 [[CMP]], i1 false +; CHECK-NEXT: [[R:%.*]] = and i1 [[CMP2]], [[CMP]] ; CHECK-NEXT: ret i1 [[R]] ; %t0 = tail call i32 @llvm.ctpop.i32(i32 %x) @@ -493,7 +493,7 @@ ; CHECK-NEXT: [[T0:%.*]] = tail call i32 @llvm.ctpop.i32(i32 [[X:%.*]]), !range [[RNG0]] ; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i32 [[T0]], 2 ; CHECK-NEXT: [[ISZERO:%.*]] = icmp eq i32 [[X]], 0 -; CHECK-NEXT: [[R:%.*]] = select i1 [[ISZERO]], i1 true, i1 [[CMP]] +; CHECK-NEXT: [[R:%.*]] = or i1 [[ISZERO]], [[CMP]] ; CHECK-NEXT: ret i1 [[R]] ; %t0 = tail call i32 @llvm.ctpop.i32(i32 %x) @@ -525,7 +525,7 @@ ; CHECK-NEXT: [[T0:%.*]] = tail call i32 @llvm.ctpop.i32(i32 [[X:%.*]]), !range [[RNG0]] ; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i32 [[T0]], 1 ; CHECK-NEXT: [[ISZERO:%.*]] = icmp eq i32 [[X]], 1 -; CHECK-NEXT: [[R:%.*]] = select i1 [[ISZERO]], i1 true, i1 [[CMP]] +; CHECK-NEXT: [[R:%.*]] = or i1 [[ISZERO]], [[CMP]] ; CHECK-NEXT: ret i1 [[R]] ; %t0 = tail call i32 @llvm.ctpop.i32(i32 %x) @@ -557,7 +557,7 @@ ; CHECK-NEXT: [[T0:%.*]] = tail call i32 @llvm.ctpop.i32(i32 [[X:%.*]]), !range [[RNG0]] ; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i32 [[T0]], 1 ; CHECK-NEXT: [[CMP2:%.*]] = icmp slt i32 [[X]], 0 -; CHECK-NEXT: [[R:%.*]] = select i1 [[CMP2]], i1 true, i1 [[CMP]] +; CHECK-NEXT: [[R:%.*]] = or i1 [[CMP2]], [[CMP]] ; CHECK-NEXT: ret i1 [[R]] ; %t0 = tail call i32 @llvm.ctpop.i32(i32 %x) @@ -855,7 +855,7 @@ ; CHECK-NEXT: [[T0:%.*]] = tail call i32 @llvm.ctpop.i32(i32 [[X:%.*]]), !range [[RNG0]] ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[T0]], 3 ; CHECK-NEXT: [[ISZERO:%.*]] = icmp eq i32 [[X]], 0 -; CHECK-NEXT: [[R:%.*]] = select i1 [[ISZERO]], i1 true, i1 [[CMP]] +; CHECK-NEXT: [[R:%.*]] = or i1 [[ISZERO]], [[CMP]] ; CHECK-NEXT: ret i1 [[R]] ; %t0 = tail call i32 @llvm.ctpop.i32(i32 %x) @@ -914,7 +914,11 @@ define i1 @is_pow2or0_ctpop_wrong_pred2_logical(i32 %x) { ; CHECK-LABEL: @is_pow2or0_ctpop_wrong_pred2_logical( -; CHECK-NEXT: ret i1 true +; CHECK-NEXT: [[T0:%.*]] = tail call i32 @llvm.ctpop.i32(i32 [[X:%.*]]), !range [[RNG0]] +; CHECK-NEXT: [[CMP:%.*]] = icmp ne i32 [[T0]], 1 +; CHECK-NEXT: [[ISZERO:%.*]] = icmp ne i32 [[X]], 0 +; CHECK-NEXT: [[R:%.*]] = or i1 [[ISZERO]], [[CMP]] +; CHECK-NEXT: ret i1 [[R]] ; %t0 = tail call i32 @llvm.ctpop.i32(i32 %x) %cmp = icmp ne i32 %t0, 1 @@ -1058,7 +1062,7 @@ ; CHECK-NEXT: [[T0:%.*]] = tail call i32 @llvm.ctpop.i32(i32 [[X:%.*]]), !range [[RNG0]] ; CHECK-NEXT: [[CMP:%.*]] = icmp ne i32 [[T0]], 5 ; CHECK-NEXT: [[NOTZERO:%.*]] = icmp ne i32 [[X]], 0 -; CHECK-NEXT: [[R:%.*]] = select i1 [[NOTZERO]], i1 [[CMP]], i1 false +; CHECK-NEXT: [[R:%.*]] = and i1 [[NOTZERO]], [[CMP]] ; CHECK-NEXT: ret i1 [[R]] ; %t0 = tail call i32 @llvm.ctpop.i32(i32 %x) @@ -1117,7 +1121,11 @@ define i1 @isnot_pow2nor0_ctpop_wrong_pred2_logical(i32 %x) { ; CHECK-LABEL: @isnot_pow2nor0_ctpop_wrong_pred2_logical( -; CHECK-NEXT: ret i1 false +; CHECK-NEXT: [[T0:%.*]] = tail call i32 @llvm.ctpop.i32(i32 [[X:%.*]]), !range [[RNG0]] +; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[T0]], 1 +; CHECK-NEXT: [[NOTZERO:%.*]] = icmp eq i32 [[X]], 0 +; CHECK-NEXT: [[R:%.*]] = and i1 [[NOTZERO]], [[CMP]] +; CHECK-NEXT: ret i1 [[R]] ; %t0 = tail call i32 @llvm.ctpop.i32(i32 %x) %cmp = icmp eq i32 %t0, 1 diff --git a/llvm/test/Transforms/InstCombine/or-fcmp.ll b/llvm/test/Transforms/InstCombine/or-fcmp.ll --- a/llvm/test/Transforms/InstCombine/or-fcmp.ll +++ b/llvm/test/Transforms/InstCombine/or-fcmp.ll @@ -351,7 +351,7 @@ define i1 @auto_gen_5_logical_fmf(double %a, double %b) { ; CHECK-LABEL: @auto_gen_5_logical_fmf( -; CHECK-NEXT: [[RETVAL:%.*]] = fcmp fast ogt double [[A:%.*]], [[B:%.*]] +; CHECK-NEXT: [[RETVAL:%.*]] = fcmp reassoc nsz arcp contract afn ogt double [[A:%.*]], [[B:%.*]] ; CHECK-NEXT: ret i1 [[RETVAL]] ; %cmp = fcmp fast ogt double %a, %b @@ -417,7 +417,7 @@ define i1 @auto_gen_7_logical_fmf(double %a, double %b) { ; CHECK-LABEL: @auto_gen_7_logical_fmf( -; CHECK-NEXT: [[RETVAL:%.*]] = fcmp fast oge double [[A:%.*]], [[B:%.*]] +; CHECK-NEXT: [[RETVAL:%.*]] = fcmp reassoc nsz arcp contract afn oge double [[A:%.*]], [[B:%.*]] ; CHECK-NEXT: ret i1 [[RETVAL]] ; %cmp = fcmp fast oge double %a, %b @@ -483,7 +483,7 @@ define i1 @auto_gen_9_logical_fmf(double %a, double %b) { ; CHECK-LABEL: @auto_gen_9_logical_fmf( -; CHECK-NEXT: [[RETVAL:%.*]] = fcmp fast oge double [[A:%.*]], [[B:%.*]] +; CHECK-NEXT: [[RETVAL:%.*]] = fcmp reassoc nsz arcp contract afn oge double [[A:%.*]], [[B:%.*]] ; CHECK-NEXT: ret i1 [[RETVAL]] ; %cmp = fcmp fast oge double %a, %b @@ -549,7 +549,7 @@ define i1 @auto_gen_11_logical_fmf(double %a, double %b) { ; CHECK-LABEL: @auto_gen_11_logical_fmf( -; CHECK-NEXT: [[RETVAL:%.*]] = fcmp fast ole double [[A:%.*]], [[B:%.*]] +; CHECK-NEXT: [[RETVAL:%.*]] = fcmp reassoc nsz arcp contract afn ole double [[A:%.*]], [[B:%.*]] ; CHECK-NEXT: ret i1 [[RETVAL]] ; %cmp = fcmp fast olt double %a, %b @@ -615,7 +615,8 @@ define i1 @auto_gen_13_logical_fmf(double %a, double %b) { ; CHECK-LABEL: @auto_gen_13_logical_fmf( -; CHECK-NEXT: ret i1 true +; CHECK-NEXT: [[RETVAL:%.*]] = fcmp reassoc nsz arcp contract afn ord double [[A:%.*]], [[B:%.*]] +; CHECK-NEXT: ret i1 [[RETVAL]] ; %cmp = fcmp fast olt double %a, %b %cmp1 = fcmp fast oge double %a, %b @@ -746,7 +747,8 @@ define i1 @auto_gen_17_logical_fmf(double %a, double %b) { ; CHECK-LABEL: @auto_gen_17_logical_fmf( -; CHECK-NEXT: ret i1 true +; CHECK-NEXT: [[RETVAL:%.*]] = fcmp reassoc nsz arcp contract afn ord double [[A:%.*]], [[B:%.*]] +; CHECK-NEXT: ret i1 [[RETVAL]] ; %cmp = fcmp fast ole double %a, %b %cmp1 = fcmp fast ogt double %a, %b @@ -811,7 +813,7 @@ define i1 @auto_gen_19_logical_fmf(double %a, double %b) { ; CHECK-LABEL: @auto_gen_19_logical_fmf( -; CHECK-NEXT: [[RETVAL:%.*]] = fcmp fast ole double [[A:%.*]], [[B:%.*]] +; CHECK-NEXT: [[RETVAL:%.*]] = fcmp reassoc nsz arcp contract afn ole double [[A:%.*]], [[B:%.*]] ; CHECK-NEXT: ret i1 [[RETVAL]] ; %cmp = fcmp fast ole double %a, %b @@ -943,7 +945,7 @@ define i1 @auto_gen_23_logical_fmf(double %a, double %b) { ; CHECK-LABEL: @auto_gen_23_logical_fmf( -; CHECK-NEXT: [[RETVAL:%.*]] = fcmp fast one double [[A:%.*]], [[B:%.*]] +; CHECK-NEXT: [[RETVAL:%.*]] = fcmp reassoc nsz arcp contract afn one double [[A:%.*]], [[B:%.*]] ; CHECK-NEXT: ret i1 [[RETVAL]] ; %cmp = fcmp fast one double %a, %b @@ -1009,7 +1011,7 @@ define i1 @auto_gen_25_logical_fmf(double %a, double %b) { ; CHECK-LABEL: @auto_gen_25_logical_fmf( -; CHECK-NEXT: [[RETVAL:%.*]] = fcmp fast one double [[A:%.*]], [[B:%.*]] +; CHECK-NEXT: [[RETVAL:%.*]] = fcmp reassoc nsz arcp contract afn one double [[A:%.*]], [[B:%.*]] ; CHECK-NEXT: ret i1 [[RETVAL]] ; %cmp = fcmp fast one double %a, %b @@ -1075,7 +1077,7 @@ define i1 @auto_gen_27_logical_fmf(double %a, double %b) { ; CHECK-LABEL: @auto_gen_27_logical_fmf( -; CHECK-NEXT: [[RETVAL:%.*]] = fcmp fast one double [[A:%.*]], [[B:%.*]] +; CHECK-NEXT: [[RETVAL:%.*]] = fcmp reassoc nsz arcp contract afn one double [[A:%.*]], [[B:%.*]] ; CHECK-NEXT: ret i1 [[RETVAL]] ; %cmp = fcmp fast one double %a, %b @@ -1401,7 +1403,7 @@ define i1 @auto_gen_37_logical_fmf(double %a, double %b) { ; CHECK-LABEL: @auto_gen_37_logical_fmf( -; CHECK-NEXT: [[RETVAL:%.*]] = fcmp fast ueq double [[A:%.*]], [[B:%.*]] +; CHECK-NEXT: [[RETVAL:%.*]] = fcmp reassoc nsz arcp contract afn ueq double [[A:%.*]], [[B:%.*]] ; CHECK-NEXT: ret i1 [[RETVAL]] ; %cmp = fcmp fast ueq double %a, %b @@ -1467,7 +1469,7 @@ define i1 @auto_gen_39_logical_fmf(double %a, double %b) { ; CHECK-LABEL: @auto_gen_39_logical_fmf( -; CHECK-NEXT: [[RETVAL:%.*]] = fcmp fast uge double [[A:%.*]], [[B:%.*]] +; CHECK-NEXT: [[RETVAL:%.*]] = fcmp reassoc nsz arcp contract afn uge double [[A:%.*]], [[B:%.*]] ; CHECK-NEXT: ret i1 [[RETVAL]] ; %cmp = fcmp fast ueq double %a, %b @@ -1533,7 +1535,7 @@ define i1 @auto_gen_41_logical_fmf(double %a, double %b) { ; CHECK-LABEL: @auto_gen_41_logical_fmf( -; CHECK-NEXT: [[RETVAL:%.*]] = fcmp fast ule double [[A:%.*]], [[B:%.*]] +; CHECK-NEXT: [[RETVAL:%.*]] = fcmp reassoc nsz arcp contract afn ule double [[A:%.*]], [[B:%.*]] ; CHECK-NEXT: ret i1 [[RETVAL]] ; %cmp = fcmp fast ueq double %a, %b @@ -1725,7 +1727,7 @@ define i1 @auto_gen_47_logical_fmf(double %a, double %b) { ; CHECK-LABEL: @auto_gen_47_logical_fmf( -; CHECK-NEXT: [[RETVAL:%.*]] = fcmp fast ugt double [[A:%.*]], [[B:%.*]] +; CHECK-NEXT: [[RETVAL:%.*]] = fcmp reassoc nsz arcp contract afn ugt double [[A:%.*]], [[B:%.*]] ; CHECK-NEXT: ret i1 [[RETVAL]] ; %cmp = fcmp fast ugt double %a, %b @@ -1791,7 +1793,7 @@ define i1 @auto_gen_49_logical_fmf(double %a, double %b) { ; CHECK-LABEL: @auto_gen_49_logical_fmf( -; CHECK-NEXT: [[RETVAL:%.*]] = fcmp fast une double [[A:%.*]], [[B:%.*]] +; CHECK-NEXT: [[RETVAL:%.*]] = fcmp reassoc nsz arcp contract afn une double [[A:%.*]], [[B:%.*]] ; CHECK-NEXT: ret i1 [[RETVAL]] ; %cmp = fcmp fast ugt double %a, %b @@ -1854,7 +1856,7 @@ define i1 @auto_gen_51_logical_fmf(double %a, double %b) { ; CHECK-LABEL: @auto_gen_51_logical_fmf( -; CHECK-NEXT: [[RETVAL:%.*]] = fcmp fast une double [[A:%.*]], [[B:%.*]] +; CHECK-NEXT: [[RETVAL:%.*]] = fcmp reassoc nsz arcp contract afn une double [[A:%.*]], [[B:%.*]] ; CHECK-NEXT: ret i1 [[RETVAL]] ; %cmp = fcmp fast ugt double %a, %b @@ -1917,7 +1919,7 @@ define i1 @auto_gen_53_logical_fmf(double %a, double %b) { ; CHECK-LABEL: @auto_gen_53_logical_fmf( -; CHECK-NEXT: [[RETVAL:%.*]] = fcmp fast uge double [[A:%.*]], [[B:%.*]] +; CHECK-NEXT: [[RETVAL:%.*]] = fcmp reassoc nsz arcp contract afn uge double [[A:%.*]], [[B:%.*]] ; CHECK-NEXT: ret i1 [[RETVAL]] ; %cmp = fcmp fast ugt double %a, %b @@ -2049,7 +2051,7 @@ define i1 @auto_gen_57_logical_fmf(double %a, double %b) { ; CHECK-LABEL: @auto_gen_57_logical_fmf( -; CHECK-NEXT: [[RETVAL:%.*]] = fcmp fast uge double [[A:%.*]], [[B:%.*]] +; CHECK-NEXT: [[RETVAL:%.*]] = fcmp reassoc nsz arcp contract afn uge double [[A:%.*]], [[B:%.*]] ; CHECK-NEXT: ret i1 [[RETVAL]] ; %cmp = fcmp fast uge double %a, %b @@ -2235,7 +2237,7 @@ define i1 @auto_gen_63_logical_fmf(double %a, double %b) { ; CHECK-LABEL: @auto_gen_63_logical_fmf( -; CHECK-NEXT: [[RETVAL:%.*]] = fcmp fast uge double [[A:%.*]], [[B:%.*]] +; CHECK-NEXT: [[RETVAL:%.*]] = fcmp reassoc nsz arcp contract afn uge double [[A:%.*]], [[B:%.*]] ; CHECK-NEXT: ret i1 [[RETVAL]] ; %cmp = fcmp fast uge double %a, %b @@ -2301,7 +2303,7 @@ define i1 @auto_gen_65_logical_fmf(double %a, double %b) { ; CHECK-LABEL: @auto_gen_65_logical_fmf( -; CHECK-NEXT: [[RETVAL:%.*]] = fcmp fast uge double [[A:%.*]], [[B:%.*]] +; CHECK-NEXT: [[RETVAL:%.*]] = fcmp reassoc nsz arcp contract afn uge double [[A:%.*]], [[B:%.*]] ; CHECK-NEXT: ret i1 [[RETVAL]] ; %cmp = fcmp fast uge double %a, %b @@ -2367,7 +2369,7 @@ define i1 @auto_gen_67_logical_fmf(double %a, double %b) { ; CHECK-LABEL: @auto_gen_67_logical_fmf( -; CHECK-NEXT: [[RETVAL:%.*]] = fcmp fast ule double [[A:%.*]], [[B:%.*]] +; CHECK-NEXT: [[RETVAL:%.*]] = fcmp reassoc nsz arcp contract afn ule double [[A:%.*]], [[B:%.*]] ; CHECK-NEXT: ret i1 [[RETVAL]] ; %cmp = fcmp fast ult double %a, %b @@ -2496,7 +2498,7 @@ define i1 @auto_gen_71_logical_fmf(double %a, double %b) { ; CHECK-LABEL: @auto_gen_71_logical_fmf( -; CHECK-NEXT: [[RETVAL:%.*]] = fcmp fast ule double [[A:%.*]], [[B:%.*]] +; CHECK-NEXT: [[RETVAL:%.*]] = fcmp reassoc nsz arcp contract afn ule double [[A:%.*]], [[B:%.*]] ; CHECK-NEXT: ret i1 [[RETVAL]] ; %cmp = fcmp fast ult double %a, %b @@ -2625,7 +2627,7 @@ define i1 @auto_gen_75_logical_fmf(double %a, double %b) { ; CHECK-LABEL: @auto_gen_75_logical_fmf( -; CHECK-NEXT: [[RETVAL:%.*]] = fcmp fast une double [[A:%.*]], [[B:%.*]] +; CHECK-NEXT: [[RETVAL:%.*]] = fcmp reassoc nsz arcp contract afn une double [[A:%.*]], [[B:%.*]] ; CHECK-NEXT: ret i1 [[RETVAL]] ; %cmp = fcmp fast ult double %a, %b @@ -2688,7 +2690,7 @@ define i1 @auto_gen_77_logical_fmf(double %a, double %b) { ; CHECK-LABEL: @auto_gen_77_logical_fmf( -; CHECK-NEXT: [[RETVAL:%.*]] = fcmp fast ult double [[A:%.*]], [[B:%.*]] +; CHECK-NEXT: [[RETVAL:%.*]] = fcmp reassoc nsz arcp contract afn ult double [[A:%.*]], [[B:%.*]] ; CHECK-NEXT: ret i1 [[RETVAL]] ; %cmp = fcmp fast ult double %a, %b @@ -2754,7 +2756,7 @@ define i1 @auto_gen_79_logical_fmf(double %a, double %b) { ; CHECK-LABEL: @auto_gen_79_logical_fmf( -; CHECK-NEXT: [[RETVAL:%.*]] = fcmp fast ule double [[A:%.*]], [[B:%.*]] +; CHECK-NEXT: [[RETVAL:%.*]] = fcmp reassoc nsz arcp contract afn ule double [[A:%.*]], [[B:%.*]] ; CHECK-NEXT: ret i1 [[RETVAL]] ; %cmp = fcmp fast ule double %a, %b @@ -2880,7 +2882,7 @@ define i1 @auto_gen_83_logical_fmf(double %a, double %b) { ; CHECK-LABEL: @auto_gen_83_logical_fmf( -; CHECK-NEXT: [[RETVAL:%.*]] = fcmp fast ule double [[A:%.*]], [[B:%.*]] +; CHECK-NEXT: [[RETVAL:%.*]] = fcmp reassoc nsz arcp contract afn ule double [[A:%.*]], [[B:%.*]] ; CHECK-NEXT: ret i1 [[RETVAL]] ; %cmp = fcmp fast ule double %a, %b @@ -3066,7 +3068,7 @@ define i1 @auto_gen_89_logical_fmf(double %a, double %b) { ; CHECK-LABEL: @auto_gen_89_logical_fmf( -; CHECK-NEXT: [[RETVAL:%.*]] = fcmp fast ule double [[A:%.*]], [[B:%.*]] +; CHECK-NEXT: [[RETVAL:%.*]] = fcmp reassoc nsz arcp contract afn ule double [[A:%.*]], [[B:%.*]] ; CHECK-NEXT: ret i1 [[RETVAL]] ; %cmp = fcmp fast ule double %a, %b @@ -3195,7 +3197,7 @@ define i1 @auto_gen_93_logical_fmf(double %a, double %b) { ; CHECK-LABEL: @auto_gen_93_logical_fmf( -; CHECK-NEXT: [[RETVAL:%.*]] = fcmp fast une double [[A:%.*]], [[B:%.*]] +; CHECK-NEXT: [[RETVAL:%.*]] = fcmp reassoc nsz arcp contract afn une double [[A:%.*]], [[B:%.*]] ; CHECK-NEXT: ret i1 [[RETVAL]] ; %cmp = fcmp fast une double %a, %b @@ -3258,7 +3260,7 @@ define i1 @auto_gen_95_logical_fmf(double %a, double %b) { ; CHECK-LABEL: @auto_gen_95_logical_fmf( -; CHECK-NEXT: [[RETVAL:%.*]] = fcmp fast une double [[A:%.*]], [[B:%.*]] +; CHECK-NEXT: [[RETVAL:%.*]] = fcmp reassoc nsz arcp contract afn une double [[A:%.*]], [[B:%.*]] ; CHECK-NEXT: ret i1 [[RETVAL]] ; %cmp = fcmp fast une double %a, %b @@ -3321,7 +3323,7 @@ define i1 @auto_gen_97_logical_fmf(double %a, double %b) { ; CHECK-LABEL: @auto_gen_97_logical_fmf( -; CHECK-NEXT: [[RETVAL:%.*]] = fcmp fast une double [[A:%.*]], [[B:%.*]] +; CHECK-NEXT: [[RETVAL:%.*]] = fcmp reassoc nsz arcp contract afn une double [[A:%.*]], [[B:%.*]] ; CHECK-NEXT: ret i1 [[RETVAL]] ; %cmp = fcmp fast une double %a, %b diff --git a/llvm/test/Transforms/InstCombine/prevent-cmp-merge.ll b/llvm/test/Transforms/InstCombine/prevent-cmp-merge.ll --- a/llvm/test/Transforms/InstCombine/prevent-cmp-merge.ll +++ b/llvm/test/Transforms/InstCombine/prevent-cmp-merge.ll @@ -71,10 +71,10 @@ define zeroext i1 @test3_logical(i32 %lhs, i32 %rhs) { ; CHECK-LABEL: @test3_logical( -; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 [[LHS:%.*]], [[RHS:%.*]] +; CHECK-NEXT: [[SUB:%.*]] = sub i32 [[LHS:%.*]], [[RHS:%.*]] ; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i32 [[LHS]], [[RHS]] ; CHECK-NEXT: [[CMP2:%.*]] = icmp eq i32 [[SUB]], 31 -; CHECK-NEXT: [[SEL:%.*]] = select i1 [[CMP1]], i1 true, i1 [[CMP2]] +; CHECK-NEXT: [[SEL:%.*]] = or i1 [[CMP1]], [[CMP2]] ; CHECK-NEXT: ret i1 [[SEL]] ;