From patchwork Mon Nov 18 01:33:34 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Schmidt X-Patchwork-Id: 291921 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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 47BB12C00DE for ; Mon, 18 Nov 2013 12:34:26 +1100 (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:subject:from:to:cc:date:content-type :content-transfer-encoding:mime-version; q=dns; s=default; b=GSU MOz3Lev0FEm/GqraEP0MfQ7Kwkmg5UiW5CdeD8Ow3qnQjVX21PXHv+tJmpHt+FT+ QPt6eTkHScqK8uz/daW2ln7kE5dbsnFdDHtZGbCgVIf6piDl+h20s7s3O32UOsym trcI5LtoCBs2BIgopBUKDBJZewH5ZqO+1clZLVOU= 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:subject:from:to:cc:date:content-type :content-transfer-encoding:mime-version; s=default; bh=g1+6vMCy9 NX73BiKKhaVHWpXe50=; b=BXZ664EDyJGDY69vruMMMXnOUTYpCtCuqMoKyMKCB awmWzI8qFo36kgVPRQJHvAnB3ZofhXsMnoiZlgAbeevfxB+iCLeJcLzcP3HqRY/1 3hOXsUPNdp7rPTUQanj/lOPYsT7xuedreEFvGuzrsPPArF1mP13PZRgbDntuBODz J0= Received: (qmail 7878 invoked by alias); 18 Nov 2013 01:34:15 -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 7868 invoked by uid 89); 18 Nov 2013 01:34:14 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.1 required=5.0 tests=AWL, BAYES_50, RDNS_NONE autolearn=no version=3.3.2 X-HELO: e23smtp08.au.ibm.com Received: from Unknown (HELO e23smtp08.au.ibm.com) (202.81.31.141) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Mon, 18 Nov 2013 01:34:13 +0000 Received: from /spool/local by e23smtp08.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 18 Nov 2013 11:33:57 +1000 Received: from d23dlp02.au.ibm.com (202.81.31.213) by e23smtp08.au.ibm.com (202.81.31.205) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 18 Nov 2013 11:33:56 +1000 Received: from d23relay04.au.ibm.com (d23relay04.au.ibm.com [9.190.234.120]) by d23dlp02.au.ibm.com (Postfix) with ESMTP id 458112BB0055 for ; Mon, 18 Nov 2013 12:33:56 +1100 (EST) Received: from d23av01.au.ibm.com (d23av01.au.ibm.com [9.190.234.96]) by d23relay04.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id rAI1GBOI62718110 for ; Mon, 18 Nov 2013 12:16:12 +1100 Received: from d23av01.au.ibm.com (localhost [127.0.0.1]) by d23av01.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id rAI1XtCt013640 for ; Mon, 18 Nov 2013 12:33:55 +1100 Received: from [9.57.64.207] ([9.57.64.207]) by d23av01.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id rAI1XqeT012829; Mon, 18 Nov 2013 12:33:53 +1100 Message-ID: <1384738414.8213.214.camel@gnopaine> Subject: [PATCH, rs6000] Fix libcpp/lex.c Altivec code to be correct for little endian From: Bill Schmidt To: gcc-patches@gcc.gnu.org Cc: dje.gcc@gmail.com, uweigand@de.ibm.com Date: Sun, 17 Nov 2013 19:33:34 -0600 Mime-Version: 1.0 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13111801-5140-0000-0000-0000042BD083 X-IsSubscribed: yes Hi, As Ulrich Weigand discovered, libcpp/lex.c contains some code optimized for use with Altivec that is incorrect for little endian targets. This breaks bootstrap on powerpc64le-unknown-linux-gnu when configured with --with-cpu=power7. This patch makes appropriate modifications for little endian. The transformation of lvsr/vperm(x,y,z) into lvsl/vperm(y,x,z) is familiar from a previous patch. The other obvious change is converting count-leading-zeroes into count-trailing-zeroes. Bootstrapped on powerpc64-unknown-linux-gnu (BE) using --with-cpu=power7 with no regressions. Bootstrap for powerpc64le-unknown-linux-gnu (LE) using --with-cpu=power7 now completes with this patch. There are still failures for --with-cpu=power7 that are not present using --with-cpu=power6 that need to be investigated, but they are unrelated to this change. Ok for trunk? Thanks, Bill 2013-11-17 Bill Schmidt * lex.c (search_line_fast): Correct for little endian. Index: libcpp/lex.c =================================================================== --- libcpp/lex.c (revision 204928) +++ libcpp/lex.c (working copy) @@ -559,8 +559,13 @@ search_line_fast (const uchar *s, const uchar *end beginning with all ones and shifting in zeros according to the mis-alignment. The LVSR instruction pulls the exact shift we want from the address. */ +#ifdef __BIG_ENDIAN__ mask = __builtin_vec_lvsr(0, s); mask = __builtin_vec_perm(zero, ones, mask); +#else + mask = __builtin_vec_lvsl(0, s); + mask = __builtin_vec_perm(ones, zero, mask); +#endif data &= mask; /* While altivec loads mask addresses, we still need to align S so @@ -624,7 +629,11 @@ search_line_fast (const uchar *s, const uchar *end /* L now contains 0xff in bytes for which we matched one of the relevant characters. We can find the byte index by finding its bit index and dividing by 8. */ +#ifdef __BIG_ENDIAN__ l = __builtin_clzl(l) >> 3; +#else + l = __builtin_ctzl(l) >> 3; +#endif return s + l; #undef N