Index: llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp =================================================================== --- llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp +++ llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp @@ -3709,6 +3709,14 @@ Value *InvMaxMin = Builder.CreateBinaryIntrinsic(InvID, X, NotY); return replaceInstUsesWith(I, InvMaxMin); } + + if (II->getIntrinsicID() == Intrinsic::is_fpclass) { + ConstantInt *ClassMask = cast(II->getArgOperand(1)); + II->setArgOperand( + 1, ConstantInt::get(ClassMask->getType(), + ~ClassMask->getZExtValue() & fcAllFlags)); + return replaceInstUsesWith(I, II); + } } if (NotOp->hasOneUse()) { Index: llvm/test/Transforms/InstCombine/is_fpclass.ll =================================================================== --- llvm/test/Transforms/InstCombine/is_fpclass.ll +++ llvm/test/Transforms/InstCombine/is_fpclass.ll @@ -417,9 +417,8 @@ define i1 @test_class_not_is_inf_nan(float %x) { ; CHECK-LABEL: @test_class_not_is_inf_nan( -; CHECK-NEXT: [[CLASS:%.*]] = call i1 @llvm.is.fpclass.f32(float [[X:%.*]], i32 519) -; CHECK-NEXT: [[NOT:%.*]] = xor i1 [[CLASS]], true -; CHECK-NEXT: ret i1 [[NOT]] +; CHECK-NEXT: [[CLASS:%.*]] = call i1 @llvm.is.fpclass.f32(float [[X:%.*]], i32 504) +; CHECK-NEXT: ret i1 [[CLASS]] ; %class = call i1 @llvm.is.fpclass.f32(float %x, i32 519) %not = xor i1 %class, true @@ -428,9 +427,8 @@ define i1 @test_class_not_is_normal(float %x) { ; CHECK-LABEL: @test_class_not_is_normal( -; CHECK-NEXT: [[CLASS:%.*]] = call i1 @llvm.is.fpclass.f32(float [[X:%.*]], i32 264) -; CHECK-NEXT: [[NOT:%.*]] = xor i1 [[CLASS]], true -; CHECK-NEXT: ret i1 [[NOT]] +; CHECK-NEXT: [[CLASS:%.*]] = call i1 @llvm.is.fpclass.f32(float [[X:%.*]], i32 759) +; CHECK-NEXT: ret i1 [[CLASS]] ; %class = call i1 @llvm.is.fpclass.f32(float %x, i32 264) %not = xor i1 %class, true @@ -449,9 +447,8 @@ define <2 x i1> @test_class_not_vector(<2 x float> %x) { ; CHECK-LABEL: @test_class_not_vector( -; CHECK-NEXT: [[CLASS:%.*]] = call <2 x i1> @llvm.is.fpclass.v2f32(<2 x float> [[X:%.*]], i32 33) -; CHECK-NEXT: [[NOT:%.*]] = xor <2 x i1> [[CLASS]], -; CHECK-NEXT: ret <2 x i1> [[NOT]] +; CHECK-NEXT: [[CLASS:%.*]] = call <2 x i1> @llvm.is.fpclass.v2f32(<2 x float> [[X:%.*]], i32 990) +; CHECK-NEXT: ret <2 x i1> [[CLASS]] ; %class = call <2 x i1> @llvm.is.fpclass.v2f32(<2 x float> %x, i32 33) %not = xor <2 x i1> %class,