Sudakshina Dutta via llvm-dev
2021-May-02 06:35 UTC
[llvm-dev] Loop invariant code motion optimization does not happen for the input code
Dear all,
Greetings. I have been trying to have a loop invariant code motion on the
LLVM IR (.ll) file which has been generated from the following .c file.
int main()
{
int a = 5, b = 20, c = 50, d = 1, x;
while(a < b)
{
x = d + 1;
x = d + 2;
c = c + 5;
a = a + 1;
}
}
Both the first two statements should qualify for loop invariant code
motion. However, loop invariant code does not move out of the loop in the
generated .ll file. Note that I have applied the following commands.
clang -S -emit-llvm prog1.c -o prog1.ll
opt -licm -S prog1.ll -o prog1-opt3.ll -opt-bisect-limit=300
Can you please help in this regard ?
Thanks and regards,
Sudakshina
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20210502/07793e8a/attachment.html>
Craig Topper via llvm-dev
2021-May-02 07:08 UTC
[llvm-dev] Loop invariant code motion optimization does not happen for the input code
Does your function in prog1.ll have the optnone attribute on it? If so try adding "-Xclang -disable-O0-optnone" to your clang command line ~Craig On Sat, May 1, 2021 at 11:35 PM Sudakshina Dutta via llvm-dev < llvm-dev at lists.llvm.org> wrote:> Dear all, > > Greetings. I have been trying to have a loop invariant code motion on the > LLVM IR (.ll) file which has been generated from the following .c file. > > int main() > { > int a = 5, b = 20, c = 50, d = 1, x; > while(a < b) > { > x = d + 1; > x = d + 2; > c = c + 5; > a = a + 1; > } > } > Both the first two statements should qualify for loop invariant code > motion. However, loop invariant code does not move out of the loop in the > generated .ll file. Note that I have applied the following commands. > > clang -S -emit-llvm prog1.c -o prog1.ll > opt -licm -S prog1.ll -o prog1-opt3.ll -opt-bisect-limit=300 > > Can you please help in this regard ? > > Thanks and regards, > Sudakshina > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210502/35d971bb/attachment.html>