https://bugs.llvm.org/show_bug.cgi?id=44679
Bug ID: 44679
Summary: Missed constant propagation optimization in simple
while loop
Product: new-bugs
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: new bugs
Assignee: unassignedb...@nondot.org
Reporter: klrehm...@gmail.com
CC: htmldevelo...@gmail.com, llvm-bugs@lists.llvm.org
//////////////////
int foo(int a) {
int num = 0;
int n = 1;
while (true) {
if (n == 1) {
num++;
n = 2;
} else if(n == 2) {
num += 2;
n = 3;
}
else if(n == 3) {
return num;
}
}
}
//////////////////
Optimized away in GCC, but not with LLVM trunk.
Interestingly, copying the loop body twice does get optimized:
//////////////////
int bar(int a) {
int num = 0;
int n = 1;
while (true) {
if (n == 1) {
num++;
n = 2;
} else if(n == 2) {
num += 2;
n = 3;
}
else if(n == 3) {
return num;
}
if (n == 1) {
num++;
n = 2;
} else if(n == 2) {
num += 2;
n = 3;
}
else if(n == 3) {
return num;
}
}
}
//////////////////
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs