[llvm] [ValueTracking] use KnownBits to compute fpclass from bitcast (PR #97762)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 4 21:06:53 PDT 2024


================
@@ -5805,6 +5805,36 @@ void computeKnownFPClass(const Value *V, const APInt &DemandedElts,
 
     break;
   }
+  case Instruction::BitCast: {
+    const Type *Ty = Op->getType();
+    const Value *Casted = Op->getOperand(0);
+    if (Ty->isVectorTy() || !Casted->getType()->isIntOrIntVectorTy())
+      break;
+
+    KnownBits Bits(Ty->getScalarSizeInBits());
+    computeKnownBits(Casted, Bits, Depth + 1, Q);
+
+    // Transfer information from the sign bit.
+    if (Bits.Zero.isSignBitSet())
+      Known.signBitMustBeZero();
+    else if (Bits.One.isSignBitSet())
----------------
dtcxzyw wrote:

```suggestion
    else if (Bits.isNegative())
```

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


More information about the llvm-commits mailing list