Skip to content

Commit

Permalink
[CVP] Add a cl::opt for canonicalization of signed relational compari…
Browse files Browse the repository at this point in the history
…sons

This canonicalization breaks the ability to discard checks in some cases.
Add a command line option to disable it. This option is on by default,
so the change is NFC.

See for details:
https://reviews.llvm.org/D112895#3149487
  • Loading branch information
arpilipe committed Nov 24, 2021
1 parent f244166 commit aa60d16
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp
Expand Up @@ -52,6 +52,11 @@ using namespace llvm;

#define DEBUG_TYPE "correlated-value-propagation"

static cl::opt<bool> CanonicalizeICmpPredicatesToUnsigned(
"canonicalize-icmp-predicates-to-unsigned", cl::init(true), cl::Hidden,
cl::desc("Enables canonicalization of signed relational predicates to "
"unsigned (e.g. sgt => ugt)"));

STATISTIC(NumPhis, "Number of phis propagated");
STATISTIC(NumPhiCommon, "Number of phis deleted via common incoming value");
STATISTIC(NumSelects, "Number of selects propagated");
Expand Down Expand Up @@ -297,6 +302,9 @@ static bool processMemAccess(Instruction *I, LazyValueInfo *LVI) {
}

static bool processICmp(ICmpInst *Cmp, LazyValueInfo *LVI) {
if (!CanonicalizeICmpPredicatesToUnsigned)
return false;

// Only for signed relational comparisons of scalar integers.
if (Cmp->getType()->isVectorTy() ||
!Cmp->getOperand(0)->getType()->isIntegerTy())
Expand Down

0 comments on commit aa60d16

Please sign in to comment.