[llvm] [InstCombine] Handle IsInf/IsZero idioms (PR #80607)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 5 01:47:46 PST 2024


================
@@ -3261,6 +3261,20 @@ Instruction *InstCombinerImpl::foldICmpBitCast(ICmpInst &Cmp) {
                                 ConstantInt::getAllOnesValue(NewType));
         }
       }
+
+      // icmp eq/ne (bitcast X to int), special fp -> llvm.is.fpclass(X, class)
+      Type *FPType = SrcType->getScalarType();
+      if (!Cmp.getParent()->getParent()->hasFnAttribute(
+              Attribute::NoImplicitFloat) &&
+          Cmp.isEquality() && FPType->isIEEELikeFPTy()) {
+        unsigned Mask = APFloat(FPType->getFltSemantics(), *C).classify();
----------------
arsenm wrote:

I believe classify returns the true FPClassTest, you don't need the implicit cast to unsigned

https://github.com/llvm/llvm-project/pull/80607


More information about the llvm-commits mailing list