From b20570e64734b73fce02d5e4fd3a400c6015d7da Mon Sep 17 00:00:00 2001 From: Hans Wennborg Date: Thu, 23 Feb 2017 22:29:00 +0000 Subject: [PATCH] Revert r282872 "CVP. Turn marking adds as no wrap on by default" While not CVP's fault, this caused miscompiles (PR31181). Reverting until those are resolved. (This also reverts the follow-ups r288154 and r288161 which removed the flag.) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@296030 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Scalar/CorrelatedValuePropagation.cpp | 5 +++++ test/Transforms/CorrelatedValuePropagation/add.ll | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp b/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp index 60786a3373f..d4d5ef4b158 100644 --- a/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp +++ b/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp @@ -41,6 +41,8 @@ STATISTIC(NumSDivs, "Number of sdiv converted to udiv"); STATISTIC(NumAShrs, "Number of ashr converted to lshr"); STATISTIC(NumSRems, "Number of srem converted to urem"); +static cl::opt DontProcessAdds("cvp-dont-process-adds", cl::init(true)); + namespace { class CorrelatedValuePropagation : public FunctionPass { public: @@ -405,6 +407,9 @@ static bool processAShr(BinaryOperator *SDI, LazyValueInfo *LVI) { static bool processAdd(BinaryOperator *AddOp, LazyValueInfo *LVI) { typedef OverflowingBinaryOperator OBO; + if (DontProcessAdds) + return false; + if (AddOp->getType()->isVectorTy() || hasLocalDefs(AddOp)) return false; diff --git a/test/Transforms/CorrelatedValuePropagation/add.ll b/test/Transforms/CorrelatedValuePropagation/add.ll index 4b436ff9a40..0ba521c894e 100644 --- a/test/Transforms/CorrelatedValuePropagation/add.ll +++ b/test/Transforms/CorrelatedValuePropagation/add.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -correlated-propagation -S | FileCheck %s +; RUN: opt < %s -correlated-propagation -cvp-dont-process-adds=false -S | FileCheck %s ; CHECK-LABEL: @test0( define void @test0(i32 %a) {