From 821fe0674f41e7b48e734d058d866347ec7e277c Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Mon, 14 Aug 2017 07:03:24 +0000 Subject: [PATCH] [ValueTracking] Revert r310583 which enabled functionality that still is causing compile time issues. Moreover, the patch *deleted* the flag in addition to changing the default, and links to a code review that doesn't even discuss the flag and just has an update to a Clang test case. I've followed up on the commit thread to ask for numbers on compile time at this point, leaving the flag in place until things stabilize, and pointing at specific code that seems to exhibit excessive compile time with this patch. Original commit message for r310583: """ [ValueTracking] Enabling ValueTracking patch by default (recommit). Part 2. The original patch was an improvement to IR ValueTracking on non-negative integers. It has been checked in to trunk (D18777, r284022). But was disabled by default due to performance regressions. Perf impact has improved. The patch would be enabled by default. """" git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@310816 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Analysis/ValueTracking.cpp | 9 +++++++ .../ValueTracking/non-negative-phi-bits.ll | 27 ------------------- 2 files changed, 9 insertions(+), 27 deletions(-) delete mode 100644 test/Analysis/ValueTracking/non-negative-phi-bits.ll diff --git a/lib/Analysis/ValueTracking.cpp b/lib/Analysis/ValueTracking.cpp index 279d880904e..b81bf9ec9d1 100644 --- a/lib/Analysis/ValueTracking.cpp +++ b/lib/Analysis/ValueTracking.cpp @@ -54,6 +54,12 @@ const unsigned MaxDepth = 6; static cl::opt DomConditionsMaxUses("dom-conditions-max-uses", cl::Hidden, cl::init(20)); +// This optimization is known to cause performance regressions is some cases, +// keep it under a temporary flag for now. +static cl::opt +DontImproveNonNegativePhiBits("dont-improve-non-negative-phi-bits", + cl::Hidden, cl::init(true)); + /// Returns the bitwidth of the given scalar or pointer type. For vector types, /// returns the element type's bitwidth. static unsigned getBitWidth(Type *Ty, const DataLayout &DL) { @@ -1252,6 +1258,9 @@ static void computeKnownBitsFromOperator(const Operator *I, KnownBits &Known, Known.Zero.setLowBits(std::min(Known2.countMinTrailingZeros(), Known3.countMinTrailingZeros())); + if (DontImproveNonNegativePhiBits) + break; + auto *OverflowOp = dyn_cast(LU); if (OverflowOp && OverflowOp->hasNoSignedWrap()) { // If initial value of recurrence is nonnegative, and we are adding diff --git a/test/Analysis/ValueTracking/non-negative-phi-bits.ll b/test/Analysis/ValueTracking/non-negative-phi-bits.ll deleted file mode 100644 index 059bbaa3c4e..00000000000 --- a/test/Analysis/ValueTracking/non-negative-phi-bits.ll +++ /dev/null @@ -1,27 +0,0 @@ -; NOTE: Assertions have been autogenerated by utils/update_test_checks.py -; RUN: opt -instcombine < %s -S | FileCheck %s - -define void @test() #0 { -; CHECK-LABEL: @test( -; CHECK-NEXT: entry: -; CHECK-NEXT: br label [[FOR_BODY:%.*]] -; CHECK: for.body: -; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[INDVARS_IV_NEXT:%.*]], [[FOR_BODY]] ] -; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nuw nsw i64 [[INDVARS_IV]], 1 -; CHECK-NEXT: [[EXITCOND:%.*]] = icmp ult i64 [[INDVARS_IV_NEXT]], 40 -; CHECK-NEXT: br i1 [[EXITCOND]], label [[FOR_END:%.*]], label [[FOR_BODY]] -; CHECK: for.end: -; CHECK-NEXT: ret void -; -entry: - br label %for.body - -for.body: ; preds = %for.body, %entry - %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ] - %indvars.iv.next = add nsw i64 %indvars.iv, 1 - %exitcond = icmp slt i64 %indvars.iv.next, 40 - br i1 %exitcond, label %for.end, label %for.body - -for.end: ; preds = %for.body - ret void -} -- 2.50.1