[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();
+        if (Mask & (fcInf | fcZero)) {
+          if (Pred == ICmpInst::ICMP_NE)
+            Mask = ~Mask & fcAllFlags;
----------------
arsenm wrote:

You don't need the clamp to fcAllFlags, it implicitly happens with the bit mask enum type 

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


More information about the llvm-commits mailing list