From patchwork Fri Jul 19 23:15:27 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: pchang9@cs.wisc.edu X-Patchwork-Id: 260363 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id F28922C009C for ; Sat, 20 Jul 2013 09:15:43 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:subject:from:to:mime-version:content-type; q= dns; s=default; b=WDIuXNPF+LOt6Yof7tepA/pOuUzuunMKrUzVo6i5DofJ8q QQ1fVWrf/WuHnjkj0EI7jDzslyeA+6EYx9Ds94pwBCiSoqWFFHikufFUc73jfLJf z3YbA/CxM6jApaNN9sFFWN/pugk10kv4okNAdlf1EXif2WZ2uLe8cuoR8UFSc= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:subject:from:to:mime-version:content-type; s= default; bh=aquGpN7vxG2qics/C0M/sh/LVTI=; b=QcAVYIy4z6usTXLtdNyG rraLlV195I84QxE8ZmRaCbe1vYdiDpcCOZRLlWimA1w12vaK2cgll3e/8j8QEBoP Hs6iNEAfmoH/L3su2vWJIcxkSKZoRQlMvX5WeZxXEY0YxY7Sqky1Tb4t9SHD130T i9+43Ho+iG9Cu1IAbOtyB3o= Received: (qmail 3861 invoked by alias); 19 Jul 2013 23:15:36 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 3852 invoked by uid 89); 19 Jul 2013 23:15:36 -0000 X-Spam-SWARE-Status: No, score=-3.2 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_MED, RCVD_IN_HOSTKARMA_W, RDNS_NONE, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.1 Received: from Unknown (HELO sandstone.cs.wisc.edu) (128.105.6.39) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Fri, 19 Jul 2013 23:15:35 +0000 Received: from webmail.cs.wisc.edu (george.cs.wisc.edu [128.105.7.110]) by sandstone.cs.wisc.edu (8.14.1/8.14.1) with ESMTP id r6JNFR5Q019306 for ; Fri, 19 Jul 2013 18:15:27 -0500 Received: from 146.151.118.255 (SquirrelMail authenticated user pchang9) by webmail.cs.wisc.edu with HTTP; Fri, 19 Jul 2013 18:15:27 -0500 Message-ID: <3d2169b26938aa3d2aa3575bf745cf44.squirrel@webmail.cs.wisc.edu> Date: Fri, 19 Jul 2013 18:15:27 -0500 Subject: [Patch, PR 57809] Wasted work in omega_eliminate_red() From: pchang9@cs.wisc.edu To: gcc-patches@gcc.gnu.org User-Agent: SquirrelMail/1.4.22 MIME-Version: 1.0 X-Virus-Found: No Hi, The problem appears in revision 201034 in version 4.9. I attached a one-line patch that fixes it. I also reported this problem at http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57809 I bootstrapped and ran the regression tests for this patch on x86_64-linux and all tests pass. In method "omega_eliminate_red()" in gcc/omega.c, the loop on line 2592 should break immediately after "red_found" is set to "1". All the iterations after "red_found" set to "1" do not perform any useful work, at best they just set "red_found" again to "1". There are three more similar problems in the same file gcc/omega.c: 1. omega_problem_has_red_equations(): the loop on line 4854 should break immediately after "result" is set to "true". 2. omega_problem_has_red_equations(): the loop on line 4907 should break immediately after "result" is set to "true". 3. omega_query_variable(): the loop on line 5252 should break immediately after "coupled" is set to "true". -Chang Index: gcc/omega.c =================================================================== --- gcc/omega.c (revision 201034) +++ gcc/omega.c (working copy) @@ -2591,7 +2591,10 @@ for (red_found = 0, e = pb->num_geqs - 1; e >= 0; e--) if (pb->geqs[e].color == omega_red) - red_found = 1; + { + red_found = 1; + break; + } if (!red_found) { Index: gcc/omega.c =================================================================== --- gcc/omega.c (revision 201034) +++ gcc/omega.c (working copy) @@ -4853,7 +4853,10 @@ for (e = pb->num_geqs - 1; e >= 0; e--) if (pb->geqs[e].color == omega_red) - result = true; + { + result = true; + break; + } if (!result) return false; Index: gcc/omega.c =================================================================== --- gcc/omega.c (revision 201034) +++ gcc/omega.c (working copy) @@ -4906,7 +4906,10 @@ for (e = pb->num_geqs - 1; e >= 0; e--) if (pb->geqs[e].color == omega_red) - result = true; + { + result = true; + break; + } if (dump_file && (dump_flags & TDF_DETAILS)) { Index: gcc/omega.c =================================================================== --- gcc/omega.c (revision 201034) +++ gcc/omega.c (working copy) @@ -5251,7 +5251,10 @@ for (e = pb->num_subs - 1; e >= 0; e--) if (pb->subs[e].coef[i] != 0) - coupled = true; + { + coupled = true; + break; + } for (e = pb->num_eqs - 1; e >= 0; e--) if (pb->eqs[e].coef[i] != 0) Index: gcc/omega.c =================================================================== --- gcc/omega.c (revision 201034) +++ gcc/omega.c (working copy) @@ -2591,7 +2591,10 @@ for (red_found = 0, e = pb->num_geqs - 1; e >= 0; e--) if (pb->geqs[e].color == omega_red) - red_found = 1; + { + red_found = 1; + break; + } if (!red_found) { Index: gcc/omega.c =================================================================== --- gcc/omega.c (revision 201034) +++ gcc/omega.c (working copy) @@ -4853,7 +4853,10 @@ for (e = pb->num_geqs - 1; e >= 0; e--) if (pb->geqs[e].color == omega_red) - result = true; + { + result = true; + break; + } if (!result) return false; Index: gcc/omega.c =================================================================== --- gcc/omega.c (revision 201034) +++ gcc/omega.c (working copy) @@ -4906,7 +4906,10 @@ for (e = pb->num_geqs - 1; e >= 0; e--) if (pb->geqs[e].color == omega_red) - result = true; + { + result = true; + break; + } if (dump_file && (dump_flags & TDF_DETAILS)) { Index: gcc/omega.c =================================================================== --- gcc/omega.c (revision 201034) +++ gcc/omega.c (working copy) @@ -5251,7 +5251,10 @@ for (e = pb->num_subs - 1; e >= 0; e--) if (pb->subs[e].coef[i] != 0) - coupled = true; + { + coupled = true; + break; + } for (e = pb->num_eqs - 1; e >= 0; e--) if (pb->eqs[e].coef[i] != 0)