From patchwork Mon Dec 10 20:27:19 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 205023 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]) by ozlabs.org (Postfix) with SMTP id 2C76E2C00BA for ; Tue, 11 Dec 2012 07:27:41 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1355776062; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:From:To:Mail-Followup-To:Cc:Subject:References:Date: In-Reply-To:Message-ID:User-Agent:MIME-Version:Content-Type: Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:Sender:Delivered-To; bh=yeJpajFHzY8HCAzLy9kT X09xpLk=; b=nFoSTOS/4X19XF5yh7w2U8v838JAG5eGPBib26pY7UgBLwHU33av 2SDaOMa0zAl0ANA+2y7PiCwF8e3EAEV0qbQaGtHaOBEDTAm8oPzfXkDN/Li6NhQJ NUncB1H6I9AeT95lskRoeanYGpb7W+j9CJyKZ4gQvq6ChhMDf0t/Rj0= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Received:From:To:Mail-Followup-To:Cc:Subject:References:Date:In-Reply-To:Message-ID:User-Agent:MIME-Version:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=NYzi+1t8PCseqJatPCfk2qb3BZGemGlzDWM01zzXmW/Bwo229r4HJS0YTw2OTH NaTJHKhKTdDukKXlg7L74B71eHz9nhE+nIiLtwB4xkUI6Fm2SrUWppIe7JeiVl2e IBAvpeFeuAAEnNH2w5o8OfOt0wF1GJp6tbxvAdk4mfZUc=; Received: (qmail 12794 invoked by alias); 10 Dec 2012 20:27:36 -0000 Received: (qmail 12779 invoked by uid 22791); 10 Dec 2012 20:27:34 -0000 X-SWARE-Spam-Status: No, hits=-3.2 required=5.0 tests=AWL, BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, KHOP_RCVD_TRUST, NML_ADSP_CUSTOM_MED, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE X-Spam-Check-By: sourceware.org Received: from mail-wg0-f53.google.com (HELO mail-wg0-f53.google.com) (74.125.82.53) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 10 Dec 2012 20:27:29 +0000 Received: by mail-wg0-f53.google.com with SMTP id ei8so1535756wgb.8 for ; Mon, 10 Dec 2012 12:27:28 -0800 (PST) Received: by 10.216.140.9 with SMTP id d9mr6295551wej.63.1355171248145; Mon, 10 Dec 2012 12:27:28 -0800 (PST) Received: from localhost ([2.28.234.219]) by mx.google.com with ESMTPS id g2sm13216321wiy.0.2012.12.10.12.27.24 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 10 Dec 2012 12:27:25 -0800 (PST) From: Richard Sandiford To: "Steve Ellcey " Mail-Followup-To: "Steve Ellcey " , , rdsandiford@googlemail.com Cc: Subject: Re: [patch, mips, testsuite] Fix gcc.target/mips/octeon-bbit-2.c for -Os References: <9bd1abff-65e1-488e-ba9b-0e0ea8d90abe@EXCHHUB01.MIPS.com> Date: Mon, 10 Dec 2012 20:27:19 +0000 In-Reply-To: <9bd1abff-65e1-488e-ba9b-0e0ea8d90abe@EXCHHUB01.MIPS.com> (Steve Ellcey's message of "Mon, 8 Oct 2012 09:21:37 -0700") Message-ID: <87pq2hy7o8.fsf@talisman.default> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1 (gnu/linux) MIME-Version: 1.0 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 Sorry for the extra-long delay on this one. "Steve Ellcey " writes: > The gcc.target/octeon-bbit-2.c is failing with -Os because that optimization > level does not do whichever optimization it is that results in a bbit instead > of a bbit[01]l. I would like to skip this test for -Os the way it already gets > skipped for -O0. The point of the test is that BBIT[01]L doesn't exist; there aren't any branch-likely variants of BBIT[01]. So we wanted to check that we could still use branch-likely instructions for g(), but wouldn't ever generate the invalid BBIT[01]L for the similarly-structured f(). The problem is that: int s = 0; for (; i & 1; i++) s += i; return s; isn't a very direct way of encouraging branch-likely instructions, because it requires the i & 1 test to be duplicated. As you say, we legimately don't do that for -Os. A sufficiently fancy gimple optimiser could also figure out that the loop iterates at most once and replace the loop with a non-iterating structure. The patch below uses a form that doesn't require any code duplication and which should be a bit more future-proof. Tested on mips64-linux-gnu and applied. Richard gcc/testsuite/ * gcc.target/mips/octeon-bbit-2.c: Restructure loops so that no code duplication is required. Allow BNE to appear. Index: gcc/testsuite/gcc.target/mips/octeon-bbit-2.c =================================================================== --- gcc/testsuite/gcc.target/mips/octeon-bbit-2.c 2012-08-27 17:27:13.000000000 +0100 +++ gcc/testsuite/gcc.target/mips/octeon-bbit-2.c 2012-10-08 21:23:53.416540290 +0100 @@ -4,22 +4,21 @@ /* { dg-final { scan-assembler "\tbbit\[01\]\t" } } */ /* { dg-final { scan-assembler-not "\tbbit\[01\]l\t" } } */ /* { dg-final { scan-assembler "\tbnel\t" } } */ -/* { dg-final { scan-assembler-not "\tbne\t" } } */ NOMIPS16 int -f (int n, int i) +f (int *a, int *b) { - int s = 0; - for (; i & 1; i++) - s += i; - return s; + do + if (__builtin_expect (*a & 1, 1)) + *a = 0; + while (++a < b); } NOMIPS16 int -g (int n, int i) +g (int *a, int *b) { - int s = 0; - for (i = 0; i < n; i++) - s += i; - return s; + do + if (__builtin_expect (*a == 3, 1)) + *a = 0; + while (++a < b); }