File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed
lib/Transforms/InstCombine
test/Transforms/InstCombine Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -1549,8 +1549,11 @@ Instruction *InstCombinerImpl::visitAdd(BinaryOperator &I) {
15491549 I.hasNoUnsignedWrap ()))
15501550 return R;
15511551 Type *Ty = I.getType ();
1552- if (Ty->isIntOrIntVectorTy (1 ))
1552+ if (Ty->isIntOrIntVectorTy (1 )) {
1553+ if (I.hasNoUnsignedWrap () || I.hasNoSignedWrap ())
1554+ return BinaryOperator::CreateDisjoint (Instruction::Or, LHS, RHS);
15531555 return BinaryOperator::CreateXor (LHS, RHS);
1556+ }
15541557
15551558 // X + X --> X << 1
15561559 if (LHS == RHS) {
Original file line number Diff line number Diff line change @@ -498,3 +498,21 @@ define i32 @sub_undemanded_low_bits(i32 %x) {
498498 %shr = lshr i32 %sub , 4
499499 ret i32 %shr
500500}
501+
502+ define i1 @add_nuw_i1 (i1 %x , i1 %y ) {
503+ ; CHECK-LABEL: @add_nuw_i1(
504+ ; CHECK-NEXT: [[Z:%.*]] = or disjoint i1 [[X:%.*]], [[Y:%.*]]
505+ ; CHECK-NEXT: ret i1 [[Z]]
506+ ;
507+ %z = add nuw i1 %x , %y
508+ ret i1 %z
509+ }
510+
511+ define i1 @add_nsw_i1 (i1 %x , i1 %y ) {
512+ ; CHECK-LABEL: @add_nsw_i1(
513+ ; CHECK-NEXT: [[Z:%.*]] = or disjoint i1 [[X:%.*]], [[Y:%.*]]
514+ ; CHECK-NEXT: ret i1 [[Z]]
515+ ;
516+ %z = add nsw i1 %x , %y
517+ ret i1 %z
518+ }
You can’t perform that action at this time.
0 commit comments