GlobalISel: Fix maxScalarIf predicate check
authorMatt Arsenault <Matthew.Arsenault@amd.com>
Wed, 22 Jul 2020 13:26:11 +0000 (09:26 -0400)
committerMatt Arsenault <Matthew.Arsenault@amd.com>
Fri, 24 Jul 2020 01:17:10 +0000 (21:17 -0400)
The std::function itself was tested, not the result of the actual
query. It seems like there should be a warning for this. Inline the
check to avoid this.

llvm/include/llvm/CodeGen/GlobalISel/LegalizerInfo.h

index 7cf1fb0..5962768 100644 (file)
@@ -864,7 +864,10 @@ public:
     return actionIf(
         LegalizeAction::NarrowScalar,
         [=](const LegalityQuery &Query) {
-          return scalarWiderThan(TypeIdx, Ty.getSizeInBits()) && Predicate(Query);
+          const LLT QueryTy = Query.Types[TypeIdx];
+          return QueryTy.isScalar() &&
+                 QueryTy.getSizeInBits() > Ty.getSizeInBits() &&
+                 Predicate(Query);
         },
         changeElementTo(typeIdx(TypeIdx), Ty));
   }