define i32 @test_abs(i32 %x) {
; CHECK-LABEL: @test_abs(
-; CHECK-NEXT: [[TMP1:%.*]] = icmp slt i32 [[X:%.*]], 0
-; CHECK-NEXT: [[NEG:%.*]] = sub nsw i32 0, [[X]]
-; CHECK-NEXT: [[TMP2:%.*]] = select i1 [[TMP1]], i32 [[NEG]], i32 [[X]]
-; CHECK-NEXT: ret i32 [[TMP2]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 true)
+; CHECK-NEXT: ret i32 [[TMP1]]
;
%ret = call i32 @abs(i32 %x)
ret i32 %ret
define i64 @test_labs(i64 %x) {
; CHECK-LABEL: @test_labs(
-; CHECK-NEXT: [[TMP1:%.*]] = icmp slt i64 [[X:%.*]], 0
-; CHECK-NEXT: [[NEG:%.*]] = sub nsw i64 0, [[X]]
-; CHECK-NEXT: [[TMP2:%.*]] = select i1 [[TMP1]], i64 [[NEG]], i64 [[X]]
-; CHECK-NEXT: ret i64 [[TMP2]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i64 @llvm.abs.i64(i64 [[X:%.*]], i1 true)
+; CHECK-NEXT: ret i64 [[TMP1]]
;
%ret = call i64 @labs(i64 %x)
ret i64 %ret
define i64 @test_llabs(i64 %x) {
; CHECK-LABEL: @test_llabs(
-; CHECK-NEXT: [[TMP1:%.*]] = icmp slt i64 [[X:%.*]], 0
-; CHECK-NEXT: [[NEG:%.*]] = sub nsw i64 0, [[X]]
-; CHECK-NEXT: [[TMP2:%.*]] = select i1 [[TMP1]], i64 [[NEG]], i64 [[X]]
-; CHECK-NEXT: ret i64 [[TMP2]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i64 @llvm.abs.i64(i64 [[X:%.*]], i1 true)
+; CHECK-NEXT: ret i64 [[TMP1]]
;
%ret = call i64 @llabs(i64 %x)
ret i64 %ret
define i8 @abs_canonical_1(i8 %x) {
; CHECK-LABEL: @abs_canonical_1(
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[X:%.*]], 0
-; CHECK-NEXT: [[NEG:%.*]] = sub i8 0, [[X]]
-; CHECK-NEXT: [[ABS:%.*]] = select i1 [[CMP]], i8 [[NEG]], i8 [[X]]
-; CHECK-NEXT: ret i8 [[ABS]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i8 @llvm.abs.i8(i8 [[X:%.*]], i1 false)
+; CHECK-NEXT: ret i8 [[TMP1]]
;
%cmp = icmp sgt i8 %x, 0
%neg = sub i8 0, %x
define <2 x i8> @abs_canonical_2(<2 x i8> %x) {
; CHECK-LABEL: @abs_canonical_2(
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt <2 x i8> [[X:%.*]], zeroinitializer
-; CHECK-NEXT: [[NEG:%.*]] = sub <2 x i8> zeroinitializer, [[X]]
-; CHECK-NEXT: [[ABS:%.*]] = select <2 x i1> [[CMP]], <2 x i8> [[NEG]], <2 x i8> [[X]]
-; CHECK-NEXT: ret <2 x i8> [[ABS]]
+; CHECK-NEXT: [[TMP1:%.*]] = call <2 x i8> @llvm.abs.v2i8(<2 x i8> [[X:%.*]], i1 false)
+; CHECK-NEXT: ret <2 x i8> [[TMP1]]
;
%cmp = icmp sgt <2 x i8> %x, <i8 -1, i8 -1>
%neg = sub <2 x i8> zeroinitializer, %x
define <2 x i8> @abs_canonical_2_vec_undef_elts(<2 x i8> %x) {
; CHECK-LABEL: @abs_canonical_2_vec_undef_elts(
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt <2 x i8> [[X:%.*]], zeroinitializer
-; CHECK-NEXT: [[NEG:%.*]] = sub <2 x i8> zeroinitializer, [[X]]
-; CHECK-NEXT: [[ABS:%.*]] = select <2 x i1> [[CMP]], <2 x i8> [[NEG]], <2 x i8> [[X]]
-; CHECK-NEXT: ret <2 x i8> [[ABS]]
+; CHECK-NEXT: [[TMP1:%.*]] = call <2 x i8> @llvm.abs.v2i8(<2 x i8> [[X:%.*]], i1 false)
+; CHECK-NEXT: ret <2 x i8> [[TMP1]]
;
%cmp = icmp sgt <2 x i8> %x, <i8 undef, i8 -1>
%neg = sub <2 x i8> zeroinitializer, %x
define i8 @abs_canonical_3(i8 %x) {
; CHECK-LABEL: @abs_canonical_3(
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[X:%.*]], 0
-; CHECK-NEXT: [[NEG:%.*]] = sub nsw i8 0, [[X]]
-; CHECK-NEXT: [[ABS:%.*]] = select i1 [[CMP]], i8 [[NEG]], i8 [[X]]
-; CHECK-NEXT: ret i8 [[ABS]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i8 @llvm.abs.i8(i8 [[X:%.*]], i1 true)
+; CHECK-NEXT: ret i8 [[TMP1]]
;
%cmp = icmp slt i8 %x, 0
%neg = sub nsw i8 0, %x
define i8 @abs_canonical_4(i8 %x) {
; CHECK-LABEL: @abs_canonical_4(
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[X:%.*]], 0
-; CHECK-NEXT: [[NEG:%.*]] = sub i8 0, [[X]]
-; CHECK-NEXT: [[ABS:%.*]] = select i1 [[CMP]], i8 [[NEG]], i8 [[X]]
-; CHECK-NEXT: ret i8 [[ABS]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i8 @llvm.abs.i8(i8 [[X:%.*]], i1 false)
+; CHECK-NEXT: ret i8 [[TMP1]]
;
%cmp = icmp slt i8 %x, 1
%neg = sub i8 0, %x
define i32 @abs_canonical_5(i8 %x) {
; CHECK-LABEL: @abs_canonical_5(
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[X:%.*]], 0
-; CHECK-NEXT: [[CONV:%.*]] = sext i8 [[X]] to i32
-; CHECK-NEXT: [[NEG:%.*]] = sub nsw i32 0, [[CONV]]
-; CHECK-NEXT: [[ABS:%.*]] = select i1 [[CMP]], i32 [[NEG]], i32 [[CONV]]
-; CHECK-NEXT: ret i32 [[ABS]]
+; CHECK-NEXT: [[CONV:%.*]] = sext i8 [[X:%.*]] to i32
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[CONV]], i1 true)
+; CHECK-NEXT: ret i32 [[TMP1]]
;
%cmp = icmp sgt i8 %x, 0
%conv = sext i8 %x to i32
define i32 @abs_canonical_6(i32 %a, i32 %b) {
; CHECK-LABEL: @abs_canonical_6(
; CHECK-NEXT: [[T1:%.*]] = sub i32 [[A:%.*]], [[B:%.*]]
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[T1]], 0
-; CHECK-NEXT: [[TMP1:%.*]] = sub i32 0, [[T1]]
-; CHECK-NEXT: [[ABS:%.*]] = select i1 [[CMP]], i32 [[TMP1]], i32 [[T1]]
-; CHECK-NEXT: ret i32 [[ABS]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[T1]], i1 false)
+; CHECK-NEXT: ret i32 [[TMP1]]
;
%t1 = sub i32 %a, %b
%cmp = icmp sgt i32 %t1, -1
define <2 x i8> @abs_canonical_7(<2 x i8> %a, <2 x i8 > %b) {
; CHECK-LABEL: @abs_canonical_7(
; CHECK-NEXT: [[T1:%.*]] = sub <2 x i8> [[A:%.*]], [[B:%.*]]
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt <2 x i8> [[T1]], zeroinitializer
-; CHECK-NEXT: [[TMP1:%.*]] = sub <2 x i8> zeroinitializer, [[T1]]
-; CHECK-NEXT: [[ABS:%.*]] = select <2 x i1> [[CMP]], <2 x i8> [[TMP1]], <2 x i8> [[T1]]
-; CHECK-NEXT: ret <2 x i8> [[ABS]]
+; CHECK-NEXT: [[TMP1:%.*]] = call <2 x i8> @llvm.abs.v2i8(<2 x i8> [[T1]], i1 false)
+; CHECK-NEXT: ret <2 x i8> [[TMP1]]
;
%t1 = sub <2 x i8> %a, %b
define i32 @abs_canonical_8(i32 %a) {
; CHECK-LABEL: @abs_canonical_8(
-; CHECK-NEXT: [[T:%.*]] = sub i32 0, [[A:%.*]]
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[A]], 0
-; CHECK-NEXT: [[ABS:%.*]] = select i1 [[CMP]], i32 [[T]], i32 [[A]]
-; CHECK-NEXT: ret i32 [[ABS]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[A:%.*]], i1 false)
+; CHECK-NEXT: ret i32 [[TMP1]]
;
%t = sub i32 0, %a
%cmp = icmp slt i32 %t, 0
define i32 @abs_canonical_9(i32 %a, i32 %b) {
; CHECK-LABEL: @abs_canonical_9(
; CHECK-NEXT: [[T1:%.*]] = sub i32 [[A:%.*]], [[B:%.*]]
-; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[T1]], -1
; CHECK-NEXT: [[T2:%.*]] = sub i32 [[B]], [[A]]
-; CHECK-NEXT: [[ABS:%.*]] = select i1 [[CMP]], i32 [[T1]], i32 [[T2]]
-; CHECK-NEXT: [[ADD:%.*]] = add i32 [[ABS]], [[T2]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[T1]], i1 false)
+; CHECK-NEXT: [[ADD:%.*]] = add i32 [[TMP1]], [[T2]]
; CHECK-NEXT: ret i32 [[ADD]]
;
%t1 = sub i32 %a, %b
define i32 @abs_canonical_10(i32 %a, i32 %b) {
; CHECK-LABEL: @abs_canonical_10(
; CHECK-NEXT: [[T1:%.*]] = sub i32 [[A:%.*]], [[B:%.*]]
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[T1]], 0
-; CHECK-NEXT: [[TMP1:%.*]] = sub i32 0, [[T1]]
-; CHECK-NEXT: [[ABS:%.*]] = select i1 [[CMP]], i32 [[TMP1]], i32 [[T1]]
-; CHECK-NEXT: ret i32 [[ABS]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[T1]], i1 false)
+; CHECK-NEXT: ret i32 [[TMP1]]
;
%t2 = sub i32 %b, %a
%t1 = sub i32 %a, %b
define i8 @nabs_canonical_1(i8 %x) {
; CHECK-LABEL: @nabs_canonical_1(
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[X:%.*]], 0
-; CHECK-NEXT: [[NEG:%.*]] = sub i8 0, [[X]]
-; CHECK-NEXT: [[ABS:%.*]] = select i1 [[CMP]], i8 [[X]], i8 [[NEG]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i8 @llvm.abs.i8(i8 [[X:%.*]], i1 false)
+; CHECK-NEXT: [[ABS:%.*]] = sub i8 0, [[TMP1]]
; CHECK-NEXT: ret i8 [[ABS]]
;
%cmp = icmp sgt i8 %x, 0
define <2 x i8> @nabs_canonical_2(<2 x i8> %x) {
; CHECK-LABEL: @nabs_canonical_2(
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt <2 x i8> [[X:%.*]], zeroinitializer
-; CHECK-NEXT: [[NEG:%.*]] = sub <2 x i8> zeroinitializer, [[X]]
-; CHECK-NEXT: [[ABS:%.*]] = select <2 x i1> [[CMP]], <2 x i8> [[X]], <2 x i8> [[NEG]]
+; CHECK-NEXT: [[TMP1:%.*]] = call <2 x i8> @llvm.abs.v2i8(<2 x i8> [[X:%.*]], i1 false)
+; CHECK-NEXT: [[ABS:%.*]] = sub <2 x i8> zeroinitializer, [[TMP1]]
; CHECK-NEXT: ret <2 x i8> [[ABS]]
;
%cmp = icmp sgt <2 x i8> %x, <i8 -1, i8 -1>
define <2 x i8> @nabs_canonical_2_vec_undef_elts(<2 x i8> %x) {
; CHECK-LABEL: @nabs_canonical_2_vec_undef_elts(
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt <2 x i8> [[X:%.*]], zeroinitializer
-; CHECK-NEXT: [[NEG:%.*]] = sub <2 x i8> zeroinitializer, [[X]]
-; CHECK-NEXT: [[ABS:%.*]] = select <2 x i1> [[CMP]], <2 x i8> [[X]], <2 x i8> [[NEG]]
+; CHECK-NEXT: [[TMP1:%.*]] = call <2 x i8> @llvm.abs.v2i8(<2 x i8> [[X:%.*]], i1 false)
+; CHECK-NEXT: [[ABS:%.*]] = sub <2 x i8> zeroinitializer, [[TMP1]]
; CHECK-NEXT: ret <2 x i8> [[ABS]]
;
%cmp = icmp sgt <2 x i8> %x, <i8 -1, i8 undef>
define i8 @nabs_canonical_3(i8 %x) {
; CHECK-LABEL: @nabs_canonical_3(
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[X:%.*]], 0
-; CHECK-NEXT: [[NEG:%.*]] = sub nsw i8 0, [[X]]
-; CHECK-NEXT: [[ABS:%.*]] = select i1 [[CMP]], i8 [[X]], i8 [[NEG]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i8 @llvm.abs.i8(i8 [[X:%.*]], i1 true)
+; CHECK-NEXT: [[ABS:%.*]] = sub nsw i8 0, [[TMP1]]
; CHECK-NEXT: ret i8 [[ABS]]
;
%cmp = icmp slt i8 %x, 0
define i8 @nabs_canonical_4(i8 %x) {
; CHECK-LABEL: @nabs_canonical_4(
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[X:%.*]], 0
-; CHECK-NEXT: [[NEG:%.*]] = sub i8 0, [[X]]
-; CHECK-NEXT: [[ABS:%.*]] = select i1 [[CMP]], i8 [[X]], i8 [[NEG]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i8 @llvm.abs.i8(i8 [[X:%.*]], i1 false)
+; CHECK-NEXT: [[ABS:%.*]] = sub i8 0, [[TMP1]]
; CHECK-NEXT: ret i8 [[ABS]]
;
%cmp = icmp slt i8 %x, 1
define i32 @nabs_canonical_5(i8 %x) {
; CHECK-LABEL: @nabs_canonical_5(
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[X:%.*]], 0
-; CHECK-NEXT: [[CONV:%.*]] = sext i8 [[X]] to i32
-; CHECK-NEXT: [[NEG:%.*]] = sub nsw i32 0, [[CONV]]
-; CHECK-NEXT: [[ABS:%.*]] = select i1 [[CMP]], i32 [[CONV]], i32 [[NEG]]
+; CHECK-NEXT: [[CONV:%.*]] = sext i8 [[X:%.*]] to i32
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[CONV]], i1 true)
+; CHECK-NEXT: [[ABS:%.*]] = sub nsw i32 0, [[TMP1]]
; CHECK-NEXT: ret i32 [[ABS]]
;
%cmp = icmp sgt i8 %x, 0
define i32 @nabs_canonical_6(i32 %a, i32 %b) {
; CHECK-LABEL: @nabs_canonical_6(
; CHECK-NEXT: [[T1:%.*]] = sub i32 [[A:%.*]], [[B:%.*]]
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[T1]], 0
-; CHECK-NEXT: [[TMP1:%.*]] = sub i32 0, [[T1]]
-; CHECK-NEXT: [[ABS:%.*]] = select i1 [[CMP]], i32 [[T1]], i32 [[TMP1]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[T1]], i1 false)
+; CHECK-NEXT: [[ABS:%.*]] = sub i32 0, [[TMP1]]
; CHECK-NEXT: ret i32 [[ABS]]
;
%t1 = sub i32 %a, %b
define <2 x i8> @nabs_canonical_7(<2 x i8> %a, <2 x i8 > %b) {
; CHECK-LABEL: @nabs_canonical_7(
; CHECK-NEXT: [[T1:%.*]] = sub <2 x i8> [[A:%.*]], [[B:%.*]]
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt <2 x i8> [[T1]], zeroinitializer
-; CHECK-NEXT: [[TMP1:%.*]] = sub <2 x i8> zeroinitializer, [[T1]]
-; CHECK-NEXT: [[ABS:%.*]] = select <2 x i1> [[CMP]], <2 x i8> [[T1]], <2 x i8> [[TMP1]]
+; CHECK-NEXT: [[TMP1:%.*]] = call <2 x i8> @llvm.abs.v2i8(<2 x i8> [[T1]], i1 false)
+; CHECK-NEXT: [[ABS:%.*]] = sub <2 x i8> zeroinitializer, [[TMP1]]
; CHECK-NEXT: ret <2 x i8> [[ABS]]
;
%t1 = sub <2 x i8> %a, %b
define i32 @nabs_canonical_8(i32 %a) {
; CHECK-LABEL: @nabs_canonical_8(
-; CHECK-NEXT: [[T:%.*]] = sub i32 0, [[A:%.*]]
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[A]], 0
-; CHECK-NEXT: [[ABS:%.*]] = select i1 [[CMP]], i32 [[A]], i32 [[T]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[A:%.*]], i1 false)
+; CHECK-NEXT: [[ABS:%.*]] = sub i32 0, [[TMP1]]
; CHECK-NEXT: ret i32 [[ABS]]
;
%t = sub i32 0, %a
define i32 @nabs_canonical_9(i32 %a, i32 %b) {
; CHECK-LABEL: @nabs_canonical_9(
; CHECK-NEXT: [[T1:%.*]] = sub i32 [[A:%.*]], [[B:%.*]]
-; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[T1]], -1
; CHECK-NEXT: [[T2:%.*]] = sub i32 [[B]], [[A]]
-; CHECK-NEXT: [[ABS:%.*]] = select i1 [[CMP]], i32 [[T2]], i32 [[T1]]
-; CHECK-NEXT: [[ADD:%.*]] = add i32 [[T2]], [[ABS]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[T1]], i1 false)
+; CHECK-NEXT: [[ADD:%.*]] = sub i32 [[T2]], [[TMP1]]
; CHECK-NEXT: ret i32 [[ADD]]
;
%t1 = sub i32 %a, %b
define i32 @nabs_canonical_10(i32 %a, i32 %b) {
; CHECK-LABEL: @nabs_canonical_10(
; CHECK-NEXT: [[T1:%.*]] = sub i32 [[A:%.*]], [[B:%.*]]
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[T1]], 0
-; CHECK-NEXT: [[TMP1:%.*]] = sub i32 0, [[T1]]
-; CHECK-NEXT: [[ABS:%.*]] = select i1 [[CMP]], i32 [[T1]], i32 [[TMP1]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[T1]], i1 false)
+; CHECK-NEXT: [[ABS:%.*]] = sub i32 0, [[TMP1]]
; CHECK-NEXT: ret i32 [[ABS]]
;
%t2 = sub i32 %b, %a
define i8 @shifty_abs_commute0(i8 %x) {
; CHECK-LABEL: @shifty_abs_commute0(
-; CHECK-NEXT: [[TMP1:%.*]] = icmp slt i8 [[X:%.*]], 0
-; CHECK-NEXT: [[TMP2:%.*]] = sub i8 0, [[X]]
-; CHECK-NEXT: [[ABS:%.*]] = select i1 [[TMP1]], i8 [[TMP2]], i8 [[X]]
-; CHECK-NEXT: ret i8 [[ABS]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i8 @llvm.abs.i8(i8 [[X:%.*]], i1 false)
+; CHECK-NEXT: ret i8 [[TMP1]]
;
%signbit = ashr i8 %x, 7
%add = add i8 %signbit, %x
define i8 @shifty_abs_commute0_nsw(i8 %x) {
; CHECK-LABEL: @shifty_abs_commute0_nsw(
-; CHECK-NEXT: [[TMP1:%.*]] = icmp slt i8 [[X:%.*]], 0
-; CHECK-NEXT: [[TMP2:%.*]] = sub nsw i8 0, [[X]]
-; CHECK-NEXT: [[ABS:%.*]] = select i1 [[TMP1]], i8 [[TMP2]], i8 [[X]]
-; CHECK-NEXT: ret i8 [[ABS]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i8 @llvm.abs.i8(i8 [[X:%.*]], i1 true)
+; CHECK-NEXT: ret i8 [[TMP1]]
;
%signbit = ashr i8 %x, 7
%add = add nsw i8 %signbit, %x
define <2 x i8> @shifty_abs_commute1(<2 x i8> %x) {
; CHECK-LABEL: @shifty_abs_commute1(
-; CHECK-NEXT: [[TMP1:%.*]] = icmp slt <2 x i8> [[X:%.*]], zeroinitializer
-; CHECK-NEXT: [[TMP2:%.*]] = sub <2 x i8> zeroinitializer, [[X]]
-; CHECK-NEXT: [[ABS:%.*]] = select <2 x i1> [[TMP1]], <2 x i8> [[TMP2]], <2 x i8> [[X]]
-; CHECK-NEXT: ret <2 x i8> [[ABS]]
+; CHECK-NEXT: [[TMP1:%.*]] = call <2 x i8> @llvm.abs.v2i8(<2 x i8> [[X:%.*]], i1 false)
+; CHECK-NEXT: ret <2 x i8> [[TMP1]]
;
%signbit = ashr <2 x i8> %x, <i8 7, i8 7>
%add = add <2 x i8> %signbit, %x
define <2 x i8> @shifty_abs_commute2(<2 x i8> %x) {
; CHECK-LABEL: @shifty_abs_commute2(
; CHECK-NEXT: [[Y:%.*]] = mul <2 x i8> [[X:%.*]], <i8 3, i8 3>
-; CHECK-NEXT: [[TMP1:%.*]] = icmp slt <2 x i8> [[Y]], zeroinitializer
-; CHECK-NEXT: [[TMP2:%.*]] = sub <2 x i8> zeroinitializer, [[Y]]
-; CHECK-NEXT: [[ABS:%.*]] = select <2 x i1> [[TMP1]], <2 x i8> [[TMP2]], <2 x i8> [[Y]]
-; CHECK-NEXT: ret <2 x i8> [[ABS]]
+; CHECK-NEXT: [[TMP1:%.*]] = call <2 x i8> @llvm.abs.v2i8(<2 x i8> [[Y]], i1 false)
+; CHECK-NEXT: ret <2 x i8> [[TMP1]]
;
%y = mul <2 x i8> %x, <i8 3, i8 3> ; extra op to thwart complexity-based canonicalization
%signbit = ashr <2 x i8> %y, <i8 7, i8 7>
define i8 @shifty_abs_commute3(i8 %x) {
; CHECK-LABEL: @shifty_abs_commute3(
; CHECK-NEXT: [[Y:%.*]] = mul i8 [[X:%.*]], 3
-; CHECK-NEXT: [[TMP1:%.*]] = icmp slt i8 [[Y]], 0
-; CHECK-NEXT: [[TMP2:%.*]] = sub i8 0, [[Y]]
-; CHECK-NEXT: [[ABS:%.*]] = select i1 [[TMP1]], i8 [[TMP2]], i8 [[Y]]
-; CHECK-NEXT: ret i8 [[ABS]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i8 @llvm.abs.i8(i8 [[Y]], i1 false)
+; CHECK-NEXT: ret i8 [[TMP1]]
;
%y = mul i8 %x, 3 ; extra op to thwart complexity-based canonicalization
%signbit = ashr i8 %y, 7
define i8 @shifty_sub(i8 %x) {
; CHECK-LABEL: @shifty_sub(
-; CHECK-NEXT: [[TMP1:%.*]] = icmp slt i8 [[X:%.*]], 0
-; CHECK-NEXT: [[TMP2:%.*]] = sub i8 0, [[X]]
-; CHECK-NEXT: [[R:%.*]] = select i1 [[TMP1]], i8 [[TMP2]], i8 [[X]]
-; CHECK-NEXT: ret i8 [[R]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i8 @llvm.abs.i8(i8 [[X:%.*]], i1 false)
+; CHECK-NEXT: ret i8 [[TMP1]]
;
%sh = ashr i8 %x, 7
%xor = xor i8 %x, %sh
define i8 @shifty_sub_nsw_commute(i8 %x) {
; CHECK-LABEL: @shifty_sub_nsw_commute(
-; CHECK-NEXT: [[TMP1:%.*]] = icmp slt i8 [[X:%.*]], 0
-; CHECK-NEXT: [[TMP2:%.*]] = sub nsw i8 0, [[X]]
-; CHECK-NEXT: [[R:%.*]] = select i1 [[TMP1]], i8 [[TMP2]], i8 [[X]]
-; CHECK-NEXT: ret i8 [[R]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i8 @llvm.abs.i8(i8 [[X:%.*]], i1 true)
+; CHECK-NEXT: ret i8 [[TMP1]]
;
%sh = ashr i8 %x, 7
%xor = xor i8 %sh, %x
define i8 @negate_abs(i8 %x) {
; CHECK-LABEL: @negate_abs(
-; CHECK-NEXT: [[N:%.*]] = sub i8 0, [[X:%.*]]
-; CHECK-NEXT: [[C:%.*]] = icmp slt i8 [[X]], 0
-; CHECK-NEXT: [[TMP1:%.*]] = select i1 [[C]], i8 [[X]], i8 [[N]]
-; CHECK-NEXT: ret i8 [[TMP1]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i8 @llvm.abs.i8(i8 [[X:%.*]], i1 false)
+; CHECK-NEXT: [[R:%.*]] = sub i8 0, [[TMP1]]
+; CHECK-NEXT: ret i8 [[R]]
;
%n = sub i8 0, %x
%c = icmp slt i8 %x, 0
define <2 x i8> @negate_nabs(<2 x i8> %x) {
; CHECK-LABEL: @negate_nabs(
-; CHECK-NEXT: [[N:%.*]] = sub <2 x i8> zeroinitializer, [[X:%.*]]
-; CHECK-NEXT: [[C:%.*]] = icmp slt <2 x i8> [[X]], zeroinitializer
-; CHECK-NEXT: [[TMP1:%.*]] = select <2 x i1> [[C]], <2 x i8> [[N]], <2 x i8> [[X]]
+; CHECK-NEXT: [[TMP1:%.*]] = call <2 x i8> @llvm.abs.v2i8(<2 x i8> [[X:%.*]], i1 false)
; CHECK-NEXT: ret <2 x i8> [[TMP1]]
;
%n = sub <2 x i8> zeroinitializer, %x
; CHECK-LABEL: @abs_swapped(
; CHECK-NEXT: [[NEG:%.*]] = sub i8 0, [[A:%.*]]
; CHECK-NEXT: call void @extra_use(i8 [[NEG]])
-; CHECK-NEXT: [[CMP1:%.*]] = icmp slt i8 [[A]], 0
-; CHECK-NEXT: [[M1:%.*]] = select i1 [[CMP1]], i8 [[NEG]], i8 [[A]]
-; CHECK-NEXT: ret i8 [[M1]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i8 @llvm.abs.i8(i8 [[A]], i1 false)
+; CHECK-NEXT: ret i8 [[TMP1]]
;
%neg = sub i8 0, %a
call void @extra_use(i8 %neg)
; CHECK-LABEL: @nabs_swapped(
; CHECK-NEXT: [[NEG:%.*]] = sub i8 0, [[A:%.*]]
; CHECK-NEXT: call void @extra_use(i8 [[NEG]])
-; CHECK-NEXT: [[CMP2:%.*]] = icmp slt i8 [[A]], 0
-; CHECK-NEXT: [[M2:%.*]] = select i1 [[CMP2]], i8 [[A]], i8 [[NEG]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i8 @llvm.abs.i8(i8 [[A]], i1 false)
+; CHECK-NEXT: [[M2:%.*]] = sub i8 0, [[TMP1]]
; CHECK-NEXT: ret i8 [[M2]]
;
%neg = sub i8 0, %a
; CHECK-LABEL: @abs_different_constants(
; CHECK-NEXT: [[NEG:%.*]] = sub i8 0, [[A:%.*]]
; CHECK-NEXT: call void @extra_use(i8 [[NEG]])
-; CHECK-NEXT: [[CMP1:%.*]] = icmp slt i8 [[A]], 0
-; CHECK-NEXT: [[M1:%.*]] = select i1 [[CMP1]], i8 [[NEG]], i8 [[A]]
-; CHECK-NEXT: ret i8 [[M1]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i8 @llvm.abs.i8(i8 [[A]], i1 false)
+; CHECK-NEXT: ret i8 [[TMP1]]
;
%neg = sub i8 0, %a
call void @extra_use(i8 %neg)
; CHECK-LABEL: @nabs_different_constants(
; CHECK-NEXT: [[NEG:%.*]] = sub i8 0, [[A:%.*]]
; CHECK-NEXT: call void @extra_use(i8 [[NEG]])
-; CHECK-NEXT: [[CMP2:%.*]] = icmp slt i8 [[A]], 0
-; CHECK-NEXT: [[M2:%.*]] = select i1 [[CMP2]], i8 [[A]], i8 [[NEG]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i8 @llvm.abs.i8(i8 [[A]], i1 false)
+; CHECK-NEXT: [[M2:%.*]] = sub i8 0, [[TMP1]]
; CHECK-NEXT: ret i8 [[M2]]
;
%neg = sub i8 0, %a
define i64 @infinite_loop_constant_expression_abs(i64 %arg) {
; CHECK-LABEL: @infinite_loop_constant_expression_abs(
; CHECK-NEXT: [[T:%.*]] = sub i64 ptrtoint (i64* @g to i64), [[ARG:%.*]]
-; CHECK-NEXT: [[T1:%.*]] = icmp slt i64 [[T]], 0
-; CHECK-NEXT: [[T2:%.*]] = sub nsw i64 0, [[T]]
-; CHECK-NEXT: [[T3:%.*]] = select i1 [[T1]], i64 [[T2]], i64 [[T]]
-; CHECK-NEXT: ret i64 [[T3]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i64 @llvm.abs.i64(i64 [[T]], i1 true)
+; CHECK-NEXT: ret i64 [[TMP1]]
;
%t = sub i64 ptrtoint (i64* @g to i64), %arg
%t1 = icmp slt i64 %t, 0
define i8 @abs_extra_use_sub(i8 %x) {
; CHECK-LABEL: @abs_extra_use_sub(
-; CHECK-NEXT: [[C:%.*]] = icmp slt i8 [[X:%.*]], 0
-; CHECK-NEXT: [[N:%.*]] = sub i8 0, [[X]]
+; CHECK-NEXT: [[N:%.*]] = sub i8 0, [[X:%.*]]
; CHECK-NEXT: call void @extra_use(i8 [[N]])
-; CHECK-NEXT: [[S:%.*]] = select i1 [[C]], i8 [[N]], i8 [[X]]
-; CHECK-NEXT: ret i8 [[S]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i8 @llvm.abs.i8(i8 [[X]], i1 false)
+; CHECK-NEXT: ret i8 [[TMP1]]
;
%c = icmp slt i8 %x, 0
%n = sub i8 0, %x
define i8 @nabs_extra_use_sub(i8 %x) {
; CHECK-LABEL: @nabs_extra_use_sub(
-; CHECK-NEXT: [[C:%.*]] = icmp slt i8 [[X:%.*]], 0
-; CHECK-NEXT: [[N:%.*]] = sub i8 0, [[X]]
+; CHECK-NEXT: [[N:%.*]] = sub i8 0, [[X:%.*]]
; CHECK-NEXT: call void @extra_use(i8 [[N]])
-; CHECK-NEXT: [[S:%.*]] = select i1 [[C]], i8 [[X]], i8 [[N]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i8 @llvm.abs.i8(i8 [[X]], i1 false)
+; CHECK-NEXT: [[S:%.*]] = sub i8 0, [[TMP1]]
; CHECK-NEXT: ret i8 [[S]]
;
%c = icmp slt i8 %x, 0
define i32 @abs_abs_x01(i32 %x) {
; CHECK-LABEL: @abs_abs_x01(
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
-; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
-; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
-; CHECK-NEXT: ret i32 [[COND]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 true)
+; CHECK-NEXT: ret i32 [[TMP1]]
;
%cmp = icmp sgt i32 %x, -1
%sub = sub nsw i32 0, %x
define <2 x i32> @abs_abs_x01_vec(<2 x i32> %x) {
; CHECK-LABEL: @abs_abs_x01_vec(
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt <2 x i32> [[X:%.*]], zeroinitializer
-; CHECK-NEXT: [[SUB:%.*]] = sub nsw <2 x i32> zeroinitializer, [[X]]
-; CHECK-NEXT: [[COND:%.*]] = select <2 x i1> [[CMP]], <2 x i32> [[SUB]], <2 x i32> [[X]]
-; CHECK-NEXT: ret <2 x i32> [[COND]]
+; CHECK-NEXT: [[TMP1:%.*]] = call <2 x i32> @llvm.abs.v2i32(<2 x i32> [[X:%.*]], i1 true)
+; CHECK-NEXT: ret <2 x i32> [[TMP1]]
;
%cmp = icmp sgt <2 x i32> %x, <i32 -1, i32 -1>
%sub = sub nsw <2 x i32> zeroinitializer, %x
define i32 @abs_abs_x02(i32 %x) {
; CHECK-LABEL: @abs_abs_x02(
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
-; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
-; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
-; CHECK-NEXT: ret i32 [[COND]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 true)
+; CHECK-NEXT: ret i32 [[TMP1]]
;
%cmp = icmp sgt i32 %x, 0
%sub = sub nsw i32 0, %x
define i32 @abs_abs_x03(i32 %x) {
; CHECK-LABEL: @abs_abs_x03(
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
-; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
-; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
-; CHECK-NEXT: ret i32 [[COND]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 true)
+; CHECK-NEXT: ret i32 [[TMP1]]
;
%cmp = icmp slt i32 %x, 0
%sub = sub nsw i32 0, %x
define i32 @abs_abs_x04(i32 %x) {
; CHECK-LABEL: @abs_abs_x04(
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
-; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
-; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
-; CHECK-NEXT: ret i32 [[COND]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 true)
+; CHECK-NEXT: ret i32 [[TMP1]]
;
%cmp = icmp slt i32 %x, 1
%sub = sub nsw i32 0, %x
define <2 x i32> @abs_abs_x04_vec(<2 x i32> %x) {
; CHECK-LABEL: @abs_abs_x04_vec(
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt <2 x i32> [[X:%.*]], zeroinitializer
-; CHECK-NEXT: [[SUB:%.*]] = sub nsw <2 x i32> zeroinitializer, [[X]]
-; CHECK-NEXT: [[COND:%.*]] = select <2 x i1> [[CMP]], <2 x i32> [[SUB]], <2 x i32> [[X]]
-; CHECK-NEXT: ret <2 x i32> [[COND]]
+; CHECK-NEXT: [[TMP1:%.*]] = call <2 x i32> @llvm.abs.v2i32(<2 x i32> [[X:%.*]], i1 true)
+; CHECK-NEXT: ret <2 x i32> [[TMP1]]
;
%cmp = icmp slt <2 x i32> %x, <i32 1, i32 1>
%sub = sub nsw <2 x i32> zeroinitializer, %x
define i32 @abs_abs_x05(i32 %x) {
; CHECK-LABEL: @abs_abs_x05(
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
-; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
-; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
-; CHECK-NEXT: ret i32 [[COND]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 true)
+; CHECK-NEXT: ret i32 [[TMP1]]
;
%cmp = icmp sgt i32 %x, -1
%sub = sub nsw i32 0, %x
define i32 @abs_abs_x06(i32 %x) {
; CHECK-LABEL: @abs_abs_x06(
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
-; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
-; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
-; CHECK-NEXT: ret i32 [[COND]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 true)
+; CHECK-NEXT: ret i32 [[TMP1]]
;
%cmp = icmp sgt i32 %x, 0
%sub = sub nsw i32 0, %x
define i32 @abs_abs_x07(i32 %x) {
; CHECK-LABEL: @abs_abs_x07(
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
-; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
-; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
-; CHECK-NEXT: ret i32 [[COND]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 true)
+; CHECK-NEXT: ret i32 [[TMP1]]
;
%cmp = icmp slt i32 %x, 0
%sub = sub nsw i32 0, %x
define i32 @abs_abs_x08(i32 %x) {
; CHECK-LABEL: @abs_abs_x08(
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
-; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
-; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
-; CHECK-NEXT: ret i32 [[COND]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 true)
+; CHECK-NEXT: ret i32 [[TMP1]]
;
%cmp = icmp slt i32 %x, 1
%sub = sub nsw i32 0, %x
define i32 @abs_abs_x09(i32 %x) {
; CHECK-LABEL: @abs_abs_x09(
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
-; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
-; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
-; CHECK-NEXT: ret i32 [[COND]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 true)
+; CHECK-NEXT: ret i32 [[TMP1]]
;
%cmp = icmp sgt i32 %x, -1
%sub = sub nsw i32 0, %x
define i32 @abs_abs_x10(i32 %x) {
; CHECK-LABEL: @abs_abs_x10(
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
-; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
-; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
-; CHECK-NEXT: ret i32 [[COND]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 true)
+; CHECK-NEXT: ret i32 [[TMP1]]
;
%cmp = icmp sgt i32 %x, 0
%sub = sub nsw i32 0, %x
define i32 @abs_abs_x11(i32 %x) {
; CHECK-LABEL: @abs_abs_x11(
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
-; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
-; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
-; CHECK-NEXT: ret i32 [[COND]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 true)
+; CHECK-NEXT: ret i32 [[TMP1]]
;
%cmp = icmp slt i32 %x, 0
%sub = sub nsw i32 0, %x
define i32 @abs_abs_x12(i32 %x) {
; CHECK-LABEL: @abs_abs_x12(
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
-; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
-; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
-; CHECK-NEXT: ret i32 [[COND]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 true)
+; CHECK-NEXT: ret i32 [[TMP1]]
;
%cmp = icmp slt i32 %x, 1
%sub = sub nsw i32 0, %x
define i32 @abs_abs_x13(i32 %x) {
; CHECK-LABEL: @abs_abs_x13(
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
-; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
-; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
-; CHECK-NEXT: ret i32 [[COND]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 true)
+; CHECK-NEXT: ret i32 [[TMP1]]
;
%cmp = icmp sgt i32 %x, -1
%sub = sub nsw i32 0, %x
define i32 @abs_abs_x14(i32 %x) {
; CHECK-LABEL: @abs_abs_x14(
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
-; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
-; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
-; CHECK-NEXT: ret i32 [[COND]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 true)
+; CHECK-NEXT: ret i32 [[TMP1]]
;
%cmp = icmp sgt i32 %x, 0
%sub = sub nsw i32 0, %x
define i32 @abs_abs_x15(i32 %x) {
; CHECK-LABEL: @abs_abs_x15(
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
-; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
-; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
-; CHECK-NEXT: ret i32 [[COND]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 true)
+; CHECK-NEXT: ret i32 [[TMP1]]
;
%cmp = icmp slt i32 %x, 0
%sub = sub nsw i32 0, %x
define i32 @abs_abs_x16(i32 %x) {
; CHECK-LABEL: @abs_abs_x16(
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
-; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
-; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
-; CHECK-NEXT: ret i32 [[COND]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 true)
+; CHECK-NEXT: ret i32 [[TMP1]]
;
%cmp = icmp slt i32 %x, 1
%sub = sub nsw i32 0, %x
; abs(abs(-x)) -> abs(-x) -> abs(x)
define i32 @abs_abs_x17(i32 %x) {
; CHECK-LABEL: @abs_abs_x17(
-; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X:%.*]]
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X]], 0
-; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
-; CHECK-NEXT: ret i32 [[COND]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 true)
+; CHECK-NEXT: ret i32 [[TMP1]]
;
%sub = sub nsw i32 0, %x
%cmp = icmp sgt i32 %sub, -1
define i32 @abs_abs_x18(i32 %x, i32 %y) {
; CHECK-LABEL: @abs_abs_x18(
; CHECK-NEXT: [[A:%.*]] = sub nsw i32 [[X:%.*]], [[Y:%.*]]
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[A]], 0
-; CHECK-NEXT: [[NEGA:%.*]] = sub i32 0, [[A]]
-; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[NEGA]], i32 [[A]]
-; CHECK-NEXT: ret i32 [[COND]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[A]], i1 false)
+; CHECK-NEXT: ret i32 [[TMP1]]
;
%a = sub nsw i32 %x, %y
%b = sub nsw i32 %y, %x
; abs(abs(-x)) -> abs(-x) -> abs(x)
define <2 x i32> @abs_abs_x02_vec(<2 x i32> %x) {
; CHECK-LABEL: @abs_abs_x02_vec(
-; CHECK-NEXT: [[SUB:%.*]] = sub nsw <2 x i32> zeroinitializer, [[X:%.*]]
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt <2 x i32> [[X]], zeroinitializer
-; CHECK-NEXT: [[COND:%.*]] = select <2 x i1> [[CMP]], <2 x i32> [[SUB]], <2 x i32> [[X]]
-; CHECK-NEXT: ret <2 x i32> [[COND]]
+; CHECK-NEXT: [[TMP1:%.*]] = call <2 x i32> @llvm.abs.v2i32(<2 x i32> [[X:%.*]], i1 true)
+; CHECK-NEXT: ret <2 x i32> [[TMP1]]
;
%sub = sub nsw <2 x i32> zeroinitializer, %x
%cmp = icmp sgt <2 x i32> %sub, <i32 -1, i32 -1>
define <2 x i32> @abs_abs_x03_vec(<2 x i32> %x, <2 x i32> %y) {
; CHECK-LABEL: @abs_abs_x03_vec(
; CHECK-NEXT: [[A:%.*]] = sub nsw <2 x i32> [[X:%.*]], [[Y:%.*]]
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt <2 x i32> [[A]], zeroinitializer
-; CHECK-NEXT: [[NEGA:%.*]] = sub <2 x i32> zeroinitializer, [[A]]
-; CHECK-NEXT: [[COND:%.*]] = select <2 x i1> [[CMP]], <2 x i32> [[NEGA]], <2 x i32> [[A]]
-; CHECK-NEXT: ret <2 x i32> [[COND]]
+; CHECK-NEXT: [[TMP1:%.*]] = call <2 x i32> @llvm.abs.v2i32(<2 x i32> [[A]], i1 false)
+; CHECK-NEXT: ret <2 x i32> [[TMP1]]
;
%a = sub nsw <2 x i32> %x, %y
%b = sub nsw <2 x i32> %y, %x
define i32 @nabs_nabs_x01(i32 %x) {
; CHECK-LABEL: @nabs_nabs_x01(
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
-; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
-; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 true)
+; CHECK-NEXT: [[COND:%.*]] = sub nsw i32 0, [[TMP1]]
; CHECK-NEXT: ret i32 [[COND]]
;
%cmp = icmp sgt i32 %x, -1
define i32 @nabs_nabs_x02(i32 %x) {
; CHECK-LABEL: @nabs_nabs_x02(
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
-; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
-; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 true)
+; CHECK-NEXT: [[COND:%.*]] = sub nsw i32 0, [[TMP1]]
; CHECK-NEXT: ret i32 [[COND]]
;
%cmp = icmp sgt i32 %x, 0
define i32 @nabs_nabs_x03(i32 %x) {
; CHECK-LABEL: @nabs_nabs_x03(
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
-; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
-; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 true)
+; CHECK-NEXT: [[COND:%.*]] = sub nsw i32 0, [[TMP1]]
; CHECK-NEXT: ret i32 [[COND]]
;
%cmp = icmp slt i32 %x, 0
define i32 @nabs_nabs_x04(i32 %x) {
; CHECK-LABEL: @nabs_nabs_x04(
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
-; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
-; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 true)
+; CHECK-NEXT: [[COND:%.*]] = sub nsw i32 0, [[TMP1]]
; CHECK-NEXT: ret i32 [[COND]]
;
%cmp = icmp slt i32 %x, 1
define i32 @nabs_nabs_x05(i32 %x) {
; CHECK-LABEL: @nabs_nabs_x05(
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
-; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
-; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 true)
+; CHECK-NEXT: [[COND:%.*]] = sub nsw i32 0, [[TMP1]]
; CHECK-NEXT: ret i32 [[COND]]
;
%cmp = icmp sgt i32 %x, -1
define i32 @nabs_nabs_x06(i32 %x) {
; CHECK-LABEL: @nabs_nabs_x06(
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
-; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
-; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 true)
+; CHECK-NEXT: [[COND:%.*]] = sub nsw i32 0, [[TMP1]]
; CHECK-NEXT: ret i32 [[COND]]
;
%cmp = icmp sgt i32 %x, 0
define i32 @nabs_nabs_x07(i32 %x) {
; CHECK-LABEL: @nabs_nabs_x07(
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
-; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
-; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 true)
+; CHECK-NEXT: [[COND:%.*]] = sub nsw i32 0, [[TMP1]]
; CHECK-NEXT: ret i32 [[COND]]
;
%cmp = icmp slt i32 %x, 0
define i32 @nabs_nabs_x08(i32 %x) {
; CHECK-LABEL: @nabs_nabs_x08(
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
-; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
-; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 true)
+; CHECK-NEXT: [[COND:%.*]] = sub nsw i32 0, [[TMP1]]
; CHECK-NEXT: ret i32 [[COND]]
;
%cmp = icmp slt i32 %x, 1
define i32 @nabs_nabs_x09(i32 %x) {
; CHECK-LABEL: @nabs_nabs_x09(
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
-; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
-; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 true)
+; CHECK-NEXT: [[COND:%.*]] = sub nsw i32 0, [[TMP1]]
; CHECK-NEXT: ret i32 [[COND]]
;
%cmp = icmp sgt i32 %x, -1
define i32 @nabs_nabs_x10(i32 %x) {
; CHECK-LABEL: @nabs_nabs_x10(
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
-; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
-; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 true)
+; CHECK-NEXT: [[COND:%.*]] = sub nsw i32 0, [[TMP1]]
; CHECK-NEXT: ret i32 [[COND]]
;
%cmp = icmp sgt i32 %x, 0
define i32 @nabs_nabs_x11(i32 %x) {
; CHECK-LABEL: @nabs_nabs_x11(
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
-; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
-; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 true)
+; CHECK-NEXT: [[COND:%.*]] = sub nsw i32 0, [[TMP1]]
; CHECK-NEXT: ret i32 [[COND]]
;
%cmp = icmp slt i32 %x, 0
define i32 @nabs_nabs_x12(i32 %x) {
; CHECK-LABEL: @nabs_nabs_x12(
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
-; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
-; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 true)
+; CHECK-NEXT: [[COND:%.*]] = sub nsw i32 0, [[TMP1]]
; CHECK-NEXT: ret i32 [[COND]]
;
%cmp = icmp slt i32 %x, 1
define i32 @nabs_nabs_x13(i32 %x) {
; CHECK-LABEL: @nabs_nabs_x13(
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
-; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
-; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 true)
+; CHECK-NEXT: [[COND:%.*]] = sub nsw i32 0, [[TMP1]]
; CHECK-NEXT: ret i32 [[COND]]
;
%cmp = icmp sgt i32 %x, -1
define i32 @nabs_nabs_x14(i32 %x) {
; CHECK-LABEL: @nabs_nabs_x14(
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
-; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
-; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 true)
+; CHECK-NEXT: [[COND:%.*]] = sub nsw i32 0, [[TMP1]]
; CHECK-NEXT: ret i32 [[COND]]
;
%cmp = icmp sgt i32 %x, 0
define i32 @nabs_nabs_x15(i32 %x) {
; CHECK-LABEL: @nabs_nabs_x15(
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
-; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
-; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 true)
+; CHECK-NEXT: [[COND:%.*]] = sub nsw i32 0, [[TMP1]]
; CHECK-NEXT: ret i32 [[COND]]
;
%cmp = icmp slt i32 %x, 0
define i32 @nabs_nabs_x16(i32 %x) {
; CHECK-LABEL: @nabs_nabs_x16(
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
-; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
-; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 true)
+; CHECK-NEXT: [[COND:%.*]] = sub nsw i32 0, [[TMP1]]
; CHECK-NEXT: ret i32 [[COND]]
;
%cmp = icmp slt i32 %x, 1
; nabs(nabs(-x)) -> nabs(-x) -> nabs(x)
define i32 @nabs_nabs_x17(i32 %x) {
; CHECK-LABEL: @nabs_nabs_x17(
-; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X:%.*]]
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X]], 0
-; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 true)
+; CHECK-NEXT: [[COND:%.*]] = sub nsw i32 0, [[TMP1]]
; CHECK-NEXT: ret i32 [[COND]]
;
%sub = sub nsw i32 0, %x
define i32 @nabs_nabs_x18(i32 %x, i32 %y) {
; CHECK-LABEL: @nabs_nabs_x18(
; CHECK-NEXT: [[A:%.*]] = sub nsw i32 [[X:%.*]], [[Y:%.*]]
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[A]], 0
-; CHECK-NEXT: [[NEGA:%.*]] = sub i32 0, [[A]]
-; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[A]], i32 [[NEGA]]
-; CHECK-NEXT: ret i32 [[COND]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[A]], i1 false)
+; CHECK-NEXT: [[COND18:%.*]] = sub i32 0, [[TMP1]]
+; CHECK-NEXT: ret i32 [[COND18]]
;
%a = sub nsw i32 %x, %y
%b = sub nsw i32 %y, %x
; nabs(nabs(-x)) -> nabs(-x) -> nabs(x)
define <2 x i32> @nabs_nabs_x01_vec(<2 x i32> %x) {
; CHECK-LABEL: @nabs_nabs_x01_vec(
-; CHECK-NEXT: [[SUB:%.*]] = sub nsw <2 x i32> zeroinitializer, [[X:%.*]]
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt <2 x i32> [[X]], zeroinitializer
-; CHECK-NEXT: [[COND:%.*]] = select <2 x i1> [[CMP]], <2 x i32> [[X]], <2 x i32> [[SUB]]
+; CHECK-NEXT: [[TMP1:%.*]] = call <2 x i32> @llvm.abs.v2i32(<2 x i32> [[X:%.*]], i1 true)
+; CHECK-NEXT: [[COND:%.*]] = sub nsw <2 x i32> zeroinitializer, [[TMP1]]
; CHECK-NEXT: ret <2 x i32> [[COND]]
;
%sub = sub nsw <2 x i32> zeroinitializer, %x
define <2 x i32> @nabs_nabs_x02_vec(<2 x i32> %x, <2 x i32> %y) {
; CHECK-LABEL: @nabs_nabs_x02_vec(
; CHECK-NEXT: [[A:%.*]] = sub nsw <2 x i32> [[X:%.*]], [[Y:%.*]]
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt <2 x i32> [[A]], zeroinitializer
-; CHECK-NEXT: [[NEGA:%.*]] = sub <2 x i32> zeroinitializer, [[A]]
-; CHECK-NEXT: [[COND:%.*]] = select <2 x i1> [[CMP]], <2 x i32> [[A]], <2 x i32> [[NEGA]]
-; CHECK-NEXT: ret <2 x i32> [[COND]]
+; CHECK-NEXT: [[TMP1:%.*]] = call <2 x i32> @llvm.abs.v2i32(<2 x i32> [[A]], i1 false)
+; CHECK-NEXT: [[COND18:%.*]] = sub <2 x i32> zeroinitializer, [[TMP1]]
+; CHECK-NEXT: ret <2 x i32> [[COND18]]
;
%a = sub nsw <2 x i32> %x, %y
%b = sub nsw <2 x i32> %y, %x
define i32 @abs_nabs_x01(i32 %x) {
; CHECK-LABEL: @abs_nabs_x01(
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
-; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
-; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
-; CHECK-NEXT: ret i32 [[COND1]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 true)
+; CHECK-NEXT: ret i32 [[TMP1]]
;
%cmp = icmp sgt i32 %x, -1
%sub = sub nsw i32 0, %x
define i32 @abs_nabs_x02(i32 %x) {
; CHECK-LABEL: @abs_nabs_x02(
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
-; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
-; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
-; CHECK-NEXT: ret i32 [[COND1]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 true)
+; CHECK-NEXT: ret i32 [[TMP1]]
;
%cmp = icmp sgt i32 %x, 0
%sub = sub nsw i32 0, %x
define i32 @abs_nabs_x03(i32 %x) {
; CHECK-LABEL: @abs_nabs_x03(
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
-; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
-; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
-; CHECK-NEXT: ret i32 [[COND1]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 true)
+; CHECK-NEXT: ret i32 [[TMP1]]
;
%cmp = icmp slt i32 %x, 0
%sub = sub nsw i32 0, %x
define i32 @abs_nabs_x04(i32 %x) {
; CHECK-LABEL: @abs_nabs_x04(
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
-; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
-; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
-; CHECK-NEXT: ret i32 [[COND1]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 true)
+; CHECK-NEXT: ret i32 [[TMP1]]
;
%cmp = icmp slt i32 %x, 1
%sub = sub nsw i32 0, %x
define i32 @abs_nabs_x05(i32 %x) {
; CHECK-LABEL: @abs_nabs_x05(
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
-; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
-; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
-; CHECK-NEXT: ret i32 [[COND1]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 true)
+; CHECK-NEXT: ret i32 [[TMP1]]
;
%cmp = icmp sgt i32 %x, -1
%sub = sub nsw i32 0, %x
define i32 @abs_nabs_x06(i32 %x) {
; CHECK-LABEL: @abs_nabs_x06(
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
-; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
-; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
-; CHECK-NEXT: ret i32 [[COND1]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 true)
+; CHECK-NEXT: ret i32 [[TMP1]]
;
%cmp = icmp sgt i32 %x, 0
%sub = sub nsw i32 0, %x
define i32 @abs_nabs_x07(i32 %x) {
; CHECK-LABEL: @abs_nabs_x07(
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
-; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
-; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
-; CHECK-NEXT: ret i32 [[COND1]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 true)
+; CHECK-NEXT: ret i32 [[TMP1]]
;
%cmp = icmp slt i32 %x, 0
%sub = sub nsw i32 0, %x
define i32 @abs_nabs_x08(i32 %x) {
; CHECK-LABEL: @abs_nabs_x08(
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
-; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
-; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
-; CHECK-NEXT: ret i32 [[COND1]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 true)
+; CHECK-NEXT: ret i32 [[TMP1]]
;
%cmp = icmp slt i32 %x, 1
%sub = sub nsw i32 0, %x
define i32 @abs_nabs_x09(i32 %x) {
; CHECK-LABEL: @abs_nabs_x09(
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
-; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
-; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
-; CHECK-NEXT: ret i32 [[COND1]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 true)
+; CHECK-NEXT: ret i32 [[TMP1]]
;
%cmp = icmp sgt i32 %x, -1
%sub = sub nsw i32 0, %x
define i32 @abs_nabs_x10(i32 %x) {
; CHECK-LABEL: @abs_nabs_x10(
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
-; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
-; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
-; CHECK-NEXT: ret i32 [[COND1]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 true)
+; CHECK-NEXT: ret i32 [[TMP1]]
;
%cmp = icmp sgt i32 %x, 0
%sub = sub nsw i32 0, %x
define i32 @abs_nabs_x11(i32 %x) {
; CHECK-LABEL: @abs_nabs_x11(
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
-; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
-; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
-; CHECK-NEXT: ret i32 [[COND1]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 true)
+; CHECK-NEXT: ret i32 [[TMP1]]
;
%cmp = icmp slt i32 %x, 0
%sub = sub nsw i32 0, %x
define i32 @abs_nabs_x12(i32 %x) {
; CHECK-LABEL: @abs_nabs_x12(
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
-; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
-; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
-; CHECK-NEXT: ret i32 [[COND1]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 true)
+; CHECK-NEXT: ret i32 [[TMP1]]
;
%cmp = icmp slt i32 %x, 1
%sub = sub nsw i32 0, %x
define i32 @abs_nabs_x13(i32 %x) {
; CHECK-LABEL: @abs_nabs_x13(
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
-; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
-; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
-; CHECK-NEXT: ret i32 [[COND1]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 true)
+; CHECK-NEXT: ret i32 [[TMP1]]
;
%cmp = icmp sgt i32 %x, -1
%sub = sub nsw i32 0, %x
define i32 @abs_nabs_x14(i32 %x) {
; CHECK-LABEL: @abs_nabs_x14(
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
-; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
-; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
-; CHECK-NEXT: ret i32 [[COND1]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 true)
+; CHECK-NEXT: ret i32 [[TMP1]]
;
%cmp = icmp sgt i32 %x, 0
%sub = sub nsw i32 0, %x
define i32 @abs_nabs_x15(i32 %x) {
; CHECK-LABEL: @abs_nabs_x15(
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
-; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
-; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
-; CHECK-NEXT: ret i32 [[COND1]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 true)
+; CHECK-NEXT: ret i32 [[TMP1]]
;
%cmp = icmp slt i32 %x, 0
%sub = sub nsw i32 0, %x
define i32 @abs_nabs_x16(i32 %x) {
; CHECK-LABEL: @abs_nabs_x16(
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
-; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
-; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
-; CHECK-NEXT: ret i32 [[COND1]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 true)
+; CHECK-NEXT: ret i32 [[TMP1]]
;
%cmp = icmp slt i32 %x, 1
%sub = sub nsw i32 0, %x
; abs(nabs(-x)) -> abs(-x) -> abs(x)
define i32 @abs_nabs_x17(i32 %x) {
; CHECK-LABEL: @abs_nabs_x17(
-; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X:%.*]]
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X]], 0
-; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
-; CHECK-NEXT: ret i32 [[COND]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 true)
+; CHECK-NEXT: ret i32 [[TMP1]]
;
%sub = sub nsw i32 0, %x
%cmp = icmp sgt i32 %sub, -1
define i32 @abs_nabs_x18(i32 %x, i32 %y) {
; CHECK-LABEL: @abs_nabs_x18(
; CHECK-NEXT: [[A:%.*]] = sub nsw i32 [[X:%.*]], [[Y:%.*]]
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[A]], 0
-; CHECK-NEXT: [[NEGA:%.*]] = sub i32 0, [[A]]
-; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[NEGA]], i32 [[A]]
-; CHECK-NEXT: ret i32 [[COND]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[A]], i1 false)
+; CHECK-NEXT: ret i32 [[TMP1]]
;
%a = sub nsw i32 %x, %y
%b = sub nsw i32 %y, %x
; abs(nabs(-x)) -> abs(-x) -> abs(x)
define <2 x i32> @abs_nabs_x01_vec(<2 x i32> %x) {
; CHECK-LABEL: @abs_nabs_x01_vec(
-; CHECK-NEXT: [[SUB:%.*]] = sub nsw <2 x i32> zeroinitializer, [[X:%.*]]
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt <2 x i32> [[X]], zeroinitializer
-; CHECK-NEXT: [[COND:%.*]] = select <2 x i1> [[CMP]], <2 x i32> [[SUB]], <2 x i32> [[X]]
-; CHECK-NEXT: ret <2 x i32> [[COND]]
+; CHECK-NEXT: [[TMP1:%.*]] = call <2 x i32> @llvm.abs.v2i32(<2 x i32> [[X:%.*]], i1 true)
+; CHECK-NEXT: ret <2 x i32> [[TMP1]]
;
%sub = sub nsw <2 x i32> zeroinitializer, %x
%cmp = icmp sgt <2 x i32> %sub, <i32 -1, i32 -1>
define <2 x i32> @abs_nabs_x02_vec(<2 x i32> %x, <2 x i32> %y) {
; CHECK-LABEL: @abs_nabs_x02_vec(
; CHECK-NEXT: [[A:%.*]] = sub nsw <2 x i32> [[X:%.*]], [[Y:%.*]]
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt <2 x i32> [[A]], zeroinitializer
-; CHECK-NEXT: [[NEGA:%.*]] = sub <2 x i32> zeroinitializer, [[A]]
-; CHECK-NEXT: [[COND:%.*]] = select <2 x i1> [[CMP]], <2 x i32> [[NEGA]], <2 x i32> [[A]]
-; CHECK-NEXT: ret <2 x i32> [[COND]]
+; CHECK-NEXT: [[TMP1:%.*]] = call <2 x i32> @llvm.abs.v2i32(<2 x i32> [[A]], i1 false)
+; CHECK-NEXT: ret <2 x i32> [[TMP1]]
;
%a = sub nsw <2 x i32> %x, %y
%b = sub nsw <2 x i32> %y, %x
define i32 @nabs_abs_x01(i32 %x) {
; CHECK-LABEL: @nabs_abs_x01(
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
-; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
-; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
-; CHECK-NEXT: ret i32 [[COND1]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 true)
+; CHECK-NEXT: [[SUB9:%.*]] = sub nsw i32 0, [[TMP1]]
+; CHECK-NEXT: ret i32 [[SUB9]]
;
%cmp = icmp sgt i32 %x, -1
%sub = sub nsw i32 0, %x
define i32 @nabs_abs_x02(i32 %x) {
; CHECK-LABEL: @nabs_abs_x02(
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
-; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
-; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
-; CHECK-NEXT: ret i32 [[COND1]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 true)
+; CHECK-NEXT: [[SUB9:%.*]] = sub nsw i32 0, [[TMP1]]
+; CHECK-NEXT: ret i32 [[SUB9]]
;
%cmp = icmp sgt i32 %x, 0
%sub = sub nsw i32 0, %x
define i32 @nabs_abs_x03(i32 %x) {
; CHECK-LABEL: @nabs_abs_x03(
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
-; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
-; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
-; CHECK-NEXT: ret i32 [[COND1]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 true)
+; CHECK-NEXT: [[SUB9:%.*]] = sub nsw i32 0, [[TMP1]]
+; CHECK-NEXT: ret i32 [[SUB9]]
;
%cmp = icmp slt i32 %x, 0
%sub = sub nsw i32 0, %x
define i32 @nabs_abs_x04(i32 %x) {
; CHECK-LABEL: @nabs_abs_x04(
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
-; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
-; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
-; CHECK-NEXT: ret i32 [[COND1]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 true)
+; CHECK-NEXT: [[SUB9:%.*]] = sub nsw i32 0, [[TMP1]]
+; CHECK-NEXT: ret i32 [[SUB9]]
;
%cmp = icmp slt i32 %x, 1
%sub = sub nsw i32 0, %x
define i32 @nabs_abs_x05(i32 %x) {
; CHECK-LABEL: @nabs_abs_x05(
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
-; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
-; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
-; CHECK-NEXT: ret i32 [[COND1]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 true)
+; CHECK-NEXT: [[SUB9:%.*]] = sub nsw i32 0, [[TMP1]]
+; CHECK-NEXT: ret i32 [[SUB9]]
;
%cmp = icmp sgt i32 %x, -1
%sub = sub nsw i32 0, %x
define i32 @nabs_abs_x06(i32 %x) {
; CHECK-LABEL: @nabs_abs_x06(
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
-; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
-; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
-; CHECK-NEXT: ret i32 [[COND1]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 true)
+; CHECK-NEXT: [[SUB9:%.*]] = sub nsw i32 0, [[TMP1]]
+; CHECK-NEXT: ret i32 [[SUB9]]
;
%cmp = icmp sgt i32 %x, 0
%sub = sub nsw i32 0, %x
define i32 @nabs_abs_x07(i32 %x) {
; CHECK-LABEL: @nabs_abs_x07(
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
-; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
-; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
-; CHECK-NEXT: ret i32 [[COND1]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 true)
+; CHECK-NEXT: [[SUB9:%.*]] = sub nsw i32 0, [[TMP1]]
+; CHECK-NEXT: ret i32 [[SUB9]]
;
%cmp = icmp slt i32 %x, 0
%sub = sub nsw i32 0, %x
define i32 @nabs_abs_x08(i32 %x) {
; CHECK-LABEL: @nabs_abs_x08(
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
-; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
-; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
-; CHECK-NEXT: ret i32 [[COND1]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 true)
+; CHECK-NEXT: [[SUB9:%.*]] = sub nsw i32 0, [[TMP1]]
+; CHECK-NEXT: ret i32 [[SUB9]]
;
%cmp = icmp slt i32 %x, 1
%sub = sub nsw i32 0, %x
define i32 @nabs_abs_x09(i32 %x) {
; CHECK-LABEL: @nabs_abs_x09(
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
-; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
-; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
-; CHECK-NEXT: ret i32 [[COND]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 true)
+; CHECK-NEXT: [[SUB16:%.*]] = sub nsw i32 0, [[TMP1]]
+; CHECK-NEXT: ret i32 [[SUB16]]
;
%cmp = icmp sgt i32 %x, -1
%sub = sub nsw i32 0, %x
define i32 @nabs_abs_x10(i32 %x) {
; CHECK-LABEL: @nabs_abs_x10(
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
-; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
-; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
-; CHECK-NEXT: ret i32 [[COND]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 true)
+; CHECK-NEXT: [[SUB16:%.*]] = sub nsw i32 0, [[TMP1]]
+; CHECK-NEXT: ret i32 [[SUB16]]
;
%cmp = icmp sgt i32 %x, 0
%sub = sub nsw i32 0, %x
define i32 @nabs_abs_x11(i32 %x) {
; CHECK-LABEL: @nabs_abs_x11(
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
-; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
-; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
-; CHECK-NEXT: ret i32 [[COND]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 true)
+; CHECK-NEXT: [[SUB16:%.*]] = sub nsw i32 0, [[TMP1]]
+; CHECK-NEXT: ret i32 [[SUB16]]
;
%cmp = icmp slt i32 %x, 0
%sub = sub nsw i32 0, %x
define i32 @nabs_abs_x12(i32 %x) {
; CHECK-LABEL: @nabs_abs_x12(
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
-; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
-; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
-; CHECK-NEXT: ret i32 [[COND]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 true)
+; CHECK-NEXT: [[SUB16:%.*]] = sub nsw i32 0, [[TMP1]]
+; CHECK-NEXT: ret i32 [[SUB16]]
;
%cmp = icmp slt i32 %x, 1
%sub = sub nsw i32 0, %x
define i32 @nabs_abs_x13(i32 %x) {
; CHECK-LABEL: @nabs_abs_x13(
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
-; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
-; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
-; CHECK-NEXT: ret i32 [[COND1]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 true)
+; CHECK-NEXT: [[SUB16:%.*]] = sub nsw i32 0, [[TMP1]]
+; CHECK-NEXT: ret i32 [[SUB16]]
;
%cmp = icmp sgt i32 %x, -1
%sub = sub nsw i32 0, %x
define i32 @nabs_abs_x14(i32 %x) {
; CHECK-LABEL: @nabs_abs_x14(
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
-; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
-; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
-; CHECK-NEXT: ret i32 [[COND1]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 true)
+; CHECK-NEXT: [[SUB16:%.*]] = sub nsw i32 0, [[TMP1]]
+; CHECK-NEXT: ret i32 [[SUB16]]
;
%cmp = icmp sgt i32 %x, 0
%sub = sub nsw i32 0, %x
define i32 @nabs_abs_x15(i32 %x) {
; CHECK-LABEL: @nabs_abs_x15(
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
-; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
-; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
-; CHECK-NEXT: ret i32 [[COND1]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 true)
+; CHECK-NEXT: [[SUB16:%.*]] = sub nsw i32 0, [[TMP1]]
+; CHECK-NEXT: ret i32 [[SUB16]]
;
%cmp = icmp slt i32 %x, 0
%sub = sub nsw i32 0, %x
define i32 @nabs_abs_x16(i32 %x) {
; CHECK-LABEL: @nabs_abs_x16(
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
-; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
-; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
-; CHECK-NEXT: ret i32 [[COND1]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 true)
+; CHECK-NEXT: [[SUB16:%.*]] = sub nsw i32 0, [[TMP1]]
+; CHECK-NEXT: ret i32 [[SUB16]]
;
%cmp = icmp slt i32 %x, 1
%sub = sub nsw i32 0, %x
; nabs(abs(-x)) -> nabs(-x) -> nabs(x)
define i32 @nabs_abs_x17(i32 %x) {
; CHECK-LABEL: @nabs_abs_x17(
-; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X:%.*]]
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X]], 0
-; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
-; CHECK-NEXT: ret i32 [[COND]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 true)
+; CHECK-NEXT: [[SUB16:%.*]] = sub nsw i32 0, [[TMP1]]
+; CHECK-NEXT: ret i32 [[SUB16]]
;
%sub = sub nsw i32 0, %x
%cmp = icmp sgt i32 %sub, -1
define i32 @nabs_abs_x18(i32 %x, i32 %y) {
; CHECK-LABEL: @nabs_abs_x18(
; CHECK-NEXT: [[A:%.*]] = sub nsw i32 [[X:%.*]], [[Y:%.*]]
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[A]], 0
-; CHECK-NEXT: [[NEGA:%.*]] = sub i32 0, [[A]]
-; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[A]], i32 [[NEGA]]
-; CHECK-NEXT: ret i32 [[COND]]
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.abs.i32(i32 [[A]], i1 false)
+; CHECK-NEXT: [[COND18:%.*]] = sub nsw i32 0, [[TMP1]]
+; CHECK-NEXT: ret i32 [[COND18]]
;
%a = sub nsw i32 %x, %y
%b = sub nsw i32 %y, %x
; nabs(abs(-x)) -> nabs(-x) -> nabs(x)
define <2 x i32> @nabs_abs_x01_vec(<2 x i32> %x) {
; CHECK-LABEL: @nabs_abs_x01_vec(
-; CHECK-NEXT: [[SUB:%.*]] = sub nsw <2 x i32> zeroinitializer, [[X:%.*]]
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt <2 x i32> [[X]], zeroinitializer
-; CHECK-NEXT: [[COND:%.*]] = select <2 x i1> [[CMP]], <2 x i32> [[X]], <2 x i32> [[SUB]]
-; CHECK-NEXT: ret <2 x i32> [[COND]]
+; CHECK-NEXT: [[TMP1:%.*]] = call <2 x i32> @llvm.abs.v2i32(<2 x i32> [[X:%.*]], i1 true)
+; CHECK-NEXT: [[SUB16:%.*]] = sub nsw <2 x i32> zeroinitializer, [[TMP1]]
+; CHECK-NEXT: ret <2 x i32> [[SUB16]]
;
%sub = sub nsw <2 x i32> zeroinitializer, %x
%cmp = icmp sgt <2 x i32> %sub, <i32 -1, i32 -1>
define <2 x i32> @nabs_abs_x02_vec(<2 x i32> %x, <2 x i32> %y) {
; CHECK-LABEL: @nabs_abs_x02_vec(
; CHECK-NEXT: [[A:%.*]] = sub nsw <2 x i32> [[X:%.*]], [[Y:%.*]]
-; CHECK-NEXT: [[CMP:%.*]] = icmp slt <2 x i32> [[A]], zeroinitializer
-; CHECK-NEXT: [[NEGA:%.*]] = sub <2 x i32> zeroinitializer, [[A]]
-; CHECK-NEXT: [[COND:%.*]] = select <2 x i1> [[CMP]], <2 x i32> [[A]], <2 x i32> [[NEGA]]
-; CHECK-NEXT: ret <2 x i32> [[COND]]
+; CHECK-NEXT: [[TMP1:%.*]] = call <2 x i32> @llvm.abs.v2i32(<2 x i32> [[A]], i1 false)
+; CHECK-NEXT: [[COND18:%.*]] = sub nsw <2 x i32> zeroinitializer, [[TMP1]]
+; CHECK-NEXT: ret <2 x i32> [[COND18]]
;
%a = sub nsw <2 x i32> %x, %y
%b = sub nsw <2 x i32> %y, %x