[PATCH] D33306: [IfConversion] Make the ifcvt-limit command line option work at the function level and remove compares with global Statistic variables

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 17 18:50:20 PDT 2017


craig.topper created this revision.

Currently this limit is compared against the sum of the global Statistic variables. This means the limit is cumulative across all functions and all runs of the pass. This doesn't seem an intuitive way to implement this.

Another issue is that the command line option won't work in release builds because the Statistic objects will always return 0.

This is part of a larger plan to try to make it harder to misuse the Statistic objects.


https://reviews.llvm.org/D33306

Files:
  lib/CodeGen/IfConversion.cpp


Index: lib/CodeGen/IfConversion.cpp
===================================================================
--- lib/CodeGen/IfConversion.cpp
+++ lib/CodeGen/IfConversion.cpp
@@ -359,8 +359,7 @@
 
   std::vector<std::unique_ptr<IfcvtToken>> Tokens;
   MadeChange = false;
-  unsigned NumIfCvts = NumSimple + NumSimpleFalse + NumTriangle +
-    NumTriangleRev + NumTriangleFalse + NumTriangleFRev + NumDiamonds;
+  unsigned NumIfCvts = 0;
   while (IfCvtLimit == -1 || (int)NumIfCvts < IfCvtLimit) {
     // Do an initial analysis for each basic block and find all the potential
     // candidates to perform if-conversion.
@@ -464,8 +463,9 @@
 
       Change |= RetVal;
 
-      NumIfCvts = NumSimple + NumSimpleFalse + NumTriangle + NumTriangleRev +
-        NumTriangleFalse + NumTriangleFRev + NumDiamonds;
+      if (RetVal)
+        ++NumIfCvts;
+
       if (IfCvtLimit != -1 && (int)NumIfCvts >= IfCvtLimit)
         break;
     }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33306.99384.patch
Type: text/x-patch
Size: 932 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170518/524c4634/attachment.bin>


More information about the llvm-commits mailing list