This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/81834] New: Simple loop with single variable is not optimized out
- From: "geoffrey at allott dot email" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 12 Aug 2017 21:52:45 +0000
- Subject: [Bug tree-optimization/81834] New: Simple loop with single variable is not optimized out
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81834
Bug ID: 81834
Summary: Simple loop with single variable is not optimized out
Product: gcc
Version: 7.1.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: geoffrey at allott dot email
Target Milestone: ---
The following code:
int main() {
for(int i=0; i += i < 1000, i < 1000;);
}
optimizes on x86_64 to the following code:
main:
.LFB0:
xorl %eax, %eax
.L2:
xorl %edx, %edx
cmpl $999, %eax
setle %dl
addl %edx, %eax
cmpl $999, %eax
jle .L2
xorl %eax, %eax
ret
I would expect the loop to be removed completely.