Skip to content

Commit a7a9233

Browse files
committed
[ValueTracking] Add additional tests. NFC.
1 parent 6f5ac74 commit a7a9233

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

llvm/test/Transforms/InstCombine/known-bits.ll

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1384,6 +1384,29 @@ define i1 @test_sign_pos(float %x) {
13841384
ret i1 %sign
13851385
}
13861386

1387+
define i1 @test_sign_pos_half(half %x) {
1388+
; CHECK-LABEL: @test_sign_pos_half(
1389+
; CHECK-NEXT: ret i1 true
1390+
;
1391+
%fabs = call half @llvm.fabs.f16(half %x)
1392+
%y = bitcast half %fabs to i16
1393+
%sign = icmp sgt i16 %y, -1
1394+
ret i1 %sign
1395+
}
1396+
1397+
define i1 @test_sign_pos_half_non_elementwise(<2 x half> %x) {
1398+
; CHECK-LABEL: @test_sign_pos_half_non_elementwise(
1399+
; CHECK-NEXT: [[FABS:%.*]] = call <2 x half> @llvm.fabs.v2f16(<2 x half> [[X:%.*]])
1400+
; CHECK-NEXT: [[Y:%.*]] = bitcast <2 x half> [[FABS]] to i32
1401+
; CHECK-NEXT: [[SIGN:%.*]] = icmp sgt i32 [[Y]], -1
1402+
; CHECK-NEXT: ret i1 [[SIGN]]
1403+
;
1404+
%fabs = call <2 x half> @llvm.fabs.v2f16(<2 x half> %x)
1405+
%y = bitcast <2 x half> %fabs to i32
1406+
%sign = icmp sgt i32 %y, -1
1407+
ret i1 %sign
1408+
}
1409+
13871410
define i1 @test_sign_neg(float %x) {
13881411
; CHECK-LABEL: @test_sign_neg(
13891412
; CHECK-NEXT: ret i1 true
@@ -1414,6 +1437,26 @@ define i32 @test_inf_only(float nofpclass(nan sub norm zero) %x) {
14141437
ret i32 %and
14151438
}
14161439

1440+
define i16 @test_inf_only_bfloat(bfloat nofpclass(nan sub norm zero) %x) {
1441+
; CHECK-LABEL: @test_inf_only_bfloat(
1442+
; CHECK-NEXT: ret i16 32512
1443+
;
1444+
%y = bitcast bfloat %x to i16
1445+
%and = and i16 %y, 32767
1446+
ret i16 %and
1447+
}
1448+
1449+
define i128 @test_inf_only_ppc_fp128(ppc_fp128 nofpclass(nan sub norm zero) %x) {
1450+
; CHECK-LABEL: @test_inf_only_ppc_fp128(
1451+
; CHECK-NEXT: [[Y:%.*]] = bitcast ppc_fp128 [[X:%.*]] to i128
1452+
; CHECK-NEXT: [[AND:%.*]] = and i128 [[Y]], 170141183460469231731687303715884105727
1453+
; CHECK-NEXT: ret i128 [[AND]]
1454+
;
1455+
%y = bitcast ppc_fp128 %x to i128
1456+
%and = and i128 %y, 170141183460469231731687303715884105727
1457+
ret i128 %and
1458+
}
1459+
14171460
define i32 @test_zero_only(float nofpclass(nan sub norm inf) %x) {
14181461
; CHECK-LABEL: @test_zero_only(
14191462
; CHECK-NEXT: ret i32 0

0 commit comments

Comments
 (0)