Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

-indvars pass fails to replace exit value of loop when profitable #1551

Closed
lattner opened this issue Feb 5, 2007 · 6 comments
Closed

-indvars pass fails to replace exit value of loop when profitable #1551

lattner opened this issue Feb 5, 2007 · 6 comments
Assignees
Labels

Comments

@lattner
Copy link
Collaborator

lattner commented Feb 5, 2007

Bugzilla Link 1179
Resolution FIXED
Resolved on May 05, 2019 06:32
Version 1.8
OS All
CC @nlewycky

Extended Description

The -indvars pass is not computing the exit value of j in either of these cases:

int ltst(int x) {
int i, j;
j=0;
for(i=0; i<x; i++)j++;
return(j);
}

int ltst(int x) {
int i = 0, j = 0
do {
j++, i++;
} while (i < x);
return(j);
}

@lattner
Copy link
Collaborator Author

lattner commented Feb 5, 2007

assigned to @lattner

@lattner
Copy link
Collaborator Author

lattner commented Feb 15, 2007

Another obvious case:

int main() {
int i = 0;
for (int x = 0; x < 200000; ++x)
i += 3;
return i;
}

@lattner
Copy link
Collaborator Author

lattner commented Mar 1, 2007

*** Bug llvm/llvm-bugzilla-archive#1232 has been marked as a duplicate of this bug. ***

@lattner
Copy link
Collaborator Author

lattner commented Mar 3, 2007

This regression is largely due to LCSSA landing. For example, the input to indvars on the code in
comment #​1 is:

define i32 @​foo() {
entry:
br label %bb5

bb5: ; preds = %bb5, %entry
%x.03.0 = phi i32 [ 0, %entry ], [ %indvar.next, %bb5 ] ; [#uses=2]
%i.01.0 = mul i32 %x.03.0, 3 ; [#uses=1]
%tmp2 = add i32 %i.01.0, 3 ; [#uses=1]
%indvar.next = add i32 %x.03.0, 1 ; [#uses=2]
icmp ne i32 %indvar.next, 200000 ; :0 [#uses=1]
br i1 %0, label %bb5, label %bb7

bb7: ; preds = %bb5
%tmp2.lcssa = phi i32 [ %tmp2, %bb5 ] ; [#uses=1]
ret i32 %tmp2.lcssa
}

the LCSSA phi node prevents exit value substitution due to IndVarSimplify.cpp:347

-Chris

@lattner
Copy link
Collaborator Author

lattner commented Mar 4, 2007

Implemented. Patch here:
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20070226/045475.html

Testcases here: test/Transforms/IndVarsSimplify/loop_evaluate_[234].ll

-Chris

@lattner
Copy link
Collaborator Author

lattner commented Nov 26, 2021

mentioned in issue llvm/llvm-bugzilla-archive#1232

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 3, 2021
jeanPerier pushed a commit to jeanPerier/llvm-project that referenced this issue Apr 1, 2022
…m#1551)

system_clock intrinsic calls with dynamically optional arguments

Modify intrinsic system_clock calls to allow for an argument that is optional
or a disassociated pointer or an unallocated allocatable.  A call with such an
argument is the same as a call that does not specify that argument.

Rename (genIsNotNull -> genIsNotNullAddr) and (genIsNull -> genIsNullAddr)
and add a use of genIsNotNullAddr.
troelsbjerre pushed a commit to troelsbjerre/llvm-project that referenced this issue Jan 10, 2024
…4/0b339c069266b7a4f3c82f80067d74620cbe19c4

[lldb] Inform every language runtime of the modified modules
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant