[PATCH] D75204: [VectorCombine] add a debug flag to skip all transforms

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 26 11:50:35 PST 2020


spatel created this revision.
spatel added a reviewer: lebedev.ri.
Herald added subscribers: hiraditya, mcrosier.
Herald added a project: LLVM.

As suggested in D75145 <https://reviews.llvm.org/D75145> (and seems obviously good, but posting for review in case I'm missing some reason to implement it differently).

I'm not sure why, but several passes have this kind of disable/enable flag implemented at the pass manager level. But that means we have to duplicate the flag for both pass managers and add code to check the flag every time the pass appears in the pipeline.

We want a debug option to see if this pass is misbehaving regardless of the pass managers, so just add a disablement check at the single point before any transforms run.


https://reviews.llvm.org/D75204

Files:
  llvm/lib/Transforms/Vectorize/VectorCombine.cpp


Index: llvm/lib/Transforms/Vectorize/VectorCombine.cpp
===================================================================
--- llvm/lib/Transforms/Vectorize/VectorCombine.cpp
+++ llvm/lib/Transforms/Vectorize/VectorCombine.cpp
@@ -23,6 +23,7 @@
 #include "llvm/IR/PatternMatch.h"
 #include "llvm/InitializePasses.h"
 #include "llvm/Pass.h"
+#include "llvm/Support/CommandLine.h"
 #include "llvm/Transforms/Vectorize.h"
 #include "llvm/Transforms/Utils/Local.h"
 
@@ -33,6 +34,10 @@
 STATISTIC(NumVecCmp, "Number of vector compares formed");
 STATISTIC(NumVecBO, "Number of vector binops formed");
 
+static cl::opt<bool> DisableVectorCombine(
+    "disable-vector-combine", cl::init(false), cl::Hidden,
+    cl::desc("Disable all vector combine transforms"));
+
 /// Compare the relative costs of extracts followed by scalar operation vs.
 /// vector operation followed by extract:
 /// opcode (extelt V0, C), (extelt V1, C) --> extelt (opcode V0, V1), C
@@ -175,6 +180,9 @@
 /// handled in the callers of this function.
 static bool runImpl(Function &F, const TargetTransformInfo &TTI,
                     const DominatorTree &DT) {
+  if (DisableVectorCombine)
+    return false;
+
   bool MadeChange = false;
   for (BasicBlock &BB : F) {
     // Ignore unreachable basic blocks.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D75204.246800.patch
Type: text/x-patch
Size: 1284 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200226/1e75da8b/attachment.bin>


More information about the llvm-commits mailing list