[PATCH] D139981: [EarlyIfConversion] Add switch to allow for multiple ifcvt iterations.

Hendrik Greving via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 13 17:02:45 PST 2022


hgreving created this revision.
hgreving added reviewers: arsenm, jroelofs.
Herald added a subscriber: hiraditya.
Herald added a project: All.
hgreving requested review of this revision.
Herald added subscribers: llvm-commits, wdng.
Herald added a project: LLVM.

Adds a switch -allow-predicating-twice in order to allow the early if-converter
to predicate predicable instructions even though they are already predicated.

      

No test added since there is no upstream target that can take advantage. The
switch is intended for downstream targets to use.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D139981

Files:
  llvm/lib/CodeGen/EarlyIfConversion.cpp


Index: llvm/lib/CodeGen/EarlyIfConversion.cpp
===================================================================
--- llvm/lib/CodeGen/EarlyIfConversion.cpp
+++ llvm/lib/CodeGen/EarlyIfConversion.cpp
@@ -52,6 +52,12 @@
 static cl::opt<bool> Stress("stress-early-ifcvt", cl::Hidden,
   cl::desc("Turn all knobs to 11"));
 
+// Absolute maximum number of instructions allowed per speculated block.
+// This bypasses all other heuristics, so it should be set fairly high.
+static cl::opt<bool> AllowPredicatingTwice(
+    "allow-predicating-twice", cl::init(false), cl::Hidden,
+    cl::desc("Allow predicating already predicated code."));
+
 STATISTIC(NumDiamondsSeen,  "Number of diamonds");
 STATISTIC(NumDiamondsConv,  "Number of diamonds converted");
 STATISTIC(NumTrianglesSeen, "Number of triangles");
@@ -321,9 +327,15 @@
       return false;
     }
 
-    // Check that instruction is predicable and that it is not already
-    // predicated.
-    if (!TII->isPredicable(*I) || TII->isPredicated(*I)) {
+    // Check that instruction is predicable
+    if (!TII->isPredicable(*I)) {
+      LLVM_DEBUG(dbgs() << "Isn't predicable: " << *I);
+      return false;
+    }
+
+    // Check that instruction is not already predicated.
+    if (!AllowPredicatingTwice && TII->isPredicated(*I)) {
+      LLVM_DEBUG(dbgs() << "Is already predicated: " << *I);
       return false;
     }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D139981.482663.patch
Type: text/x-patch
Size: 1386 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221214/7106b36a/attachment.bin>


More information about the llvm-commits mailing list