2018-05-18 23:22:19 +08:00
|
|
|
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
2014-06-06 14:54:45 +08:00
|
|
|
; RUN: opt < %s -instcombine -S | FileCheck %s
|
|
|
|
|
|
|
|
define i32 @abs_abs_x01(i32 %x) {
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-LABEL: @abs_abs_x01(
|
2018-05-20 22:23:23 +08:00
|
|
|
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
2018-05-20 22:23:23 +08:00
|
|
|
; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-NEXT: ret i32 [[COND]]
|
|
|
|
;
|
2014-06-06 14:54:45 +08:00
|
|
|
%cmp = icmp sgt i32 %x, -1
|
|
|
|
%sub = sub nsw i32 0, %x
|
|
|
|
%cond = select i1 %cmp, i32 %x, i32 %sub
|
|
|
|
%cmp1 = icmp sgt i32 %cond, -1
|
|
|
|
%sub16 = sub nsw i32 0, %cond
|
|
|
|
%cond18 = select i1 %cmp1, i32 %cond, i32 %sub16
|
|
|
|
ret i32 %cond18
|
|
|
|
}
|
|
|
|
|
2016-10-27 23:02:45 +08:00
|
|
|
define <2 x i32> @abs_abs_x01_vec(<2 x i32> %x) {
|
|
|
|
; CHECK-LABEL: @abs_abs_x01_vec(
|
2018-05-20 22:23:23 +08:00
|
|
|
; CHECK-NEXT: [[CMP:%.*]] = icmp slt <2 x i32> [[X:%.*]], zeroinitializer
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-NEXT: [[SUB:%.*]] = sub nsw <2 x i32> zeroinitializer, [[X]]
|
2018-05-20 22:23:23 +08:00
|
|
|
; CHECK-NEXT: [[COND:%.*]] = select <2 x i1> [[CMP]], <2 x i32> [[SUB]], <2 x i32> [[X]]
|
2016-10-27 23:26:10 +08:00
|
|
|
; CHECK-NEXT: ret <2 x i32> [[COND]]
|
2016-10-27 23:02:45 +08:00
|
|
|
;
|
|
|
|
%cmp = icmp sgt <2 x i32> %x, <i32 -1, i32 -1>
|
|
|
|
%sub = sub nsw <2 x i32> zeroinitializer, %x
|
|
|
|
%cond = select <2 x i1> %cmp, <2 x i32> %x, <2 x i32> %sub
|
|
|
|
%cmp1 = icmp sgt <2 x i32> %cond, <i32 -1, i32 -1>
|
|
|
|
%sub16 = sub nsw <2 x i32> zeroinitializer, %cond
|
|
|
|
%cond18 = select <2 x i1> %cmp1, <2 x i32> %cond, <2 x i32> %sub16
|
|
|
|
ret <2 x i32> %cond18
|
|
|
|
}
|
|
|
|
|
2014-06-06 14:54:45 +08:00
|
|
|
define i32 @abs_abs_x02(i32 %x) {
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-LABEL: @abs_abs_x02(
|
2018-05-20 22:23:23 +08:00
|
|
|
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
2018-05-20 22:23:23 +08:00
|
|
|
; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-NEXT: ret i32 [[COND]]
|
|
|
|
;
|
2014-06-06 14:54:45 +08:00
|
|
|
%cmp = icmp sgt i32 %x, 0
|
|
|
|
%sub = sub nsw i32 0, %x
|
|
|
|
%cond = select i1 %cmp, i32 %x, i32 %sub
|
|
|
|
%cmp1 = icmp sgt i32 %cond, -1
|
|
|
|
%sub16 = sub nsw i32 0, %cond
|
|
|
|
%cond18 = select i1 %cmp1, i32 %cond, i32 %sub16
|
|
|
|
ret i32 %cond18
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @abs_abs_x03(i32 %x) {
|
2018-05-18 23:22:19 +08:00
|
|
|
; 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]]
|
|
|
|
;
|
2014-06-06 14:54:45 +08:00
|
|
|
%cmp = icmp slt i32 %x, 0
|
|
|
|
%sub = sub nsw i32 0, %x
|
|
|
|
%cond = select i1 %cmp, i32 %sub, i32 %x
|
|
|
|
%cmp1 = icmp sgt i32 %cond, -1
|
|
|
|
%sub16 = sub nsw i32 0, %cond
|
|
|
|
%cond18 = select i1 %cmp1, i32 %cond, i32 %sub16
|
|
|
|
ret i32 %cond18
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @abs_abs_x04(i32 %x) {
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-LABEL: @abs_abs_x04(
|
2018-05-20 22:23:23 +08:00
|
|
|
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
|
|
|
; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
|
|
|
|
; CHECK-NEXT: ret i32 [[COND]]
|
|
|
|
;
|
2014-06-06 14:54:45 +08:00
|
|
|
%cmp = icmp slt i32 %x, 1
|
|
|
|
%sub = sub nsw i32 0, %x
|
|
|
|
%cond = select i1 %cmp, i32 %sub, i32 %x
|
|
|
|
%cmp1 = icmp sgt i32 %cond, -1
|
|
|
|
%sub16 = sub nsw i32 0, %cond
|
|
|
|
%cond18 = select i1 %cmp1, i32 %cond, i32 %sub16
|
|
|
|
ret i32 %cond18
|
|
|
|
}
|
|
|
|
|
2016-10-27 23:02:45 +08:00
|
|
|
define <2 x i32> @abs_abs_x04_vec(<2 x i32> %x) {
|
|
|
|
; CHECK-LABEL: @abs_abs_x04_vec(
|
2018-05-20 22:23:23 +08:00
|
|
|
; CHECK-NEXT: [[CMP:%.*]] = icmp slt <2 x i32> [[X:%.*]], zeroinitializer
|
2018-05-18 23:22:19 +08:00
|
|
|
; 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]]
|
2016-10-27 23:26:10 +08:00
|
|
|
; CHECK-NEXT: ret <2 x i32> [[COND]]
|
2016-10-27 23:02:45 +08:00
|
|
|
;
|
|
|
|
%cmp = icmp slt <2 x i32> %x, <i32 1, i32 1>
|
|
|
|
%sub = sub nsw <2 x i32> zeroinitializer, %x
|
|
|
|
%cond = select <2 x i1> %cmp, <2 x i32> %sub, <2 x i32> %x
|
|
|
|
%cmp1 = icmp sgt <2 x i32> %cond, <i32 -1, i32 -1>
|
|
|
|
%sub16 = sub nsw <2 x i32> zeroinitializer, %cond
|
|
|
|
%cond18 = select <2 x i1> %cmp1, <2 x i32> %cond, <2 x i32> %sub16
|
|
|
|
ret <2 x i32> %cond18
|
|
|
|
}
|
|
|
|
|
2014-06-06 14:54:45 +08:00
|
|
|
define i32 @abs_abs_x05(i32 %x) {
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-LABEL: @abs_abs_x05(
|
2018-05-20 22:23:23 +08:00
|
|
|
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
2018-05-20 22:23:23 +08:00
|
|
|
; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-NEXT: ret i32 [[COND]]
|
|
|
|
;
|
2014-06-06 14:54:45 +08:00
|
|
|
%cmp = icmp sgt i32 %x, -1
|
|
|
|
%sub = sub nsw i32 0, %x
|
|
|
|
%cond = select i1 %cmp, i32 %x, i32 %sub
|
|
|
|
%cmp1 = icmp sgt i32 %cond, 0
|
|
|
|
%sub16 = sub nsw i32 0, %cond
|
|
|
|
%cond18 = select i1 %cmp1, i32 %cond, i32 %sub16
|
|
|
|
ret i32 %cond18
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @abs_abs_x06(i32 %x) {
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-LABEL: @abs_abs_x06(
|
2018-05-20 22:23:23 +08:00
|
|
|
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
2018-05-20 22:23:23 +08:00
|
|
|
; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-NEXT: ret i32 [[COND]]
|
|
|
|
;
|
2014-06-06 14:54:45 +08:00
|
|
|
%cmp = icmp sgt i32 %x, 0
|
|
|
|
%sub = sub nsw i32 0, %x
|
|
|
|
%cond = select i1 %cmp, i32 %x, i32 %sub
|
|
|
|
%cmp1 = icmp sgt i32 %cond, 0
|
|
|
|
%sub16 = sub nsw i32 0, %cond
|
|
|
|
%cond18 = select i1 %cmp1, i32 %cond, i32 %sub16
|
|
|
|
ret i32 %cond18
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @abs_abs_x07(i32 %x) {
|
2018-05-18 23:22:19 +08:00
|
|
|
; 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]]
|
|
|
|
;
|
2014-06-06 14:54:45 +08:00
|
|
|
%cmp = icmp slt i32 %x, 0
|
|
|
|
%sub = sub nsw i32 0, %x
|
|
|
|
%cond = select i1 %cmp, i32 %sub, i32 %x
|
|
|
|
%cmp1 = icmp sgt i32 %cond, 0
|
|
|
|
%sub16 = sub nsw i32 0, %cond
|
|
|
|
%cond18 = select i1 %cmp1, i32 %cond, i32 %sub16
|
|
|
|
ret i32 %cond18
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @abs_abs_x08(i32 %x) {
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-LABEL: @abs_abs_x08(
|
2018-05-20 22:23:23 +08:00
|
|
|
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
|
|
|
; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
|
|
|
|
; CHECK-NEXT: ret i32 [[COND]]
|
|
|
|
;
|
2014-06-06 14:54:45 +08:00
|
|
|
%cmp = icmp slt i32 %x, 1
|
|
|
|
%sub = sub nsw i32 0, %x
|
|
|
|
%cond = select i1 %cmp, i32 %sub, i32 %x
|
|
|
|
%cmp1 = icmp sgt i32 %cond, 0
|
|
|
|
%sub16 = sub nsw i32 0, %cond
|
|
|
|
%cond18 = select i1 %cmp1, i32 %cond, i32 %sub16
|
|
|
|
ret i32 %cond18
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @abs_abs_x09(i32 %x) {
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-LABEL: @abs_abs_x09(
|
2018-05-20 22:23:23 +08:00
|
|
|
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
2018-05-20 22:23:23 +08:00
|
|
|
; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-NEXT: ret i32 [[COND]]
|
|
|
|
;
|
2014-06-06 14:54:45 +08:00
|
|
|
%cmp = icmp sgt i32 %x, -1
|
|
|
|
%sub = sub nsw i32 0, %x
|
|
|
|
%cond = select i1 %cmp, i32 %x, i32 %sub
|
|
|
|
%cmp1 = icmp slt i32 %cond, 0
|
|
|
|
%sub9 = sub nsw i32 0, %cond
|
|
|
|
%cond18 = select i1 %cmp1, i32 %sub9, i32 %cond
|
|
|
|
ret i32 %cond18
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @abs_abs_x10(i32 %x) {
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-LABEL: @abs_abs_x10(
|
2018-05-20 22:23:23 +08:00
|
|
|
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
2018-05-20 22:23:23 +08:00
|
|
|
; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-NEXT: ret i32 [[COND]]
|
|
|
|
;
|
2014-06-06 14:54:45 +08:00
|
|
|
%cmp = icmp sgt i32 %x, 0
|
|
|
|
%sub = sub nsw i32 0, %x
|
|
|
|
%cond = select i1 %cmp, i32 %x, i32 %sub
|
|
|
|
%cmp1 = icmp slt i32 %cond, 0
|
|
|
|
%sub9 = sub nsw i32 0, %cond
|
|
|
|
%cond18 = select i1 %cmp1, i32 %sub9, i32 %cond
|
|
|
|
ret i32 %cond18
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @abs_abs_x11(i32 %x) {
|
2018-05-18 23:22:19 +08:00
|
|
|
; 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]]
|
|
|
|
;
|
2014-06-06 14:54:45 +08:00
|
|
|
%cmp = icmp slt i32 %x, 0
|
|
|
|
%sub = sub nsw i32 0, %x
|
|
|
|
%cond = select i1 %cmp, i32 %sub, i32 %x
|
|
|
|
%cmp1 = icmp slt i32 %cond, 0
|
|
|
|
%sub9 = sub nsw i32 0, %cond
|
|
|
|
%cond18 = select i1 %cmp1, i32 %sub9, i32 %cond
|
|
|
|
ret i32 %cond18
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @abs_abs_x12(i32 %x) {
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-LABEL: @abs_abs_x12(
|
2018-05-20 22:23:23 +08:00
|
|
|
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
|
|
|
; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
|
|
|
|
; CHECK-NEXT: ret i32 [[COND]]
|
|
|
|
;
|
2014-06-06 14:54:45 +08:00
|
|
|
%cmp = icmp slt i32 %x, 1
|
|
|
|
%sub = sub nsw i32 0, %x
|
|
|
|
%cond = select i1 %cmp, i32 %sub, i32 %x
|
|
|
|
%cmp1 = icmp slt i32 %cond, 0
|
|
|
|
%sub9 = sub nsw i32 0, %cond
|
|
|
|
%cond18 = select i1 %cmp1, i32 %sub9, i32 %cond
|
|
|
|
ret i32 %cond18
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @abs_abs_x13(i32 %x) {
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-LABEL: @abs_abs_x13(
|
2018-05-20 22:23:23 +08:00
|
|
|
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
2018-05-20 22:23:23 +08:00
|
|
|
; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-NEXT: ret i32 [[COND]]
|
|
|
|
;
|
2014-06-06 14:54:45 +08:00
|
|
|
%cmp = icmp sgt i32 %x, -1
|
|
|
|
%sub = sub nsw i32 0, %x
|
|
|
|
%cond = select i1 %cmp, i32 %x, i32 %sub
|
|
|
|
%cmp1 = icmp slt i32 %cond, 1
|
|
|
|
%sub9 = sub nsw i32 0, %cond
|
|
|
|
%cond18 = select i1 %cmp1, i32 %sub9, i32 %cond
|
|
|
|
ret i32 %cond18
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @abs_abs_x14(i32 %x) {
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-LABEL: @abs_abs_x14(
|
2018-05-20 22:23:23 +08:00
|
|
|
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
2018-05-20 22:23:23 +08:00
|
|
|
; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-NEXT: ret i32 [[COND]]
|
|
|
|
;
|
2014-06-06 14:54:45 +08:00
|
|
|
%cmp = icmp sgt i32 %x, 0
|
|
|
|
%sub = sub nsw i32 0, %x
|
|
|
|
%cond = select i1 %cmp, i32 %x, i32 %sub
|
|
|
|
%cmp1 = icmp slt i32 %cond, 1
|
|
|
|
%sub9 = sub nsw i32 0, %cond
|
|
|
|
%cond18 = select i1 %cmp1, i32 %sub9, i32 %cond
|
|
|
|
ret i32 %cond18
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @abs_abs_x15(i32 %x) {
|
2018-05-18 23:22:19 +08:00
|
|
|
; 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]]
|
|
|
|
;
|
2014-06-06 14:54:45 +08:00
|
|
|
%cmp = icmp slt i32 %x, 0
|
|
|
|
%sub = sub nsw i32 0, %x
|
|
|
|
%cond = select i1 %cmp, i32 %sub, i32 %x
|
|
|
|
%cmp1 = icmp slt i32 %cond, 1
|
|
|
|
%sub9 = sub nsw i32 0, %cond
|
|
|
|
%cond18 = select i1 %cmp1, i32 %sub9, i32 %cond
|
|
|
|
ret i32 %cond18
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @abs_abs_x16(i32 %x) {
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-LABEL: @abs_abs_x16(
|
2018-05-20 22:23:23 +08:00
|
|
|
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
|
|
|
; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
|
|
|
|
; CHECK-NEXT: ret i32 [[COND]]
|
|
|
|
;
|
2014-06-06 14:54:45 +08:00
|
|
|
%cmp = icmp slt i32 %x, 1
|
|
|
|
%sub = sub nsw i32 0, %x
|
|
|
|
%cond = select i1 %cmp, i32 %sub, i32 %x
|
|
|
|
%cmp1 = icmp slt i32 %cond, 1
|
|
|
|
%sub9 = sub nsw i32 0, %cond
|
|
|
|
%cond18 = select i1 %cmp1, i32 %sub9, i32 %cond
|
|
|
|
ret i32 %cond18
|
|
|
|
}
|
|
|
|
|
2018-07-27 09:49:51 +08:00
|
|
|
; abs(abs(-x)) -> abs(-x) -> abs(x)
|
2018-07-12 21:28:20 +08:00
|
|
|
define i32 @abs_abs_x17(i32 %x) {
|
|
|
|
; CHECK-LABEL: @abs_abs_x17(
|
|
|
|
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X:%.*]]
|
2018-07-27 09:49:51 +08:00
|
|
|
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X]], 0
|
2018-07-12 21:28:20 +08:00
|
|
|
; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
|
|
|
|
; CHECK-NEXT: ret i32 [[COND]]
|
|
|
|
;
|
|
|
|
%sub = sub nsw i32 0, %x
|
|
|
|
%cmp = icmp sgt i32 %sub, -1
|
|
|
|
%cond = select i1 %cmp, i32 %sub, i32 %x
|
|
|
|
%cmp1 = icmp sgt i32 %cond, -1
|
|
|
|
%sub16 = sub nsw i32 0, %cond
|
|
|
|
%cond18 = select i1 %cmp1, i32 %cond, i32 %sub16
|
|
|
|
ret i32 %cond18
|
|
|
|
}
|
|
|
|
|
|
|
|
; abs(abs(x - y)) -> abs(x - y)
|
|
|
|
define i32 @abs_abs_x18(i32 %x, i32 %y) {
|
|
|
|
; CHECK-LABEL: @abs_abs_x18(
|
|
|
|
; CHECK-NEXT: [[A:%.*]] = sub nsw i32 [[X:%.*]], [[Y:%.*]]
|
2018-07-27 09:49:51 +08:00
|
|
|
; 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]]
|
2018-07-16 10:23:00 +08:00
|
|
|
; CHECK-NEXT: ret i32 [[COND]]
|
2018-07-12 21:28:20 +08:00
|
|
|
;
|
|
|
|
%a = sub nsw i32 %x, %y
|
|
|
|
%b = sub nsw i32 %y, %x
|
|
|
|
%cmp = icmp sgt i32 %a, -1
|
|
|
|
%cond = select i1 %cmp, i32 %a, i32 %b
|
|
|
|
%cmp1 = icmp sgt i32 %cond, -1
|
|
|
|
%sub16 = sub nsw i32 0, %cond
|
|
|
|
%cond18 = select i1 %cmp1, i32 %cond, i32 %sub16
|
|
|
|
ret i32 %cond18
|
|
|
|
}
|
|
|
|
|
2018-07-27 09:49:51 +08:00
|
|
|
; abs(abs(-x)) -> abs(-x) -> abs(x)
|
2018-07-12 21:28:20 +08:00
|
|
|
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:%.*]]
|
2018-07-27 09:49:51 +08:00
|
|
|
; CHECK-NEXT: [[CMP:%.*]] = icmp slt <2 x i32> [[X]], zeroinitializer
|
2018-07-12 21:28:20 +08:00
|
|
|
; CHECK-NEXT: [[COND:%.*]] = select <2 x i1> [[CMP]], <2 x i32> [[SUB]], <2 x i32> [[X]]
|
2018-07-16 08:51:40 +08:00
|
|
|
; CHECK-NEXT: ret <2 x i32> [[COND]]
|
2018-07-12 21:28:20 +08:00
|
|
|
;
|
|
|
|
%sub = sub nsw <2 x i32> zeroinitializer, %x
|
|
|
|
%cmp = icmp sgt <2 x i32> %sub, <i32 -1, i32 -1>
|
|
|
|
%cond = select <2 x i1> %cmp, <2 x i32> %sub, <2 x i32> %x
|
|
|
|
%cmp1 = icmp sgt <2 x i32> %cond, <i32 -1, i32 -1>
|
|
|
|
%sub16 = sub nsw <2 x i32> zeroinitializer, %cond
|
|
|
|
%cond18 = select <2 x i1> %cmp1, <2 x i32> %cond, <2 x i32> %sub16
|
|
|
|
ret <2 x i32> %cond18
|
|
|
|
}
|
|
|
|
|
|
|
|
; abs(abs(x - y)) -> abs(x - y)
|
|
|
|
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:%.*]]
|
2018-07-27 09:49:51 +08:00
|
|
|
; 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]]
|
2018-07-16 10:23:00 +08:00
|
|
|
; CHECK-NEXT: ret <2 x i32> [[COND]]
|
2018-07-12 21:28:20 +08:00
|
|
|
;
|
|
|
|
%a = sub nsw <2 x i32> %x, %y
|
|
|
|
%b = sub nsw <2 x i32> %y, %x
|
|
|
|
%cmp = icmp sgt <2 x i32> %a, <i32 -1, i32 -1>
|
|
|
|
%cond = select <2 x i1> %cmp, <2 x i32> %a, <2 x i32> %b
|
|
|
|
%cmp1 = icmp sgt <2 x i32> %cond, <i32 -1, i32 -1>
|
|
|
|
%sub16 = sub nsw <2 x i32> zeroinitializer, %cond
|
|
|
|
%cond18 = select <2 x i1> %cmp1, <2 x i32> %cond, <2 x i32> %sub16
|
|
|
|
ret <2 x i32> %cond18
|
|
|
|
}
|
|
|
|
|
2014-06-06 14:54:45 +08:00
|
|
|
define i32 @nabs_nabs_x01(i32 %x) {
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-LABEL: @nabs_nabs_x01(
|
2018-05-20 22:23:23 +08:00
|
|
|
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
2018-05-20 22:23:23 +08:00
|
|
|
; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-NEXT: ret i32 [[COND]]
|
|
|
|
;
|
2014-06-06 14:54:45 +08:00
|
|
|
%cmp = icmp sgt i32 %x, -1
|
|
|
|
%sub = sub nsw i32 0, %x
|
|
|
|
%cond = select i1 %cmp, i32 %sub, i32 %x
|
|
|
|
%cmp1 = icmp sgt i32 %cond, -1
|
|
|
|
%sub9 = sub nsw i32 0, %cond
|
|
|
|
%cond18 = select i1 %cmp1, i32 %sub9, i32 %cond
|
|
|
|
ret i32 %cond18
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @nabs_nabs_x02(i32 %x) {
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-LABEL: @nabs_nabs_x02(
|
2018-05-20 22:23:23 +08:00
|
|
|
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
2018-05-20 22:23:23 +08:00
|
|
|
; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-NEXT: ret i32 [[COND]]
|
|
|
|
;
|
2014-06-06 14:54:45 +08:00
|
|
|
%cmp = icmp sgt i32 %x, 0
|
|
|
|
%sub = sub nsw i32 0, %x
|
|
|
|
%cond = select i1 %cmp, i32 %sub, i32 %x
|
|
|
|
%cmp1 = icmp sgt i32 %cond, -1
|
|
|
|
%sub9 = sub nsw i32 0, %cond
|
|
|
|
%cond18 = select i1 %cmp1, i32 %sub9, i32 %cond
|
|
|
|
ret i32 %cond18
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @nabs_nabs_x03(i32 %x) {
|
2018-05-18 23:22:19 +08:00
|
|
|
; 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: ret i32 [[COND]]
|
|
|
|
;
|
2014-06-06 14:54:45 +08:00
|
|
|
%cmp = icmp slt i32 %x, 0
|
|
|
|
%sub = sub nsw i32 0, %x
|
|
|
|
%cond = select i1 %cmp, i32 %x, i32 %sub
|
|
|
|
%cmp1 = icmp sgt i32 %cond, -1
|
|
|
|
%sub9 = sub nsw i32 0, %cond
|
|
|
|
%cond18 = select i1 %cmp1, i32 %sub9, i32 %cond
|
|
|
|
ret i32 %cond18
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @nabs_nabs_x04(i32 %x) {
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-LABEL: @nabs_nabs_x04(
|
2018-05-20 22:23:23 +08:00
|
|
|
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
|
|
|
; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
|
|
|
|
; CHECK-NEXT: ret i32 [[COND]]
|
|
|
|
;
|
2014-06-06 14:54:45 +08:00
|
|
|
%cmp = icmp slt i32 %x, 1
|
|
|
|
%sub = sub nsw i32 0, %x
|
|
|
|
%cond = select i1 %cmp, i32 %x, i32 %sub
|
|
|
|
%cmp1 = icmp sgt i32 %cond, -1
|
|
|
|
%sub9 = sub nsw i32 0, %cond
|
|
|
|
%cond18 = select i1 %cmp1, i32 %sub9, i32 %cond
|
|
|
|
ret i32 %cond18
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @nabs_nabs_x05(i32 %x) {
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-LABEL: @nabs_nabs_x05(
|
2018-05-20 22:23:23 +08:00
|
|
|
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
2018-05-20 22:23:23 +08:00
|
|
|
; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-NEXT: ret i32 [[COND]]
|
|
|
|
;
|
2014-06-06 14:54:45 +08:00
|
|
|
%cmp = icmp sgt i32 %x, -1
|
|
|
|
%sub = sub nsw i32 0, %x
|
|
|
|
%cond = select i1 %cmp, i32 %sub, i32 %x
|
|
|
|
%cmp1 = icmp sgt i32 %cond, 0
|
|
|
|
%sub9 = sub nsw i32 0, %cond
|
|
|
|
%cond18 = select i1 %cmp1, i32 %sub9, i32 %cond
|
|
|
|
ret i32 %cond18
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @nabs_nabs_x06(i32 %x) {
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-LABEL: @nabs_nabs_x06(
|
2018-05-20 22:23:23 +08:00
|
|
|
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
2018-05-20 22:23:23 +08:00
|
|
|
; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-NEXT: ret i32 [[COND]]
|
|
|
|
;
|
2014-06-06 14:54:45 +08:00
|
|
|
%cmp = icmp sgt i32 %x, 0
|
|
|
|
%sub = sub nsw i32 0, %x
|
|
|
|
%cond = select i1 %cmp, i32 %sub, i32 %x
|
|
|
|
%cmp1 = icmp sgt i32 %cond, 0
|
|
|
|
%sub9 = sub nsw i32 0, %cond
|
|
|
|
%cond18 = select i1 %cmp1, i32 %sub9, i32 %cond
|
|
|
|
ret i32 %cond18
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @nabs_nabs_x07(i32 %x) {
|
2018-05-18 23:22:19 +08:00
|
|
|
; 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: ret i32 [[COND]]
|
|
|
|
;
|
2014-06-06 14:54:45 +08:00
|
|
|
%cmp = icmp slt i32 %x, 0
|
|
|
|
%sub = sub nsw i32 0, %x
|
|
|
|
%cond = select i1 %cmp, i32 %x, i32 %sub
|
|
|
|
%cmp1 = icmp sgt i32 %cond, 0
|
|
|
|
%sub9 = sub nsw i32 0, %cond
|
|
|
|
%cond18 = select i1 %cmp1, i32 %sub9, i32 %cond
|
|
|
|
ret i32 %cond18
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @nabs_nabs_x08(i32 %x) {
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-LABEL: @nabs_nabs_x08(
|
2018-05-20 22:23:23 +08:00
|
|
|
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
|
|
|
; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
|
|
|
|
; CHECK-NEXT: ret i32 [[COND]]
|
|
|
|
;
|
2014-06-06 14:54:45 +08:00
|
|
|
%cmp = icmp slt i32 %x, 1
|
|
|
|
%sub = sub nsw i32 0, %x
|
|
|
|
%cond = select i1 %cmp, i32 %x, i32 %sub
|
|
|
|
%cmp1 = icmp sgt i32 %cond, 0
|
|
|
|
%sub9 = sub nsw i32 0, %cond
|
|
|
|
%cond18 = select i1 %cmp1, i32 %sub9, i32 %cond
|
|
|
|
ret i32 %cond18
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @nabs_nabs_x09(i32 %x) {
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-LABEL: @nabs_nabs_x09(
|
2018-05-20 22:23:23 +08:00
|
|
|
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
2018-05-20 22:23:23 +08:00
|
|
|
; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-NEXT: ret i32 [[COND]]
|
|
|
|
;
|
2014-06-06 14:54:45 +08:00
|
|
|
%cmp = icmp sgt i32 %x, -1
|
|
|
|
%sub = sub nsw i32 0, %x
|
|
|
|
%cond = select i1 %cmp, i32 %sub, i32 %x
|
|
|
|
%cmp1 = icmp slt i32 %cond, 0
|
|
|
|
%sub16 = sub nsw i32 0, %cond
|
|
|
|
%cond18 = select i1 %cmp1, i32 %cond, i32 %sub16
|
|
|
|
ret i32 %cond18
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @nabs_nabs_x10(i32 %x) {
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-LABEL: @nabs_nabs_x10(
|
2018-05-20 22:23:23 +08:00
|
|
|
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
2018-05-20 22:23:23 +08:00
|
|
|
; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-NEXT: ret i32 [[COND]]
|
|
|
|
;
|
2014-06-06 14:54:45 +08:00
|
|
|
%cmp = icmp sgt i32 %x, 0
|
|
|
|
%sub = sub nsw i32 0, %x
|
|
|
|
%cond = select i1 %cmp, i32 %sub, i32 %x
|
|
|
|
%cmp1 = icmp slt i32 %cond, 0
|
|
|
|
%sub16 = sub nsw i32 0, %cond
|
|
|
|
%cond18 = select i1 %cmp1, i32 %cond, i32 %sub16
|
|
|
|
ret i32 %cond18
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @nabs_nabs_x11(i32 %x) {
|
2018-05-18 23:22:19 +08:00
|
|
|
; 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: ret i32 [[COND]]
|
|
|
|
;
|
2014-06-06 14:54:45 +08:00
|
|
|
%cmp = icmp slt i32 %x, 0
|
|
|
|
%sub = sub nsw i32 0, %x
|
|
|
|
%cond = select i1 %cmp, i32 %x, i32 %sub
|
|
|
|
%cmp1 = icmp slt i32 %cond, 0
|
|
|
|
%sub16 = sub nsw i32 0, %cond
|
|
|
|
%cond18 = select i1 %cmp1, i32 %cond, i32 %sub16
|
|
|
|
ret i32 %cond18
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @nabs_nabs_x12(i32 %x) {
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-LABEL: @nabs_nabs_x12(
|
2018-05-20 22:23:23 +08:00
|
|
|
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
|
|
|
; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
|
|
|
|
; CHECK-NEXT: ret i32 [[COND]]
|
|
|
|
;
|
2014-06-06 14:54:45 +08:00
|
|
|
%cmp = icmp slt i32 %x, 1
|
|
|
|
%sub = sub nsw i32 0, %x
|
|
|
|
%cond = select i1 %cmp, i32 %x, i32 %sub
|
|
|
|
%cmp1 = icmp slt i32 %cond, 0
|
|
|
|
%sub16 = sub nsw i32 0, %cond
|
|
|
|
%cond18 = select i1 %cmp1, i32 %cond, i32 %sub16
|
|
|
|
ret i32 %cond18
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @nabs_nabs_x13(i32 %x) {
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-LABEL: @nabs_nabs_x13(
|
2018-05-20 22:23:23 +08:00
|
|
|
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
2018-05-20 22:23:23 +08:00
|
|
|
; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-NEXT: ret i32 [[COND]]
|
|
|
|
;
|
2014-06-06 14:54:45 +08:00
|
|
|
%cmp = icmp sgt i32 %x, -1
|
|
|
|
%sub = sub nsw i32 0, %x
|
|
|
|
%cond = select i1 %cmp, i32 %sub, i32 %x
|
|
|
|
%cmp1 = icmp slt i32 %cond, 1
|
|
|
|
%sub16 = sub nsw i32 0, %cond
|
|
|
|
%cond18 = select i1 %cmp1, i32 %cond, i32 %sub16
|
|
|
|
ret i32 %cond18
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @nabs_nabs_x14(i32 %x) {
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-LABEL: @nabs_nabs_x14(
|
2018-05-20 22:23:23 +08:00
|
|
|
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
2018-05-20 22:23:23 +08:00
|
|
|
; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-NEXT: ret i32 [[COND]]
|
|
|
|
;
|
2014-06-06 14:54:45 +08:00
|
|
|
%cmp = icmp sgt i32 %x, 0
|
|
|
|
%sub = sub nsw i32 0, %x
|
|
|
|
%cond = select i1 %cmp, i32 %sub, i32 %x
|
|
|
|
%cmp1 = icmp slt i32 %cond, 1
|
|
|
|
%sub16 = sub nsw i32 0, %cond
|
|
|
|
%cond18 = select i1 %cmp1, i32 %cond, i32 %sub16
|
|
|
|
ret i32 %cond18
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @nabs_nabs_x15(i32 %x) {
|
2018-05-18 23:22:19 +08:00
|
|
|
; 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: ret i32 [[COND]]
|
|
|
|
;
|
2014-06-06 14:54:45 +08:00
|
|
|
%cmp = icmp slt i32 %x, 0
|
|
|
|
%sub = sub nsw i32 0, %x
|
|
|
|
%cond = select i1 %cmp, i32 %x, i32 %sub
|
|
|
|
%cmp1 = icmp slt i32 %cond, 1
|
|
|
|
%sub16 = sub nsw i32 0, %cond
|
|
|
|
%cond18 = select i1 %cmp1, i32 %cond, i32 %sub16
|
|
|
|
ret i32 %cond18
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @nabs_nabs_x16(i32 %x) {
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-LABEL: @nabs_nabs_x16(
|
2018-05-20 22:23:23 +08:00
|
|
|
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
|
|
|
; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
|
|
|
|
; CHECK-NEXT: ret i32 [[COND]]
|
|
|
|
;
|
2014-06-06 14:54:45 +08:00
|
|
|
%cmp = icmp slt i32 %x, 1
|
|
|
|
%sub = sub nsw i32 0, %x
|
|
|
|
%cond = select i1 %cmp, i32 %x, i32 %sub
|
|
|
|
%cmp1 = icmp slt i32 %cond, 1
|
|
|
|
%sub16 = sub nsw i32 0, %cond
|
|
|
|
%cond18 = select i1 %cmp1, i32 %cond, i32 %sub16
|
|
|
|
ret i32 %cond18
|
|
|
|
}
|
2014-06-12 22:06:00 +08:00
|
|
|
|
2018-07-27 09:49:51 +08:00
|
|
|
; nabs(nabs(-x)) -> nabs(-x) -> nabs(x)
|
2018-07-12 21:28:20 +08:00
|
|
|
define i32 @nabs_nabs_x17(i32 %x) {
|
|
|
|
; CHECK-LABEL: @nabs_nabs_x17(
|
|
|
|
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X:%.*]]
|
2018-07-27 09:49:51 +08:00
|
|
|
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X]], 0
|
2018-07-12 21:28:20 +08:00
|
|
|
; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
|
|
|
|
; CHECK-NEXT: ret i32 [[COND]]
|
|
|
|
;
|
|
|
|
%sub = sub nsw i32 0, %x
|
|
|
|
%cmp = icmp sgt i32 %sub, -1
|
|
|
|
%cond = select i1 %cmp, i32 %x, i32 %sub
|
|
|
|
%cmp1 = icmp sgt i32 %cond, -1
|
|
|
|
%sub16 = sub nsw i32 0, %cond
|
|
|
|
%cond18 = select i1 %cmp1, i32 %sub16, i32 %cond
|
|
|
|
ret i32 %cond18
|
|
|
|
}
|
|
|
|
|
|
|
|
; nabs(nabs(x - y)) -> nabs(x - y)
|
|
|
|
define i32 @nabs_nabs_x18(i32 %x, i32 %y) {
|
|
|
|
; CHECK-LABEL: @nabs_nabs_x18(
|
|
|
|
; CHECK-NEXT: [[A:%.*]] = sub nsw i32 [[X:%.*]], [[Y:%.*]]
|
2018-07-27 09:49:51 +08:00
|
|
|
; 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]]
|
2018-07-16 10:23:00 +08:00
|
|
|
; CHECK-NEXT: ret i32 [[COND]]
|
2018-07-12 21:28:20 +08:00
|
|
|
;
|
|
|
|
%a = sub nsw i32 %x, %y
|
|
|
|
%b = sub nsw i32 %y, %x
|
|
|
|
%cmp = icmp sgt i32 %a, -1
|
|
|
|
%cond = select i1 %cmp, i32 %b, i32 %a
|
|
|
|
%cmp1 = icmp sgt i32 %cond, -1
|
|
|
|
%sub16 = sub nsw i32 0, %cond
|
|
|
|
%cond18 = select i1 %cmp1, i32 %sub16, i32 %cond
|
|
|
|
ret i32 %cond18
|
|
|
|
}
|
|
|
|
|
2018-07-27 09:49:51 +08:00
|
|
|
; nabs(nabs(-x)) -> nabs(-x) -> nabs(x)
|
2018-07-12 21:28:20 +08:00
|
|
|
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:%.*]]
|
2018-07-27 09:49:51 +08:00
|
|
|
; CHECK-NEXT: [[CMP:%.*]] = icmp slt <2 x i32> [[X]], zeroinitializer
|
2018-07-12 21:28:20 +08:00
|
|
|
; CHECK-NEXT: [[COND:%.*]] = select <2 x i1> [[CMP]], <2 x i32> [[X]], <2 x i32> [[SUB]]
|
2018-07-16 08:51:40 +08:00
|
|
|
; CHECK-NEXT: ret <2 x i32> [[COND]]
|
2018-07-12 21:28:20 +08:00
|
|
|
;
|
|
|
|
%sub = sub nsw <2 x i32> zeroinitializer, %x
|
|
|
|
%cmp = icmp sgt <2 x i32> %sub, <i32 -1, i32 -1>
|
|
|
|
%cond = select <2 x i1> %cmp, <2 x i32> %x, <2 x i32> %sub
|
|
|
|
%cmp1 = icmp sgt <2 x i32> %cond, <i32 -1, i32 -1>
|
|
|
|
%sub16 = sub nsw <2 x i32> zeroinitializer, %cond
|
|
|
|
%cond18 = select <2 x i1> %cmp1, <2 x i32> %sub16, <2 x i32> %cond
|
|
|
|
ret <2 x i32> %cond18
|
|
|
|
}
|
|
|
|
|
|
|
|
; nabs(nabs(x - y)) -> nabs(x - y)
|
|
|
|
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:%.*]]
|
2018-07-27 09:49:51 +08:00
|
|
|
; 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]]
|
2018-07-16 10:23:00 +08:00
|
|
|
; CHECK-NEXT: ret <2 x i32> [[COND]]
|
2018-07-12 21:28:20 +08:00
|
|
|
;
|
|
|
|
%a = sub nsw <2 x i32> %x, %y
|
|
|
|
%b = sub nsw <2 x i32> %y, %x
|
|
|
|
%cmp = icmp sgt <2 x i32> %a, <i32 -1, i32 -1>
|
|
|
|
%cond = select <2 x i1> %cmp, <2 x i32> %b, <2 x i32> %a
|
|
|
|
%cmp1 = icmp sgt <2 x i32> %cond, <i32 -1, i32 -1>
|
|
|
|
%sub16 = sub nsw <2 x i32> zeroinitializer, %cond
|
|
|
|
%cond18 = select <2 x i1> %cmp1, <2 x i32> %sub16, <2 x i32> %cond
|
|
|
|
ret <2 x i32> %cond18
|
|
|
|
}
|
|
|
|
|
2014-06-12 22:06:00 +08:00
|
|
|
define i32 @abs_nabs_x01(i32 %x) {
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-LABEL: @abs_nabs_x01(
|
2018-05-20 22:23:23 +08:00
|
|
|
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
2018-05-20 22:23:23 +08:00
|
|
|
; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-NEXT: ret i32 [[COND1]]
|
|
|
|
;
|
2014-06-12 22:06:00 +08:00
|
|
|
%cmp = icmp sgt i32 %x, -1
|
|
|
|
%sub = sub nsw i32 0, %x
|
|
|
|
%cond = select i1 %cmp, i32 %sub, i32 %x
|
|
|
|
%cmp1 = icmp sgt i32 %cond, -1
|
|
|
|
%sub16 = sub nsw i32 0, %cond
|
|
|
|
%cond18 = select i1 %cmp1, i32 %cond, i32 %sub16
|
|
|
|
ret i32 %cond18
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @abs_nabs_x02(i32 %x) {
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-LABEL: @abs_nabs_x02(
|
2018-05-20 22:23:23 +08:00
|
|
|
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
2018-05-20 22:23:23 +08:00
|
|
|
; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-NEXT: ret i32 [[COND1]]
|
|
|
|
;
|
2014-06-12 22:06:00 +08:00
|
|
|
%cmp = icmp sgt i32 %x, 0
|
|
|
|
%sub = sub nsw i32 0, %x
|
|
|
|
%cond = select i1 %cmp, i32 %sub, i32 %x
|
|
|
|
%cmp1 = icmp sgt i32 %cond, -1
|
|
|
|
%sub16 = sub nsw i32 0, %cond
|
|
|
|
%cond18 = select i1 %cmp1, i32 %cond, i32 %sub16
|
|
|
|
ret i32 %cond18
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @abs_nabs_x03(i32 %x) {
|
2018-05-18 23:22:19 +08:00
|
|
|
; 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]]
|
|
|
|
;
|
2014-06-12 22:06:00 +08:00
|
|
|
%cmp = icmp slt i32 %x, 0
|
|
|
|
%sub = sub nsw i32 0, %x
|
|
|
|
%cond = select i1 %cmp, i32 %x, i32 %sub
|
|
|
|
%cmp1 = icmp sgt i32 %cond, -1
|
|
|
|
%sub16 = sub nsw i32 0, %cond
|
|
|
|
%cond18 = select i1 %cmp1, i32 %cond, i32 %sub16
|
|
|
|
ret i32 %cond18
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @abs_nabs_x04(i32 %x) {
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-LABEL: @abs_nabs_x04(
|
2018-05-20 22:23:23 +08:00
|
|
|
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
|
|
|
; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
|
|
|
|
; CHECK-NEXT: ret i32 [[COND1]]
|
|
|
|
;
|
2014-06-12 22:06:00 +08:00
|
|
|
%cmp = icmp slt i32 %x, 1
|
|
|
|
%sub = sub nsw i32 0, %x
|
|
|
|
%cond = select i1 %cmp, i32 %x, i32 %sub
|
|
|
|
%cmp1 = icmp sgt i32 %cond, -1
|
|
|
|
%sub16 = sub nsw i32 0, %cond
|
|
|
|
%cond18 = select i1 %cmp1, i32 %cond, i32 %sub16
|
|
|
|
ret i32 %cond18
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @abs_nabs_x05(i32 %x) {
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-LABEL: @abs_nabs_x05(
|
2018-05-20 22:23:23 +08:00
|
|
|
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
2018-05-20 22:23:23 +08:00
|
|
|
; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-NEXT: ret i32 [[COND1]]
|
|
|
|
;
|
2014-06-12 22:06:00 +08:00
|
|
|
%cmp = icmp sgt i32 %x, -1
|
|
|
|
%sub = sub nsw i32 0, %x
|
|
|
|
%cond = select i1 %cmp, i32 %sub, i32 %x
|
|
|
|
%cmp1 = icmp sgt i32 %cond, 0
|
|
|
|
%sub16 = sub nsw i32 0, %cond
|
|
|
|
%cond18 = select i1 %cmp1, i32 %cond, i32 %sub16
|
|
|
|
ret i32 %cond18
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @abs_nabs_x06(i32 %x) {
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-LABEL: @abs_nabs_x06(
|
2018-05-20 22:23:23 +08:00
|
|
|
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
2018-05-20 22:23:23 +08:00
|
|
|
; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-NEXT: ret i32 [[COND1]]
|
|
|
|
;
|
2014-06-12 22:06:00 +08:00
|
|
|
%cmp = icmp sgt i32 %x, 0
|
|
|
|
%sub = sub nsw i32 0, %x
|
|
|
|
%cond = select i1 %cmp, i32 %sub, i32 %x
|
|
|
|
%cmp1 = icmp sgt i32 %cond, 0
|
|
|
|
%sub16 = sub nsw i32 0, %cond
|
|
|
|
%cond18 = select i1 %cmp1, i32 %cond, i32 %sub16
|
|
|
|
ret i32 %cond18
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @abs_nabs_x07(i32 %x) {
|
2018-05-18 23:22:19 +08:00
|
|
|
; 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]]
|
|
|
|
;
|
2014-06-12 22:06:00 +08:00
|
|
|
%cmp = icmp slt i32 %x, 0
|
|
|
|
%sub = sub nsw i32 0, %x
|
|
|
|
%cond = select i1 %cmp, i32 %x, i32 %sub
|
|
|
|
%cmp1 = icmp sgt i32 %cond, 0
|
|
|
|
%sub16 = sub nsw i32 0, %cond
|
|
|
|
%cond18 = select i1 %cmp1, i32 %cond, i32 %sub16
|
|
|
|
ret i32 %cond18
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @abs_nabs_x08(i32 %x) {
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-LABEL: @abs_nabs_x08(
|
2018-05-20 22:23:23 +08:00
|
|
|
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
|
|
|
; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
|
|
|
|
; CHECK-NEXT: ret i32 [[COND1]]
|
|
|
|
;
|
2014-06-12 22:06:00 +08:00
|
|
|
%cmp = icmp slt i32 %x, 1
|
|
|
|
%sub = sub nsw i32 0, %x
|
|
|
|
%cond = select i1 %cmp, i32 %x, i32 %sub
|
|
|
|
%cmp1 = icmp sgt i32 %cond, 0
|
|
|
|
%sub16 = sub nsw i32 0, %cond
|
|
|
|
%cond18 = select i1 %cmp1, i32 %cond, i32 %sub16
|
|
|
|
ret i32 %cond18
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @abs_nabs_x09(i32 %x) {
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-LABEL: @abs_nabs_x09(
|
2018-05-20 22:23:23 +08:00
|
|
|
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
2018-05-20 22:23:23 +08:00
|
|
|
; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-NEXT: ret i32 [[COND1]]
|
|
|
|
;
|
2014-06-12 22:06:00 +08:00
|
|
|
%cmp = icmp sgt i32 %x, -1
|
|
|
|
%sub = sub nsw i32 0, %x
|
|
|
|
%cond = select i1 %cmp, i32 %sub, i32 %x
|
|
|
|
%cmp1 = icmp slt i32 %cond, 0
|
|
|
|
%sub9 = sub nsw i32 0, %cond
|
|
|
|
%cond18 = select i1 %cmp1, i32 %sub9, i32 %cond
|
|
|
|
ret i32 %cond18
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @abs_nabs_x10(i32 %x) {
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-LABEL: @abs_nabs_x10(
|
2018-05-20 22:23:23 +08:00
|
|
|
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
2018-05-20 22:23:23 +08:00
|
|
|
; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-NEXT: ret i32 [[COND1]]
|
|
|
|
;
|
2014-06-12 22:06:00 +08:00
|
|
|
%cmp = icmp sgt i32 %x, 0
|
|
|
|
%sub = sub nsw i32 0, %x
|
|
|
|
%cond = select i1 %cmp, i32 %sub, i32 %x
|
|
|
|
%cmp1 = icmp slt i32 %cond, 0
|
|
|
|
%sub9 = sub nsw i32 0, %cond
|
|
|
|
%cond18 = select i1 %cmp1, i32 %sub9, i32 %cond
|
|
|
|
ret i32 %cond18
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @abs_nabs_x11(i32 %x) {
|
2018-05-18 23:22:19 +08:00
|
|
|
; 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]]
|
|
|
|
;
|
2014-06-12 22:06:00 +08:00
|
|
|
%cmp = icmp slt i32 %x, 0
|
|
|
|
%sub = sub nsw i32 0, %x
|
|
|
|
%cond = select i1 %cmp, i32 %x, i32 %sub
|
|
|
|
%cmp1 = icmp slt i32 %cond, 0
|
|
|
|
%sub9 = sub nsw i32 0, %cond
|
|
|
|
%cond18 = select i1 %cmp1, i32 %sub9, i32 %cond
|
|
|
|
ret i32 %cond18
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @abs_nabs_x12(i32 %x) {
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-LABEL: @abs_nabs_x12(
|
2018-05-20 22:23:23 +08:00
|
|
|
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
|
|
|
; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
|
|
|
|
; CHECK-NEXT: ret i32 [[COND1]]
|
|
|
|
;
|
2014-06-12 22:06:00 +08:00
|
|
|
%cmp = icmp slt i32 %x, 1
|
|
|
|
%sub = sub nsw i32 0, %x
|
|
|
|
%cond = select i1 %cmp, i32 %x, i32 %sub
|
|
|
|
%cmp1 = icmp slt i32 %cond, 0
|
|
|
|
%sub9 = sub nsw i32 0, %cond
|
|
|
|
%cond18 = select i1 %cmp1, i32 %sub9, i32 %cond
|
|
|
|
ret i32 %cond18
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @abs_nabs_x13(i32 %x) {
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-LABEL: @abs_nabs_x13(
|
2018-05-20 22:23:23 +08:00
|
|
|
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
2018-05-20 22:23:23 +08:00
|
|
|
; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-NEXT: ret i32 [[COND1]]
|
|
|
|
;
|
2014-06-12 22:06:00 +08:00
|
|
|
%cmp = icmp sgt i32 %x, -1
|
|
|
|
%sub = sub nsw i32 0, %x
|
|
|
|
%cond = select i1 %cmp, i32 %sub, i32 %x
|
|
|
|
%cmp1 = icmp slt i32 %cond, 1
|
|
|
|
%sub9 = sub nsw i32 0, %cond
|
|
|
|
%cond18 = select i1 %cmp1, i32 %sub9, i32 %cond
|
|
|
|
ret i32 %cond18
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @abs_nabs_x14(i32 %x) {
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-LABEL: @abs_nabs_x14(
|
2018-05-20 22:23:23 +08:00
|
|
|
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
2018-05-20 22:23:23 +08:00
|
|
|
; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-NEXT: ret i32 [[COND1]]
|
|
|
|
;
|
2014-06-12 22:06:00 +08:00
|
|
|
%cmp = icmp sgt i32 %x, 0
|
|
|
|
%sub = sub nsw i32 0, %x
|
|
|
|
%cond = select i1 %cmp, i32 %sub, i32 %x
|
|
|
|
%cmp1 = icmp slt i32 %cond, 1
|
|
|
|
%sub9 = sub nsw i32 0, %cond
|
|
|
|
%cond18 = select i1 %cmp1, i32 %sub9, i32 %cond
|
|
|
|
ret i32 %cond18
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @abs_nabs_x15(i32 %x) {
|
2018-05-18 23:22:19 +08:00
|
|
|
; 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]]
|
|
|
|
;
|
2014-06-12 22:06:00 +08:00
|
|
|
%cmp = icmp slt i32 %x, 0
|
|
|
|
%sub = sub nsw i32 0, %x
|
|
|
|
%cond = select i1 %cmp, i32 %x, i32 %sub
|
|
|
|
%cmp1 = icmp slt i32 %cond, 1
|
|
|
|
%sub9 = sub nsw i32 0, %cond
|
|
|
|
%cond18 = select i1 %cmp1, i32 %sub9, i32 %cond
|
|
|
|
ret i32 %cond18
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @abs_nabs_x16(i32 %x) {
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-LABEL: @abs_nabs_x16(
|
2018-05-20 22:23:23 +08:00
|
|
|
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
|
|
|
; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
|
|
|
|
; CHECK-NEXT: ret i32 [[COND1]]
|
|
|
|
;
|
2014-06-12 22:06:00 +08:00
|
|
|
%cmp = icmp slt i32 %x, 1
|
|
|
|
%sub = sub nsw i32 0, %x
|
|
|
|
%cond = select i1 %cmp, i32 %x, i32 %sub
|
|
|
|
%cmp1 = icmp slt i32 %cond, 1
|
|
|
|
%sub9 = sub nsw i32 0, %cond
|
|
|
|
%cond18 = select i1 %cmp1, i32 %sub9, i32 %cond
|
|
|
|
ret i32 %cond18
|
|
|
|
}
|
|
|
|
|
2018-07-27 09:49:51 +08:00
|
|
|
; abs(nabs(-x)) -> abs(-x) -> abs(x)
|
2018-07-12 21:28:20 +08:00
|
|
|
define i32 @abs_nabs_x17(i32 %x) {
|
|
|
|
; CHECK-LABEL: @abs_nabs_x17(
|
|
|
|
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X:%.*]]
|
2018-07-27 09:49:51 +08:00
|
|
|
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X]], 0
|
2018-07-12 21:28:20 +08:00
|
|
|
; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[SUB]], i32 [[X]]
|
2018-07-16 10:23:00 +08:00
|
|
|
; CHECK-NEXT: ret i32 [[COND]]
|
2018-07-12 21:28:20 +08:00
|
|
|
;
|
|
|
|
%sub = sub nsw i32 0, %x
|
|
|
|
%cmp = icmp sgt i32 %sub, -1
|
|
|
|
%cond = select i1 %cmp, i32 %x, i32 %sub
|
|
|
|
%cmp1 = icmp sgt i32 %cond, -1
|
|
|
|
%sub16 = sub nsw i32 0, %cond
|
|
|
|
%cond18 = select i1 %cmp1, i32 %cond, i32 %sub16
|
|
|
|
ret i32 %cond18
|
|
|
|
}
|
|
|
|
|
|
|
|
; abs(nabs(x - y)) -> abs(x - y)
|
|
|
|
define i32 @abs_nabs_x18(i32 %x, i32 %y) {
|
|
|
|
; CHECK-LABEL: @abs_nabs_x18(
|
|
|
|
; CHECK-NEXT: [[A:%.*]] = sub nsw i32 [[X:%.*]], [[Y:%.*]]
|
2018-07-27 09:49:51 +08:00
|
|
|
; 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]]
|
2018-07-16 10:23:00 +08:00
|
|
|
; CHECK-NEXT: ret i32 [[COND]]
|
2018-07-12 21:28:20 +08:00
|
|
|
;
|
|
|
|
%a = sub nsw i32 %x, %y
|
|
|
|
%b = sub nsw i32 %y, %x
|
|
|
|
%cmp = icmp sgt i32 %a, -1
|
|
|
|
%cond = select i1 %cmp, i32 %b, i32 %a
|
|
|
|
%cmp1 = icmp sgt i32 %cond, -1
|
|
|
|
%sub16 = sub nsw i32 0, %cond
|
|
|
|
%cond18 = select i1 %cmp1, i32 %cond, i32 %sub16
|
|
|
|
ret i32 %cond18
|
|
|
|
}
|
|
|
|
|
2018-07-27 09:49:51 +08:00
|
|
|
; abs(nabs(-x)) -> abs(-x) -> abs(x)
|
2018-07-12 21:28:20 +08:00
|
|
|
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:%.*]]
|
2018-07-27 09:49:51 +08:00
|
|
|
; CHECK-NEXT: [[CMP:%.*]] = icmp slt <2 x i32> [[X]], zeroinitializer
|
2018-07-16 08:51:40 +08:00
|
|
|
; CHECK-NEXT: [[COND:%.*]] = select <2 x i1> [[CMP]], <2 x i32> [[SUB]], <2 x i32> [[X]]
|
|
|
|
; CHECK-NEXT: ret <2 x i32> [[COND]]
|
2018-07-12 21:28:20 +08:00
|
|
|
;
|
|
|
|
%sub = sub nsw <2 x i32> zeroinitializer, %x
|
|
|
|
%cmp = icmp sgt <2 x i32> %sub, <i32 -1, i32 -1>
|
|
|
|
%cond = select <2 x i1> %cmp, <2 x i32> %x, <2 x i32> %sub
|
|
|
|
%cmp1 = icmp sgt <2 x i32> %cond, <i32 -1, i32 -1>
|
|
|
|
%sub16 = sub nsw <2 x i32> zeroinitializer, %cond
|
|
|
|
%cond18 = select <2 x i1> %cmp1, <2 x i32> %cond, <2 x i32> %sub16
|
|
|
|
ret <2 x i32> %cond18
|
|
|
|
}
|
|
|
|
|
|
|
|
; abs(nabs(x - y)) -> abs(x - y)
|
|
|
|
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:%.*]]
|
2018-07-27 09:49:51 +08:00
|
|
|
; 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]]
|
2018-07-16 10:23:00 +08:00
|
|
|
; CHECK-NEXT: ret <2 x i32> [[COND]]
|
2018-07-12 21:28:20 +08:00
|
|
|
;
|
|
|
|
%a = sub nsw <2 x i32> %x, %y
|
|
|
|
%b = sub nsw <2 x i32> %y, %x
|
|
|
|
%cmp = icmp sgt <2 x i32> %a, <i32 -1, i32 -1>
|
|
|
|
%cond = select <2 x i1> %cmp, <2 x i32> %b, <2 x i32> %a
|
|
|
|
%cmp1 = icmp sgt <2 x i32> %cond, <i32 -1, i32 -1>
|
|
|
|
%sub16 = sub nsw <2 x i32> zeroinitializer, %cond
|
|
|
|
%cond18 = select <2 x i1> %cmp1, <2 x i32> %cond, <2 x i32> %sub16
|
|
|
|
ret <2 x i32> %cond18
|
|
|
|
}
|
|
|
|
|
2014-06-12 22:06:00 +08:00
|
|
|
define i32 @nabs_abs_x01(i32 %x) {
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-LABEL: @nabs_abs_x01(
|
2018-05-20 22:23:23 +08:00
|
|
|
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
2018-05-20 22:23:23 +08:00
|
|
|
; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-NEXT: ret i32 [[COND1]]
|
|
|
|
;
|
2014-06-12 22:06:00 +08:00
|
|
|
%cmp = icmp sgt i32 %x, -1
|
|
|
|
%sub = sub nsw i32 0, %x
|
|
|
|
%cond = select i1 %cmp, i32 %x, i32 %sub
|
|
|
|
%cmp1 = icmp sgt i32 %cond, -1
|
|
|
|
%sub9 = sub nsw i32 0, %cond
|
|
|
|
%cond18 = select i1 %cmp1, i32 %sub9, i32 %cond
|
|
|
|
ret i32 %cond18
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @nabs_abs_x02(i32 %x) {
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-LABEL: @nabs_abs_x02(
|
2018-05-20 22:23:23 +08:00
|
|
|
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
2018-05-20 22:23:23 +08:00
|
|
|
; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-NEXT: ret i32 [[COND1]]
|
|
|
|
;
|
2014-06-12 22:06:00 +08:00
|
|
|
%cmp = icmp sgt i32 %x, 0
|
|
|
|
%sub = sub nsw i32 0, %x
|
|
|
|
%cond = select i1 %cmp, i32 %x, i32 %sub
|
|
|
|
%cmp1 = icmp sgt i32 %cond, -1
|
|
|
|
%sub9 = sub nsw i32 0, %cond
|
|
|
|
%cond18 = select i1 %cmp1, i32 %sub9, i32 %cond
|
|
|
|
ret i32 %cond18
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @nabs_abs_x03(i32 %x) {
|
2018-05-18 23:22:19 +08:00
|
|
|
; 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]]
|
|
|
|
;
|
2014-06-12 22:06:00 +08:00
|
|
|
%cmp = icmp slt i32 %x, 0
|
|
|
|
%sub = sub nsw i32 0, %x
|
|
|
|
%cond = select i1 %cmp, i32 %sub, i32 %x
|
|
|
|
%cmp1 = icmp sgt i32 %cond, -1
|
|
|
|
%sub9 = sub nsw i32 0, %cond
|
|
|
|
%cond18 = select i1 %cmp1, i32 %sub9, i32 %cond
|
|
|
|
ret i32 %cond18
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @nabs_abs_x04(i32 %x) {
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-LABEL: @nabs_abs_x04(
|
2018-05-20 22:23:23 +08:00
|
|
|
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
|
|
|
; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
|
|
|
|
; CHECK-NEXT: ret i32 [[COND1]]
|
|
|
|
;
|
2014-06-12 22:06:00 +08:00
|
|
|
%cmp = icmp slt i32 %x, 1
|
|
|
|
%sub = sub nsw i32 0, %x
|
|
|
|
%cond = select i1 %cmp, i32 %sub, i32 %x
|
|
|
|
%cmp1 = icmp sgt i32 %cond, -1
|
|
|
|
%sub9 = sub nsw i32 0, %cond
|
|
|
|
%cond18 = select i1 %cmp1, i32 %sub9, i32 %cond
|
|
|
|
ret i32 %cond18
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @nabs_abs_x05(i32 %x) {
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-LABEL: @nabs_abs_x05(
|
2018-05-20 22:23:23 +08:00
|
|
|
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
2018-05-20 22:23:23 +08:00
|
|
|
; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-NEXT: ret i32 [[COND1]]
|
|
|
|
;
|
2014-06-12 22:06:00 +08:00
|
|
|
%cmp = icmp sgt i32 %x, -1
|
|
|
|
%sub = sub nsw i32 0, %x
|
|
|
|
%cond = select i1 %cmp, i32 %x, i32 %sub
|
|
|
|
%cmp1 = icmp sgt i32 %cond, 0
|
|
|
|
%sub9 = sub nsw i32 0, %cond
|
|
|
|
%cond18 = select i1 %cmp1, i32 %sub9, i32 %cond
|
|
|
|
ret i32 %cond18
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @nabs_abs_x06(i32 %x) {
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-LABEL: @nabs_abs_x06(
|
2018-05-20 22:23:23 +08:00
|
|
|
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
2018-05-20 22:23:23 +08:00
|
|
|
; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-NEXT: ret i32 [[COND1]]
|
|
|
|
;
|
2014-06-12 22:06:00 +08:00
|
|
|
%cmp = icmp sgt i32 %x, 0
|
|
|
|
%sub = sub nsw i32 0, %x
|
|
|
|
%cond = select i1 %cmp, i32 %x, i32 %sub
|
|
|
|
%cmp1 = icmp sgt i32 %cond, 0
|
|
|
|
%sub9 = sub nsw i32 0, %cond
|
|
|
|
%cond18 = select i1 %cmp1, i32 %sub9, i32 %cond
|
|
|
|
ret i32 %cond18
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @nabs_abs_x07(i32 %x) {
|
2018-05-18 23:22:19 +08:00
|
|
|
; 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]]
|
|
|
|
;
|
2014-06-12 22:06:00 +08:00
|
|
|
%cmp = icmp slt i32 %x, 0
|
|
|
|
%sub = sub nsw i32 0, %x
|
|
|
|
%cond = select i1 %cmp, i32 %sub, i32 %x
|
|
|
|
%cmp1 = icmp sgt i32 %cond, 0
|
|
|
|
%sub9 = sub nsw i32 0, %cond
|
|
|
|
%cond18 = select i1 %cmp1, i32 %sub9, i32 %cond
|
|
|
|
ret i32 %cond18
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @nabs_abs_x08(i32 %x) {
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-LABEL: @nabs_abs_x08(
|
2018-05-20 22:23:23 +08:00
|
|
|
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
|
|
|
; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
|
|
|
|
; CHECK-NEXT: ret i32 [[COND1]]
|
|
|
|
;
|
2014-06-12 22:06:00 +08:00
|
|
|
%cmp = icmp slt i32 %x, 1
|
|
|
|
%sub = sub nsw i32 0, %x
|
|
|
|
%cond = select i1 %cmp, i32 %sub, i32 %x
|
|
|
|
%cmp1 = icmp sgt i32 %cond, 0
|
|
|
|
%sub9 = sub nsw i32 0, %cond
|
|
|
|
%cond18 = select i1 %cmp1, i32 %sub9, i32 %cond
|
|
|
|
ret i32 %cond18
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @nabs_abs_x09(i32 %x) {
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-LABEL: @nabs_abs_x09(
|
2018-05-20 22:23:23 +08:00
|
|
|
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
2018-05-26 03:18:09 +08:00
|
|
|
; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
|
|
|
|
; CHECK-NEXT: ret i32 [[COND]]
|
2018-05-18 23:22:19 +08:00
|
|
|
;
|
2014-06-12 22:06:00 +08:00
|
|
|
%cmp = icmp sgt i32 %x, -1
|
|
|
|
%sub = sub nsw i32 0, %x
|
|
|
|
%cond = select i1 %cmp, i32 %x, i32 %sub
|
|
|
|
%cmp1 = icmp slt i32 %cond, 0
|
|
|
|
%sub16 = sub nsw i32 0, %cond
|
|
|
|
%cond18 = select i1 %cmp1, i32 %cond, i32 %sub16
|
|
|
|
ret i32 %cond18
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @nabs_abs_x10(i32 %x) {
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-LABEL: @nabs_abs_x10(
|
2018-05-20 22:23:23 +08:00
|
|
|
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
2018-05-26 03:18:09 +08:00
|
|
|
; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
|
|
|
|
; CHECK-NEXT: ret i32 [[COND]]
|
2018-05-18 23:22:19 +08:00
|
|
|
;
|
2014-06-12 22:06:00 +08:00
|
|
|
%cmp = icmp sgt i32 %x, 0
|
|
|
|
%sub = sub nsw i32 0, %x
|
|
|
|
%cond = select i1 %cmp, i32 %x, i32 %sub
|
|
|
|
%cmp1 = icmp slt i32 %cond, 0
|
|
|
|
%sub16 = sub nsw i32 0, %cond
|
|
|
|
%cond18 = select i1 %cmp1, i32 %cond, i32 %sub16
|
|
|
|
ret i32 %cond18
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @nabs_abs_x11(i32 %x) {
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-LABEL: @nabs_abs_x11(
|
|
|
|
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
|
|
|
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
2018-05-26 03:18:09 +08:00
|
|
|
; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
|
|
|
|
; CHECK-NEXT: ret i32 [[COND]]
|
2018-05-18 23:22:19 +08:00
|
|
|
;
|
2014-06-12 22:06:00 +08:00
|
|
|
%cmp = icmp slt i32 %x, 0
|
|
|
|
%sub = sub nsw i32 0, %x
|
|
|
|
%cond = select i1 %cmp, i32 %sub, i32 %x
|
|
|
|
%cmp1 = icmp slt i32 %cond, 0
|
|
|
|
%sub16 = sub nsw i32 0, %cond
|
|
|
|
%cond18 = select i1 %cmp1, i32 %cond, i32 %sub16
|
|
|
|
ret i32 %cond18
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @nabs_abs_x12(i32 %x) {
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-LABEL: @nabs_abs_x12(
|
2018-05-20 22:23:23 +08:00
|
|
|
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
2018-05-26 03:18:09 +08:00
|
|
|
; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
|
|
|
|
; CHECK-NEXT: ret i32 [[COND]]
|
2018-05-18 23:22:19 +08:00
|
|
|
;
|
2014-06-12 22:06:00 +08:00
|
|
|
%cmp = icmp slt i32 %x, 1
|
|
|
|
%sub = sub nsw i32 0, %x
|
|
|
|
%cond = select i1 %cmp, i32 %sub, i32 %x
|
|
|
|
%cmp1 = icmp slt i32 %cond, 0
|
|
|
|
%sub16 = sub nsw i32 0, %cond
|
|
|
|
%cond18 = select i1 %cmp1, i32 %cond, i32 %sub16
|
|
|
|
ret i32 %cond18
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @nabs_abs_x13(i32 %x) {
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-LABEL: @nabs_abs_x13(
|
2018-05-20 22:23:23 +08:00
|
|
|
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
2018-05-20 22:23:23 +08:00
|
|
|
; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-NEXT: ret i32 [[COND1]]
|
|
|
|
;
|
2014-06-12 22:06:00 +08:00
|
|
|
%cmp = icmp sgt i32 %x, -1
|
|
|
|
%sub = sub nsw i32 0, %x
|
|
|
|
%cond = select i1 %cmp, i32 %x, i32 %sub
|
|
|
|
%cmp1 = icmp slt i32 %cond, 1
|
|
|
|
%sub16 = sub nsw i32 0, %cond
|
|
|
|
%cond18 = select i1 %cmp1, i32 %cond, i32 %sub16
|
|
|
|
ret i32 %cond18
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @nabs_abs_x14(i32 %x) {
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-LABEL: @nabs_abs_x14(
|
2018-05-20 22:23:23 +08:00
|
|
|
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
2018-05-20 22:23:23 +08:00
|
|
|
; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-NEXT: ret i32 [[COND1]]
|
|
|
|
;
|
2014-06-12 22:06:00 +08:00
|
|
|
%cmp = icmp sgt i32 %x, 0
|
|
|
|
%sub = sub nsw i32 0, %x
|
|
|
|
%cond = select i1 %cmp, i32 %x, i32 %sub
|
|
|
|
%cmp1 = icmp slt i32 %cond, 1
|
|
|
|
%sub16 = sub nsw i32 0, %cond
|
|
|
|
%cond18 = select i1 %cmp1, i32 %cond, i32 %sub16
|
|
|
|
ret i32 %cond18
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @nabs_abs_x15(i32 %x) {
|
2018-05-18 23:22:19 +08:00
|
|
|
; 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]]
|
|
|
|
;
|
2014-06-12 22:06:00 +08:00
|
|
|
%cmp = icmp slt i32 %x, 0
|
|
|
|
%sub = sub nsw i32 0, %x
|
|
|
|
%cond = select i1 %cmp, i32 %sub, i32 %x
|
|
|
|
%cmp1 = icmp slt i32 %cond, 1
|
|
|
|
%sub16 = sub nsw i32 0, %cond
|
|
|
|
%cond18 = select i1 %cmp1, i32 %cond, i32 %sub16
|
|
|
|
ret i32 %cond18
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @nabs_abs_x16(i32 %x) {
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-LABEL: @nabs_abs_x16(
|
2018-05-20 22:23:23 +08:00
|
|
|
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
|
2018-05-18 23:22:19 +08:00
|
|
|
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X]]
|
|
|
|
; CHECK-NEXT: [[COND1:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
|
|
|
|
; CHECK-NEXT: ret i32 [[COND1]]
|
|
|
|
;
|
2014-06-12 22:06:00 +08:00
|
|
|
%cmp = icmp slt i32 %x, 1
|
|
|
|
%sub = sub nsw i32 0, %x
|
|
|
|
%cond = select i1 %cmp, i32 %sub, i32 %x
|
|
|
|
%cmp1 = icmp slt i32 %cond, 1
|
|
|
|
%sub16 = sub nsw i32 0, %cond
|
|
|
|
%cond18 = select i1 %cmp1, i32 %cond, i32 %sub16
|
|
|
|
ret i32 %cond18
|
2016-10-27 23:02:45 +08:00
|
|
|
}
|
2018-05-18 23:22:19 +08:00
|
|
|
|
2018-07-27 09:49:51 +08:00
|
|
|
; nabs(abs(-x)) -> nabs(-x) -> nabs(x)
|
2018-07-12 21:28:20 +08:00
|
|
|
define i32 @nabs_abs_x17(i32 %x) {
|
|
|
|
; CHECK-LABEL: @nabs_abs_x17(
|
|
|
|
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 0, [[X:%.*]]
|
2018-07-27 09:49:51 +08:00
|
|
|
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X]], 0
|
2018-07-12 21:28:20 +08:00
|
|
|
; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[SUB]]
|
2018-07-16 10:23:00 +08:00
|
|
|
; CHECK-NEXT: ret i32 [[COND]]
|
2018-07-12 21:28:20 +08:00
|
|
|
;
|
|
|
|
%sub = sub nsw i32 0, %x
|
|
|
|
%cmp = icmp sgt i32 %sub, -1
|
|
|
|
%cond = select i1 %cmp, i32 %sub, i32 %x
|
|
|
|
%cmp1 = icmp sgt i32 %cond, -1
|
|
|
|
%sub16 = sub nsw i32 0, %cond
|
|
|
|
%cond18 = select i1 %cmp1, i32 %sub16, i32 %cond
|
|
|
|
ret i32 %cond18
|
|
|
|
}
|
|
|
|
|
|
|
|
; nabs(abs(x - y)) -> nabs(x - y)
|
|
|
|
define i32 @nabs_abs_x18(i32 %x, i32 %y) {
|
|
|
|
; CHECK-LABEL: @nabs_abs_x18(
|
|
|
|
; CHECK-NEXT: [[A:%.*]] = sub nsw i32 [[X:%.*]], [[Y:%.*]]
|
2018-07-27 09:49:51 +08:00
|
|
|
; 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]]
|
2018-07-16 10:23:00 +08:00
|
|
|
; CHECK-NEXT: ret i32 [[COND]]
|
2018-07-12 21:28:20 +08:00
|
|
|
;
|
|
|
|
%a = sub nsw i32 %x, %y
|
|
|
|
%b = sub nsw i32 %y, %x
|
|
|
|
%cmp = icmp sgt i32 %a, -1
|
|
|
|
%cond = select i1 %cmp, i32 %a, i32 %b
|
|
|
|
%cmp1 = icmp sgt i32 %cond, -1
|
|
|
|
%sub16 = sub nsw i32 0, %cond
|
|
|
|
%cond18 = select i1 %cmp1, i32 %sub16, i32 %cond
|
|
|
|
ret i32 %cond18
|
|
|
|
}
|
|
|
|
|
2018-07-27 09:49:51 +08:00
|
|
|
; nabs(abs(-x)) -> nabs(-x) -> nabs(x)
|
2018-07-12 21:28:20 +08:00
|
|
|
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:%.*]]
|
2018-07-27 09:49:51 +08:00
|
|
|
; CHECK-NEXT: [[CMP:%.*]] = icmp slt <2 x i32> [[X]], zeroinitializer
|
2018-07-16 08:51:40 +08:00
|
|
|
; CHECK-NEXT: [[COND:%.*]] = select <2 x i1> [[CMP]], <2 x i32> [[X]], <2 x i32> [[SUB]]
|
|
|
|
; CHECK-NEXT: ret <2 x i32> [[COND]]
|
2018-07-12 21:28:20 +08:00
|
|
|
;
|
|
|
|
%sub = sub nsw <2 x i32> zeroinitializer, %x
|
|
|
|
%cmp = icmp sgt <2 x i32> %sub, <i32 -1, i32 -1>
|
|
|
|
%cond = select <2 x i1> %cmp, <2 x i32> %sub, <2 x i32> %x
|
|
|
|
%cmp1 = icmp sgt <2 x i32> %cond, <i32 -1, i32 -1>
|
|
|
|
%sub16 = sub nsw <2 x i32> zeroinitializer, %cond
|
|
|
|
%cond18 = select <2 x i1> %cmp1, <2 x i32> %sub16, <2 x i32> %cond
|
|
|
|
ret <2 x i32> %cond18
|
|
|
|
}
|
|
|
|
|
|
|
|
; nabs(abs(x - y)) -> nabs(x - y)
|
|
|
|
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:%.*]]
|
2018-07-27 09:49:51 +08:00
|
|
|
; 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]]
|
2018-07-16 10:23:00 +08:00
|
|
|
; CHECK-NEXT: ret <2 x i32> [[COND]]
|
2018-07-12 21:28:20 +08:00
|
|
|
;
|
|
|
|
%a = sub nsw <2 x i32> %x, %y
|
|
|
|
%b = sub nsw <2 x i32> %y, %x
|
|
|
|
%cmp = icmp sgt <2 x i32> %a, <i32 -1, i32 -1>
|
|
|
|
%cond = select <2 x i1> %cmp, <2 x i32> %a, <2 x i32> %b
|
|
|
|
%cmp1 = icmp sgt <2 x i32> %cond, <i32 -1, i32 -1>
|
|
|
|
%sub16 = sub nsw <2 x i32> zeroinitializer, %cond
|
|
|
|
%cond18 = select <2 x i1> %cmp1, <2 x i32> %sub16, <2 x i32> %cond
|
|
|
|
ret <2 x i32> %cond18
|
|
|
|
}
|