From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19827 invoked by alias); 31 Aug 2007 08:05:43 -0000 Received: (qmail 19781 invoked by uid 48); 31 Aug 2007 08:05:33 -0000 Date: Fri, 31 Aug 2007 08:05:00 -0000 Subject: [Bug tree-optimization/33259] New: limited range of remainder operation can prove loop runs at most once X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "raeburn at raeburn dot org" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2007-08/txt/msg02382.txt.bz2 The result of a signed remainder operation with a constant divisor is limited in absolute value to less than the value of the divisor. Following it with code to force the remainder to be positive by adjusting the quotient and remainder values is pretty straightforward. However, if it's written as a loop it doesn't get optimized well. The rtl initially generated appears to have the loop transformed into arithmetic to figure out the number of times the loop would run, in a branch conditionalized on whether the loop would be run at all. (Actually, it appears to run the loop body once, and then do math to figure out how many more times.) However, the compiler doesn't figure out that in that branch, the loop body would be run exactly once, either in the tree or rtl optimizations. -- Summary: limited range of remainder operation can prove loop runs at most once Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: raeburn at raeburn dot org GCC build triplet: i686-pc-linux-gnu GCC host triplet: i686-pc-linux-gnu GCC target triplet: i686-pc-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33259