LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 1232 - constant propagation doesn't work through unrolled loops
Summary: constant propagation doesn't work through unrolled loops
Status: RESOLVED DUPLICATE of bug 1179
Alias: None
Product: new-bugs
Classification: Unclassified
Component: new bugs (show other bugs)
Version: unspecified
Hardware: PC Linux
: P normal
Assignee: Unassigned LLVM Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-02-28 19:46 PST by Mathias Gaunard
Modified: 2010-02-22 12:42 PST (History)
1 user (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mathias Gaunard 2007-02-28 19:46:00 PST
With the following C code, the loop is completely eliminated, thanks to loop
unrolling and constant propagation.
The resulting LLVM code just calls printf with 20.

#include <stdio.h>
#include <stddef.h>

int main()
{
	int v = 0;

	size_t i;
	for(i=0; i<5; i++)
	{
		v += i*2;
	}

	printf("%d\n", v);
}


However, if 5 is replaced by 100, loop unrolling doesn't occur, and for some
reason constant propagation doesn't work anymore.
The resulting code just needs to call printf with 9900, there is no need for any
loop.
Comment 1 Chris Lattner 2007-02-28 19:48:24 PST
Yep, known.

*** This bug has been marked as a duplicate of 1179 ***
Comment 2 Chris Lattner 2007-03-03 19:02:56 PST
This has been implemented, see PR1179 for details,

-Chris