llvm.org GIT mirror llvm / 7e14c3d
[IndVars] Add an option to be able to disable LFTR This change adds an option disable-lftr to be able to disable Linear Function Test Replace optimization. By default option is off so current behavior is not changed. Reviewers: reames, sanjoy, wmi, andreadb, apilipenko Reviewed By: sanjoy Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D33979 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@305055 91177308-0d34-0410-b5e6-96231b3b80d8 Serguei Katkov 2 years ago
2 changed file(s) with 34 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
8484 "indvars-post-increment-ranges", cl::Hidden,
8585 cl::desc("Use post increment control-dependent ranges in IndVarSimplify"),
8686 cl::init(true));
87
88 static cl::opt
89 DisableLFTR("disable-lftr", cl::Hidden, cl::init(false),
90 cl::desc("Disable Linear Function Test Replace optimization"));
8791
8892 namespace {
8993 struct RewritePhi;
24122416
24132417 // If we have a trip count expression, rewrite the loop's exit condition
24142418 // using it. We can currently only handle loops with a single exit.
2415 if (canExpandBackedgeTakenCount(L, SE, Rewriter) && needsLFTR(L, DT)) {
2419 if (!DisableLFTR && canExpandBackedgeTakenCount(L, SE, Rewriter) &&
2420 needsLFTR(L, DT)) {
24162421 PHINode *IndVar = FindLoopCounter(L, BackedgeTakenCount, SE, DT);
24172422 if (IndVar) {
24182423 // Check preconditions for proper SCEVExpander operation. SCEV does not
0 ; LFTR should not eliminate the need for the computation of i*i completely
1 ; due to LFTR is disabled.
2 ; RUN: opt < %s -indvars -dce -disable-lftr -S | FileCheck %s
3
4 ; Provide legal integer types.
5 target datalayout = "n8:16:32:64"
6
7
8 @A = external global i32 ; [#uses=1]
9
10 define i32 @quadratic_setlt() {
11 ; CHECK-LABEL: @quadratic_setlt(
12 ; CHECK: mul
13 entry:
14 br label %loop
15
16 loop: ; preds = %loop, %entry
17 %i = phi i32 [ 7, %entry ], [ %i.next, %loop ] ; [#uses=5]
18 %i.next = add i32 %i, 1 ; [#uses=1]
19 store i32 %i, i32* @A
20 %i2 = mul i32 %i, %i ; [#uses=1]
21 %c = icmp slt i32 %i2, 1000 ; [#uses=1]
22 br i1 %c, label %loop, label %loopexit
23
24 loopexit: ; preds = %loop
25 ret i32 %i
26 }
27