[llvm] dfae717 - GlobalISel: Fix maxScalarIf predicate check

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 23 18:46:41 PDT 2020


Author: Matt Arsenault
Date: 2020-07-23T21:17:10-04:00
New Revision: dfae7174f8bb83f18490ba80ac44b4ed4bb29f66

URL: https://github.com/llvm/llvm-project/commit/dfae7174f8bb83f18490ba80ac44b4ed4bb29f66
DIFF: https://github.com/llvm/llvm-project/commit/dfae7174f8bb83f18490ba80ac44b4ed4bb29f66.diff

LOG: GlobalISel: Fix maxScalarIf predicate check

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.

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/CodeGen/GlobalISel/LegalizerInfo.h b/llvm/include/llvm/CodeGen/GlobalISel/LegalizerInfo.h
index 7cf1fb03d6e1..5962768c206c 100644
--- a/llvm/include/llvm/CodeGen/GlobalISel/LegalizerInfo.h
+++ b/llvm/include/llvm/CodeGen/GlobalISel/LegalizerInfo.h
@@ -864,7 +864,10 @@ class LegalizeRuleSet {
     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));
   }


        


More information about the llvm-commits mailing list