Loading llvm/test/Transforms/InstCombine/overflow_to_sat.ll 0 → 100644 +730 −0 File added.Preview size limit exceeded, changes collapsed. Show changes llvm/test/Transforms/InstCombine/saturating-add-sub.ll +48 −0 Original line number Diff line number Diff line Loading @@ -1484,6 +1484,54 @@ define i32 @uadd_sat_constant_commute(i32 %x) { ret i32 %r } define i32 @uadd_sat_canon(i32 %x, i32 %y) { ; CHECK-LABEL: @uadd_sat_canon( ; CHECK-NEXT: [[A:%.*]] = add i32 [[X:%.*]], [[Y:%.*]] ; CHECK-NEXT: [[C:%.*]] = icmp ult i32 [[A]], [[X]] ; CHECK-NEXT: [[R:%.*]] = select i1 [[C]], i32 -1, i32 [[A]] ; CHECK-NEXT: ret i32 [[R]] ; %a = add i32 %x, %y %c = icmp ult i32 %a, %x %r = select i1 %c, i32 -1, i32 %a ret i32 %r } define i32 @uadd_sat_canon_y(i32 %x, i32 %y) { ; CHECK-LABEL: @uadd_sat_canon_y( ; CHECK-NEXT: [[A:%.*]] = add i32 [[X:%.*]], [[Y:%.*]] ; CHECK-NEXT: [[C:%.*]] = icmp ult i32 [[A]], [[Y]] ; CHECK-NEXT: [[R:%.*]] = select i1 [[C]], i32 -1, i32 [[A]] ; CHECK-NEXT: ret i32 [[R]] ; %a = add i32 %x, %y %c = icmp ult i32 %a, %y %r = select i1 %c, i32 -1, i32 %a ret i32 %r } define i32 @uadd_sat_canon_nuw(i32 %x, i32 %y) { ; CHECK-LABEL: @uadd_sat_canon_nuw( ; CHECK-NEXT: [[A:%.*]] = add nuw i32 [[X:%.*]], [[Y:%.*]] ; CHECK-NEXT: ret i32 [[A]] ; %a = add nuw i32 %x, %y %c = icmp ult i32 %a, %x %r = select i1 %c, i32 -1, i32 %a ret i32 %r } define i32 @uadd_sat_canon_y_nuw(i32 %x, i32 %y) { ; CHECK-LABEL: @uadd_sat_canon_y_nuw( ; CHECK-NEXT: [[A:%.*]] = add nuw i32 [[X:%.*]], [[Y:%.*]] ; CHECK-NEXT: ret i32 [[A]] ; %a = add nuw i32 %x, %y %c = icmp ult i32 %a, %y %r = select i1 %c, i32 -1, i32 %a ret i32 %r } define <4 x i32> @uadd_sat_constant_vec(<4 x i32> %x) { ; CHECK-LABEL: @uadd_sat_constant_vec( ; CHECK-NEXT: [[A:%.*]] = add <4 x i32> [[X:%.*]], <i32 42, i32 42, i32 42, i32 42> Loading Loading
llvm/test/Transforms/InstCombine/overflow_to_sat.ll 0 → 100644 +730 −0 File added.Preview size limit exceeded, changes collapsed. Show changes
llvm/test/Transforms/InstCombine/saturating-add-sub.ll +48 −0 Original line number Diff line number Diff line Loading @@ -1484,6 +1484,54 @@ define i32 @uadd_sat_constant_commute(i32 %x) { ret i32 %r } define i32 @uadd_sat_canon(i32 %x, i32 %y) { ; CHECK-LABEL: @uadd_sat_canon( ; CHECK-NEXT: [[A:%.*]] = add i32 [[X:%.*]], [[Y:%.*]] ; CHECK-NEXT: [[C:%.*]] = icmp ult i32 [[A]], [[X]] ; CHECK-NEXT: [[R:%.*]] = select i1 [[C]], i32 -1, i32 [[A]] ; CHECK-NEXT: ret i32 [[R]] ; %a = add i32 %x, %y %c = icmp ult i32 %a, %x %r = select i1 %c, i32 -1, i32 %a ret i32 %r } define i32 @uadd_sat_canon_y(i32 %x, i32 %y) { ; CHECK-LABEL: @uadd_sat_canon_y( ; CHECK-NEXT: [[A:%.*]] = add i32 [[X:%.*]], [[Y:%.*]] ; CHECK-NEXT: [[C:%.*]] = icmp ult i32 [[A]], [[Y]] ; CHECK-NEXT: [[R:%.*]] = select i1 [[C]], i32 -1, i32 [[A]] ; CHECK-NEXT: ret i32 [[R]] ; %a = add i32 %x, %y %c = icmp ult i32 %a, %y %r = select i1 %c, i32 -1, i32 %a ret i32 %r } define i32 @uadd_sat_canon_nuw(i32 %x, i32 %y) { ; CHECK-LABEL: @uadd_sat_canon_nuw( ; CHECK-NEXT: [[A:%.*]] = add nuw i32 [[X:%.*]], [[Y:%.*]] ; CHECK-NEXT: ret i32 [[A]] ; %a = add nuw i32 %x, %y %c = icmp ult i32 %a, %x %r = select i1 %c, i32 -1, i32 %a ret i32 %r } define i32 @uadd_sat_canon_y_nuw(i32 %x, i32 %y) { ; CHECK-LABEL: @uadd_sat_canon_y_nuw( ; CHECK-NEXT: [[A:%.*]] = add nuw i32 [[X:%.*]], [[Y:%.*]] ; CHECK-NEXT: ret i32 [[A]] ; %a = add nuw i32 %x, %y %c = icmp ult i32 %a, %y %r = select i1 %c, i32 -1, i32 %a ret i32 %r } define <4 x i32> @uadd_sat_constant_vec(<4 x i32> %x) { ; CHECK-LABEL: @uadd_sat_constant_vec( ; CHECK-NEXT: [[A:%.*]] = add <4 x i32> [[X:%.*]], <i32 42, i32 42, i32 42, i32 42> Loading