[llvm-bugs] [Bug 44679] New: Missed constant propagation optimization in simple while loop
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Jan 27 08:08:18 PST 2020
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: unassignedbugs at nondot.org
Reporter: klrehm123 at gmail.com
CC: htmldeveloper at gmail.com, llvm-bugs at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200127/be6bdff4/attachment.html>
More information about the llvm-bugs
mailing list