https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88186
Bug ID: 88186 Summary: GCC Fails to optimize arithmetic progression Product: gcc Version: tree-ssa Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: giuliano.belinassi at usp dot br Target Milestone: --- Created attachment 45087 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=45087&action=edit Somewhat a test case. GCC fails to optimize simple arithmetic progressions. See attached code. gcc -Ofast -o induction induction_test.c ./induction 1 Sum is 0, elapsed time: 0 Sum is 0, elapsed time: 0 ./induction 600000000 Sum is 179999999700000000, elapsed time: 203883 Sum is 179999999700000000, elapsed time: 0 It takes O(n), but the expected time would be O(1) after the optimization.