[llvm] [InstCombine] Handle isnormal idiom (PR #125454)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Sun Feb 2 20:34:08 PST 2025
================
@@ -877,6 +877,162 @@ define i1 @isnan_idiom_ppc_fp128(ppc_fp128 %x) {
ret i1 %ret
}
+define i1 @fpclass_test_normal(float %num) {
+; CHECK-LABEL: define i1 @fpclass_test_normal(
+; CHECK-SAME: float [[NUM:%.*]]) {
+; CHECK-NEXT: [[RES:%.*]] = call i1 @llvm.is.fpclass.f32(float [[NUM]], i32 264)
+; CHECK-NEXT: ret i1 [[RES]]
+;
+ %cast = bitcast float %num to i32
+ %masked = and i32 %cast, 2139095040
+ %test1 = icmp ne i32 %masked, 2139095040
+ %test2 = icmp ne i32 %masked, 0
+ %res = and i1 %test1, %test2
+ ret i1 %res
+}
+
+define i1 @fpclass_test_normal_half(half %num) {
+; CHECK-LABEL: define i1 @fpclass_test_normal_half(
+; CHECK-SAME: half [[NUM:%.*]]) {
+; CHECK-NEXT: [[RES:%.*]] = call i1 @llvm.is.fpclass.f16(half [[NUM]], i32 264)
+; CHECK-NEXT: ret i1 [[RES]]
+;
+ %cast = bitcast half %num to i16
+ %masked = and i16 %cast, 31744
+ %test1 = icmp ne i16 %masked, 31744
+ %test2 = icmp ne i16 %masked, 0
+ %res = and i1 %test1, %test2
+ ret i1 %res
+}
+
+define <2 x i1> @fpclass_test_normal_half_vec(<2 x half> %num) {
----------------
arsenm wrote:
Missing test for negated form for vector?
https://github.com/llvm/llvm-project/pull/125454
More information about the llvm-commits
mailing list