diff --git a/llvm/lib/CodeGen/EarlyIfConversion.cpp b/llvm/lib/CodeGen/EarlyIfConversion.cpp --- a/llvm/lib/CodeGen/EarlyIfConversion.cpp +++ b/llvm/lib/CodeGen/EarlyIfConversion.cpp @@ -52,6 +52,12 @@ static cl::opt 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 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; }