%r = add i32 %s, -42
ret i32 %r
}
+
+define i8 @umax(i8 %a, i8 %b) {
+; CHECK-LABEL: @umax(
+; CHECK-NEXT: [[USUB:%.*]] = tail call i8 @llvm.usub.sat.i8(i8 [[A:%.*]], i8 [[B:%.*]])
+; CHECK-NEXT: [[R:%.*]] = add i8 [[USUB]], [[B]]
+; CHECK-NEXT: ret i8 [[R]]
+;
+ %usub = tail call i8 @llvm.usub.sat.i8(i8 %a, i8 %b)
+ %r = add i8 %usub, %b
+ ret i8 %r
+}
+
+define <2 x i8> @umax_vec(<2 x i8> %a, <2 x i8> %b) {
+; CHECK-LABEL: @umax_vec(
+; CHECK-NEXT: [[USUB:%.*]] = tail call <2 x i8> @llvm.usub.sat.v2i8(<2 x i8> [[A:%.*]], <2 x i8> [[B:%.*]])
+; CHECK-NEXT: [[R:%.*]] = add <2 x i8> [[USUB]], [[B]]
+; CHECK-NEXT: ret <2 x i8> [[R]]
+;
+ %usub = tail call <2 x i8> @llvm.usub.sat.v2i8(<2 x i8> %a, <2 x i8> %b)
+ %r = add <2 x i8> %usub, %b
+ ret <2 x i8> %r
+}
+
+define i8 @umax_extra_use(i8 %a, i8 %b) {
+; CHECK-LABEL: @umax_extra_use(
+; CHECK-NEXT: [[USUB:%.*]] = tail call i8 @llvm.usub.sat.i8(i8 [[A:%.*]], i8 [[B:%.*]])
+; CHECK-NEXT: call void @use(i8 [[USUB]])
+; CHECK-NEXT: [[R:%.*]] = add i8 [[USUB]], [[B]]
+; CHECK-NEXT: ret i8 [[R]]
+;
+ %usub = tail call i8 @llvm.usub.sat.i8(i8 %a, i8 %b)
+ call void @use(i8 %usub)
+ %r = add i8 %usub, %b
+ ret i8 %r
+}
+
+define i8 @umin(i8 %a, i8 %b) {
+; CHECK-LABEL: @umin(
+; CHECK-NEXT: [[USUB:%.*]] = tail call i8 @llvm.usub.sat.i8(i8 [[A:%.*]], i8 [[B:%.*]])
+; CHECK-NEXT: [[R:%.*]] = sub i8 [[A]], [[USUB]]
+; CHECK-NEXT: ret i8 [[R]]
+;
+ %usub = tail call i8 @llvm.usub.sat.i8(i8 %a, i8 %b)
+ %r = sub i8 %a, %usub
+ ret i8 %r
+}
+
+define <2 x i8> @umin_vec(<2 x i8> %a, <2 x i8> %b) {
+; CHECK-LABEL: @umin_vec(
+; CHECK-NEXT: [[USUB:%.*]] = tail call <2 x i8> @llvm.usub.sat.v2i8(<2 x i8> [[A:%.*]], <2 x i8> [[B:%.*]])
+; CHECK-NEXT: [[R:%.*]] = sub <2 x i8> [[A]], [[USUB]]
+; CHECK-NEXT: ret <2 x i8> [[R]]
+;
+ %usub = tail call <2 x i8> @llvm.usub.sat.v2i8(<2 x i8> %a, <2 x i8> %b)
+ %r = sub <2 x i8> %a, %usub
+ ret <2 x i8> %r
+}
+
+define i8 @umin_extra_use(i8 %a, i8 %b) {
+; CHECK-LABEL: @umin_extra_use(
+; CHECK-NEXT: [[USUB:%.*]] = tail call i8 @llvm.usub.sat.i8(i8 [[A:%.*]], i8 [[B:%.*]])
+; CHECK-NEXT: call void @use(i8 [[USUB]])
+; CHECK-NEXT: [[R:%.*]] = sub i8 [[A]], [[USUB]]
+; CHECK-NEXT: ret i8 [[R]]
+;
+ %usub = tail call i8 @llvm.usub.sat.i8(i8 %a, i8 %b)
+ call void @use(i8 %usub)
+ %r = sub i8 %a, %usub
+ ret i8 %r
+}
+
+declare void @use(i8)