@@ -268,6 +268,21 @@ class FPMathOperator : public Operator {
268
268
SubclassOptionalData = FMF.Flags ;
269
269
}
270
270
271
+ // / Returns true if `Ty` is composed of a single kind of float-poing type
272
+ // / (possibly repeated within an aggregate).
273
+ static bool isComposedOfHomogeneousFloatingPointTypes (Type *Ty) {
274
+ if (auto *StructTy = dyn_cast<StructType>(Ty)) {
275
+ if (!StructTy->isLiteral () || !StructTy->containsHomogeneousTypes ())
276
+ return false ;
277
+ Ty = StructTy->elements ().front ();
278
+ } else if (auto *ArrayTy = dyn_cast<ArrayType>(Ty)) {
279
+ do {
280
+ Ty = ArrayTy->getElementType ();
281
+ } while ((ArrayTy = dyn_cast<ArrayType>(Ty)));
282
+ }
283
+ return Ty->isFPOrFPVectorTy ();
284
+ };
285
+
271
286
public:
272
287
// / Test if this operation allows all non-strict floating-point transforms.
273
288
bool isFast () const {
@@ -329,16 +344,8 @@ class FPMathOperator : public Operator {
329
344
// / Returns true if `Ty` is a supported floating-point type for phi, select,
330
345
// / or call FPMathOperators.
331
346
static bool isSupportedFloatingPointType (Type *Ty) {
332
- if (auto *StructTy = dyn_cast<StructType>(Ty)) {
333
- if (!StructTy->isLiteral () || !StructTy->containsHomogeneousTypes ())
334
- return false ;
335
- Ty = StructTy->elements ().front ();
336
- } else if (auto *ArrayTy = dyn_cast<ArrayType>(Ty)) {
337
- do {
338
- Ty = ArrayTy->getElementType ();
339
- } while ((ArrayTy = dyn_cast<ArrayType>(Ty)));
340
- }
341
- return Ty->isFPOrFPVectorTy ();
347
+ return Ty->isFPOrFPVectorTy () ||
348
+ isComposedOfHomogeneousFloatingPointTypes (Ty);
342
349
}
343
350
344
351
static bool classof (const Value *V) {
0 commit comments