Skip to content

Commit 5939b6f

Browse files
committed
[ValueTracking] Add additional tests. NFC.
1 parent 5ca4885 commit 5939b6f

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
@@ -1205,6 +1205,29 @@ define i1 @test_sign_pos(float %x) {
12051205
ret i1 %sign
12061206
}
12071207

1208+
define i1 @test_sign_pos_half(half %x) {
1209+
; CHECK-LABEL: @test_sign_pos_half(
1210+
; CHECK-NEXT: ret i1 true
1211+
;
1212+
%fabs = call half @llvm.fabs.f16(half %x)
1213+
%y = bitcast half %fabs to i16
1214+
%sign = icmp sgt i16 %y, -1
1215+
ret i1 %sign
1216+
}
1217+
1218+
define i1 @test_sign_pos_half_non_elementwise(<2 x half> %x) {
1219+
; CHECK-LABEL: @test_sign_pos_half_non_elementwise(
1220+
; CHECK-NEXT: [[FABS:%.*]] = call <2 x half> @llvm.fabs.v2f16(<2 x half> [[X:%.*]])
1221+
; CHECK-NEXT: [[Y:%.*]] = bitcast <2 x half> [[FABS]] to i32
1222+
; CHECK-NEXT: [[SIGN:%.*]] = icmp sgt i32 [[Y]], -1
1223+
; CHECK-NEXT: ret i1 [[SIGN]]
1224+
;
1225+
%fabs = call <2 x half> @llvm.fabs.v2f16(<2 x half> %x)
1226+
%y = bitcast <2 x half> %fabs to i32
1227+
%sign = icmp sgt i32 %y, -1
1228+
ret i1 %sign
1229+
}
1230+
12081231
define i1 @test_sign_neg(float %x) {
12091232
; CHECK-LABEL: @test_sign_neg(
12101233
; CHECK-NEXT: ret i1 true
@@ -1235,6 +1258,26 @@ define i32 @test_inf_only(float nofpclass(nan sub norm zero) %x) {
12351258
ret i32 %and
12361259
}
12371260

1261+
define i16 @test_inf_only_bfloat(bfloat nofpclass(nan sub norm zero) %x) {
1262+
; CHECK-LABEL: @test_inf_only_bfloat(
1263+
; CHECK-NEXT: ret i16 32512
1264+
;
1265+
%y = bitcast bfloat %x to i16
1266+
%and = and i16 %y, 32767
1267+
ret i16 %and
1268+
}
1269+
1270+
define i128 @test_inf_only_ppc_fp128(ppc_fp128 nofpclass(nan sub norm zero) %x) {
1271+
; CHECK-LABEL: @test_inf_only_ppc_fp128(
1272+
; CHECK-NEXT: [[Y:%.*]] = bitcast ppc_fp128 [[X:%.*]] to i128
1273+
; CHECK-NEXT: [[AND:%.*]] = and i128 [[Y]], 170141183460469231731687303715884105727
1274+
; CHECK-NEXT: ret i128 [[AND]]
1275+
;
1276+
%y = bitcast ppc_fp128 %x to i128
1277+
%and = and i128 %y, 170141183460469231731687303715884105727
1278+
ret i128 %and
1279+
}
1280+
12381281
define i32 @test_zero_only(float nofpclass(nan sub norm inf) %x) {
12391282
; CHECK-LABEL: @test_zero_only(
12401283
; CHECK-NEXT: ret i32 0

0 commit comments

Comments
 (0)