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

store not sunk by licm #5691

Closed
llvmbot opened this issue Oct 27, 2009 · 4 comments
Closed

store not sunk by licm #5691

llvmbot opened this issue Oct 27, 2009 · 4 comments
Labels
bugzilla Issues migrated from bugzilla loopoptim

Comments

@llvmbot
Copy link
Collaborator

llvmbot commented Oct 27, 2009

Bugzilla Link 5319
Resolution FIXED
Resolved on Sep 05, 2010 20:10
Version trunk
OS Linux
Attachments testcase .ll
Reporter LLVM Bugzilla Contributor
CC @asl,@sunfishcode

Extended Description

This simple C program:

void g(int *);

void f() {
int array[20];
int i;
for (i = 0; i<100; i++) {
array [0] = 0;
}
g(array);
}

is optimized down to:

[...]
bb:
%i.04 = phi i32 [ 0, %entry ], [ %1, %bb ]
store i32 0, i32* %0, align 4
%1 = add nsw i32 %i.04, 1
%exitcond = icmp eq i32 %1, 100
br i1 %exitcond, label %bb2, label %bb
[...]

by llvm-gcc -O2. If we were to run another opt -licm over this then it sinks the store instruction. The problem is that we have more complicated IR at the point of time when LICM actually runs:

[...]
bb:
%3 = phi i32* [ %1, %bb.nph ], [ %2, %bb1 ]
%storemerge1 = phi i32 [ 0, %bb.nph ], [ %storemerge, %bb1 ]
store i32 0, i32* %3, align 4
%4 = add nsw i32 %storemerge1, 1
br label %bb1
bb1:
%storemerge = phi i32 [ %4, %bb ]
%5 = icmp slt i32 %storemerge, 100
br i1 %5, label %bb, label %bb1.bb2_crit_edge
[...]

The full .ll that LICM isn't getting is attached.

@lattner
Copy link
Collaborator

lattner commented Oct 27, 2009

This is expected behavior, you need to run loop rotate before licm to get this. This is completely eliminate at -O3.

@lattner
Copy link
Collaborator

lattner commented Oct 27, 2009

Err, actually, Nick is completely right, I'm an idiot. :)

@llvmbot
Copy link
Collaborator Author

llvmbot commented Oct 27, 2009

What? Loop rotate was the last pass run before -licm. It was the last pass run on the attached testcase .ll file. If loop-rotate isn't doing the right thing then we need to fix that.

@lattner
Copy link
Collaborator

lattner commented Sep 6, 2010

Fixed in r113134.

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 3, 2021
Michael137 pushed a commit to Michael137/llvm-project that referenced this issue Dec 2, 2022
[Clang] Adjust assert from Sema::BuildCXXTypeConstructExpr
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla loopoptim
Projects
None yet
Development

No branches or pull requests

2 participants