From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12497 invoked by alias); 27 Mar 2005 19:13:42 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 12467 invoked by uid 48); 27 Mar 2005 19:13:36 -0000 Date: Sun, 27 Mar 2005 19:13:00 -0000 From: "pinskia at gcc dot gnu dot org" To: gcc-bugs@gcc.gnu.org Message-ID: <20050327191334.20656.pinskia@gcc.gnu.org> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug tree-optimization/20656] New: No strength reduction for a simple testcase X-Bugzilla-Reason: CC X-SW-Source: 2005-03/txt/msg03148.txt.bz2 List-Id: The following two function should be equivalent: int f(int offset, int len, int num_bytes) { int i; num_bytes = 0; for (i = 0; i < len; i++) num_bytes ++; return num_bytes; } int f1(int offset, int len, int num_bytes) { if (len<0) return 0; return len; } Why don't we strength reduce the loop in f? Then we just need to remove the loop and two functions would be equivalent. The orginal code which was found in real code (I think java code in classpath): int f(int offset, int len, int num_bytes) { int i; for (i = 0; i < len; i++) num_bytes +=2; return num_bytes; } int f1(int offset, int len, int num_bytes) { if (len<0) return num_bytes; return num_bytes+len*2; } -- Summary: No strength reduction for a simple testcase Product: gcc Version: 4.1.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: enhancement Priority: P2 Component: tree-optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: pinskia at gcc dot gnu dot org CC: gcc-bugs at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20656