[llvm] 8748be7 - [LoopPred] Enable new transformation by default

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 6 15:42:04 PST 2019


Author: Philip Reames
Date: 2019-11-06T15:41:57-08:00
New Revision: 8748be7750920b7bd669a47be72a81ee7f1d305c

URL: https://github.com/llvm/llvm-project/commit/8748be7750920b7bd669a47be72a81ee7f1d305c
DIFF: https://github.com/llvm/llvm-project/commit/8748be7750920b7bd669a47be72a81ee7f1d305c.diff

LOG: [LoopPred] Enable new transformation by default

The basic idea of the transform is to convert variant loop exit conditions into invariant exit conditions by changing the iteration on which the exit is taken when we know that the trip count is unobservable.  See the original patch which introduced the code for a more complete explanation.

The individual parts of this have been reviewed, the result has been fuzzed, and then further analyzed by hand, but despite all of that, I will not be suprised to see breakage here.  If you see problems, please don't hesitate to revert - though please do provide a test case.  The most likely class of issues are latent SCEV bugs and without a reduced test case, I'll be essentially stuck on reducing them.

(Note: A bunch of tests were opted out of the new transform to preserve coverage.  That landed in a previous commit to simplify revert cycles if they turn out to be needed.)

Added: 
    

Modified: 
    llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
    llvm/test/Transforms/IndVarSimplify/exit_value_tests.ll
    llvm/test/Transforms/LoopUnroll/scevunroll.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
index f00b6a5ce3f2..6737c62e94b6 100644
--- a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
+++ b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
@@ -125,7 +125,7 @@ DisableLFTR("disable-lftr", cl::Hidden, cl::init(false),
             cl::desc("Disable Linear Function Test Replace optimization"));
 
 static cl::opt<bool>
-LoopPredication("indvars-predicate-loops", cl::Hidden, cl::init(false),
+LoopPredication("indvars-predicate-loops", cl::Hidden, cl::init(true),
                 cl::desc("Predicate conditions in read only loops"));
 
 namespace {

diff  --git a/llvm/test/Transforms/IndVarSimplify/exit_value_tests.ll b/llvm/test/Transforms/IndVarSimplify/exit_value_tests.ll
index 619ee4d08ea9..f06164e4a1e5 100644
--- a/llvm/test/Transforms/IndVarSimplify/exit_value_tests.ll
+++ b/llvm/test/Transforms/IndVarSimplify/exit_value_tests.ll
@@ -226,7 +226,6 @@ loopexit:
 define i32 @unroll_phi_select(i32 %arg1, i32 %arg2, i16 %len) {
 ; CHECK-LABEL: @unroll_phi_select(
 ; CHECK-NEXT:  entry:
-; CHECK-NEXT:    [[LENGTH:%.*]] = zext i16 [[LEN:%.*]] to i32
 ; CHECK-NEXT:    ret i32 [[ARG2:%.*]]
 ;
 entry:

diff  --git a/llvm/test/Transforms/LoopUnroll/scevunroll.ll b/llvm/test/Transforms/LoopUnroll/scevunroll.ll
index d67e1cfe9d4d..ea473e1ccab6 100644
--- a/llvm/test/Transforms/LoopUnroll/scevunroll.ll
+++ b/llvm/test/Transforms/LoopUnroll/scevunroll.ll
@@ -67,12 +67,10 @@ exit2:
 ; SCEV properly unrolls multi-exit loops.
 ;
 ; CHECK-LABEL: @multiExit(
-; CHECK: getelementptr i32, i32* %base, i32 10
+; CHECK: getelementptr i32, i32* %base, i32 %iv
 ; CHECK-NEXT: load i32, i32*
-; CHECK: br i1 false, label %l2.10, label %exit1
-; CHECK: l2.10:
-; CHECK-NOT: br
-; CHECK: ret i32
+; CHECK: br i1 false, label %l2, label %exit1
+; CHECK: br i1 true, label %l1, label %exit2
 define i32 @multiExit(i32* %base) nounwind {
 entry:
   br label %l1


        


More information about the llvm-commits mailing list