assert(Depth <= MaxAnalysisRecursionDepth && "Limit Search Depth");
- const APFloat *C;
- if (match(V, m_APFloat(C))) {
- // We know all of the classes for a scalar constant or a splat vector
- // constant!
- Known.KnownFPClasses = C->classify();
- Known.SignBit = C->isNegative();
+ if (auto *CFP = dyn_cast_or_null<ConstantFP>(V)) {
+ Known.KnownFPClasses = CFP->getValueAPF().classify();
+ Known.SignBit = CFP->isNegative();
+ return;
+ }
+
+ // Try to handle fixed width vector constants
+ auto *VFVTy = dyn_cast<FixedVectorType>(V->getType());
+ const Constant *CV = dyn_cast<Constant>(V);
+ if (VFVTy && CV) {
+ Known.KnownFPClasses = fcNone;
+
+ // For vectors, verify that each element is not NaN.
+ unsigned NumElts = VFVTy->getNumElements();
+ for (unsigned i = 0; i != NumElts; ++i) {
+ Constant *Elt = CV->getAggregateElement(i);
+ if (!Elt) {
+ Known = KnownFPClass();
+ return;
+ }
+ if (isa<UndefValue>(Elt))
+ continue;
+ auto *CElt = dyn_cast<ConstantFP>(Elt);
+ if (!CElt) {
+ Known = KnownFPClass();
+ return;
+ }
+
+ KnownFPClass KnownElt{CElt->getValueAPF().classify(), CElt->isNegative()};
+ Known |= KnownElt;
+ }
+
return;
}
; Test a vector element that's an undef/poison
define <3 x double> @returned_undef_constant_vector_elt() {
-; CHECK-LABEL: define <3 x double> @returned_undef_constant_vector_elt() {
+; CHECK-LABEL: define nofpclass(nan inf pzero sub norm) <3 x double> @returned_undef_constant_vector_elt() {
; CHECK-NEXT: call void @unknown()
; CHECK-NEXT: ret <3 x double> <double -0.000000e+00, double poison, double undef>
;
}
define <2 x double> @returned_qnan_zero_vector() {
-; CHECK-LABEL: define noundef <2 x double> @returned_qnan_zero_vector() {
+; CHECK-LABEL: define noundef nofpclass(snan inf nzero sub norm) <2 x double> @returned_qnan_zero_vector() {
; CHECK-NEXT: call void @unknown()
; CHECK-NEXT: ret <2 x double> <double 0x7FF8000000000000, double 0.000000e+00>
;