From patchwork Wed Jan 26 21:03:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 50471 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 553A0385803A for ; Wed, 26 Jan 2022 21:04:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 553A0385803A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1643231063; bh=YoaJ3h+8dCLt72o6TZaLYQXSsj8EZjxG0xh+mKmksng=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=F3IH7Rt0JHbta6GVAEs3I0b8Sf9gfFL2AyecdkGJ4tcOD0zoyS7WbEQI7913CwSD7 Lim8Hq2VKw9HqNBLxoP/NLRu+RBfG8+pbwnJpRR4LJa4XQ8C/faoVz69FMKoZK28w9 mqWD1RuT2qfI16SLx1FWHk7wFwlTsno2xNr6efsk= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 558223858D35 for ; Wed, 26 Jan 2022 21:03:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 558223858D35 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-625-4xcU_gfMMwuceA6Xq518-Q-1; Wed, 26 Jan 2022 16:03:50 -0500 X-MC-Unique: 4xcU_gfMMwuceA6Xq518-Q-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 06F1A1853024; Wed, 26 Jan 2022 21:03:49 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.125]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 679BD4EC7F; Wed, 26 Jan 2022 21:03:47 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.16.1/8.16.1) with ESMTPS id 20QL3cT62382222 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 26 Jan 2022 22:03:39 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.16.1/8.16.1/Submit) id 20QL3aq82382221; Wed, 26 Jan 2022 22:03:36 +0100 Date: Wed, 26 Jan 2022 22:03:36 +0100 To: Segher Boessenkool , David Edelsohn Subject: [PATCH] rs6000: Fix up *intrin.h for C89 [PR104239] Message-ID: <20220126210336.GW2646553@tucnak> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_SHORT, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jakub Jelinek via Gcc-patches From: Jakub Jelinek Reply-To: Jakub Jelinek Cc: gcc-patches@gcc.gnu.org, "Paul A. Clarke" Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Hi! When writing testcases for the previously posted patch, I have noticed that 3 of the headers aren't valid C89 (I didn't have any dg-options so -ansi -pedantic-errors was implied and these errors were reported). The following patch fixes those, ok for trunk? Note, as can be seen even in this patch, seems older rs6000/*intrin.h headers uglify not just argument names (__A instead of A etc.), but also automatic variable names and other local identifiers, while e.g. emmintrin.h or bmi2intrin.h clearly uglify only the argument names and not local variables. I think that should be fixed but don't have time for that myself (libstdc++ or e.g. the x86 headers uglify everything; this is so that one can #define result a + b #include etc.). 2022-01-26 Jakub Jelinek PR target/104239 * config/rs6000/emmintrin.h (_mm_sad_epu8): Use __asm__ instead of asm. * config/rs6000/smmintrin.h (_mm_minpos_epu16): Declare iterator before for loop instead of for init clause. * config/rs6000/bmi2intrin.h (_pext_u64): Likewise. * gcc.target/powerpc/pr104239-3.c: New test. Jakub --- gcc/config/rs6000/emmintrin.h.jj 2022-01-11 22:56:21.316686838 +0000 +++ gcc/config/rs6000/emmintrin.h 2022-01-26 20:47:26.319336232 +0000 @@ -2215,7 +2215,7 @@ _mm_sad_epu8 (__m128i __A, __m128i __B) vsum = (__vector signed int) vec_sum4s (vabsdiff, zero); #ifdef __LITTLE_ENDIAN__ /* Sum across four integers with two integer results. */ - asm ("vsum2sws %0,%1,%2" : "=v" (result) : "v" (vsum), "v" (zero)); + __asm__ ("vsum2sws %0,%1,%2" : "=v" (result) : "v" (vsum), "v" (zero)); /* Note: vec_sum2s could be used here, but on little-endian, vector shifts are added that are not needed for this use-case. A vector shift to correctly position the 32-bit integer results --- gcc/config/rs6000/smmintrin.h.jj 2022-01-19 10:27:58.529911366 +0000 +++ gcc/config/rs6000/smmintrin.h 2022-01-26 20:48:05.720348812 +0000 @@ -687,7 +687,8 @@ _mm_minpos_epu16 (__m128i __A) union __u __u = { .__m = __A }, __r = { .__m = {0} }; unsigned short __ridx = 0; unsigned short __rmin = __u.__uh[__ridx]; - for (unsigned long __i = 1; __i < 8; __i++) + unsigned long __i; + for (__i = 1; __i < 8; __i++) { if (__u.__uh[__i] < __rmin) { --- gcc/config/rs6000/bmi2intrin.h.jj 2022-01-26 20:42:53.132315506 +0000 +++ gcc/config/rs6000/bmi2intrin.h 2022-01-26 20:46:33.687983641 +0000 @@ -115,10 +115,11 @@ _pext_u64 (unsigned long long __X, unsig the Power8 Bit permute instruction. */ if (__builtin_constant_p (__M) && (__builtin_popcountl (__M) <= 8)) { + long i; /* Also if the pext mask is constant, then the popcount is constant, we can evaluate the following loop at compile time and use a constant bit permute vector. */ - for (long i = 0; i < __builtin_popcountl (__M); i++) + for (i = 0; i < __builtin_popcountl (__M); i++) { c = __builtin_clzl (m); p = (p << 8) | c; --- gcc/testsuite/gcc.target/powerpc/pr104239-3.c.jj 2022-01-26 20:52:42.987474394 +0000 +++ gcc/testsuite/gcc.target/powerpc/pr104239-3.c 2022-01-26 20:52:36.547308886 +0000 @@ -0,0 +1,7 @@ +/* PR target/104239 */ +/* { dg-options "-O2 -mdejagnu-cpu=power8 -DNO_WARN_X86_INTRINSICS -std=c89" } */ +/* { dg-require-effective-target powerpc_p8vector_ok } */ + +#include + +int i;