From patchwork Tue Jan 31 08:09:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 50674 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2622677wrn; Tue, 31 Jan 2023 00:10:27 -0800 (PST) X-Google-Smtp-Source: AK7set8yiYhn4LVtKqDIfXpfoYWpqT+12CDGzXiBalww+Pgn2YM48jo4Nf9JcvHGik2AeK1L/90G X-Received: by 2002:a17:906:134e:b0:88c:bc3e:de46 with SMTP id x14-20020a170906134e00b0088cbc3ede46mr676355ejb.34.1675152627449; Tue, 31 Jan 2023 00:10:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675152627; cv=none; d=google.com; s=arc-20160816; b=oXSTcJvuOUQopMvChVN3wIHT43AVHTJDnV9fo02b2ejbbGHo3+DT9Lt4G+1rnvCeKF QeghUK5kuxbFWD/CegD2ae5ltlRdycYrymGkCsXbJSlS3jduNS5jW2vsF+0uUXUQozfh oQaB4jH1wCilw7f5ahKIMAZ8FzYhAcqZ1JfWY4lGU07fWG7hKWl3OvzHGJfzkepWSGJs MI9D97Sj5eHkMIH4eDjg6lvcZKUI5vwcMg4UscOk6/QtEnpMdEFC9Jh/TH3wUFng7/d0 qGUgZQIjLqaimcqgOzi49UnhQhcDE+OFjIR0YNGDxtiFCHMTBbjk6DgSduTsIGbOwTMD BzqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-disposition:mime-version:message-id:subject:cc:to:date :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=COhEBUODxzlkOrKqAw0uvYQm3bh3wZbXXWH+91W98NI=; b=Un64pJWgzSaTGJqucP92oTcTae8hAHCLxz7GRY44ykYMNGkmTGhYfq3ONrM5rowyj6 JQ4gXXZ5uDy1La7gRuUGPnMsV9ZAa+5LQ91W++fX3B1UImsug/n0LIg8H+8djz3JmIwh T7pTbCO1uw540nvzeVsKkcV7RmVlNmMs8B+NEmQz4AwPxrJk1j3jokV/SAlV5GMvh3Y1 qwV1QnoQx4kJWBJGg6NsPFbXRaHcUkzWB7Bc1tWlBEy3u6a+N8MPKyIShg2YSqSr/xgX lWZQI3mke6ejidC+2Rh8n5ksjvlxnwxnMxsa42NM6iJH18aXvbVDaJwxI+x+9vdSGOyq mcXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=deQhTWxf; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id b5-20020a05640202c500b0048ccd99d3fasi17621676edx.482.2023.01.31.00.10.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Jan 2023 00:10:27 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=deQhTWxf; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5FC543858C62 for ; Tue, 31 Jan 2023 08:10:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5FC543858C62 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1675152626; bh=COhEBUODxzlkOrKqAw0uvYQm3bh3wZbXXWH+91W98NI=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=deQhTWxf6SbGnafEyu44vdsGGAgSSe6WupJ0MkHq9EaupZop7+52Oys1Z14lFj5Xt rBk23v+u8++Ic5lMRHkTWZ5bxuJLlf5lLhWcGlMuwmampl0tarGKm7d9Lc2LtR+46g j6c5AnLAbj/W3wizupreeqbFKX0H9F1qW+pG9w0g= 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 872863858D1E for ; Tue, 31 Jan 2023 08:09:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 872863858D1E Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-167-7xrv3SBoNAydDBmW4RHWPw-1; Tue, 31 Jan 2023 03:09:29 -0500 X-MC-Unique: 7xrv3SBoNAydDBmW4RHWPw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8160E3847982; Tue, 31 Jan 2023 08:09:29 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.223]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3D134175A2; Tue, 31 Jan 2023 08:09:29 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 30V89QUB1011592 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 31 Jan 2023 09:09:26 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 30V89P6e1011591; Tue, 31 Jan 2023 09:09:25 +0100 Date: Tue, 31 Jan 2023 09:09:25 +0100 To: Hongtao Liu , Uros Bizjak Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] i386: Fix up -Wuninitialized warnings in avx512erintrin.h [PR105593] Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-3.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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 Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756524841639059310?= X-GMAIL-MSGID: =?utf-8?q?1756524841639059310?= Hi! As reported in the PR, there are some -Wuninitialized warnings in avx512erintrin.h. One can see that by compiling sse-23.c testcase with -Wuninitialized (or when actually using those intrinsics). Those 6 spots use an uninitialized variable and pass it as one of the argument to a builtin with constant mask -1, because there is no unmasked builtin. It is true that expansion of those builtins into RTL will see mask is all ones and ignore the unneeded argument, but -Wuninitialized is diagnosed on GIMPLE and on GIMPLE these builtins are just builtin calls. avx512fintrin.h and other headers use in these cases the _mm*_undefined_* () intrinsics, like: return (__m512i) __builtin_ia32_psrav8di_mask ((__v8di) __X, (__v8di) __Y, (__v8di) _mm512_undefined_epi32 (), (__mmask8) -1); etc. and the following patch does the same for avx512erintrin.h. With the recent changes in C++ FE and the _mm*_undefined_* intrinsics, we don't emit -Wuninitialized warnings for those (previously we didn't just in C due to self-initialization). Of course we could also just self-initialize these uninitialized vars and add the #pragma GCC diagnostic dances around it, but using the intrinsics is consistent with the rest and IMHO cleaner. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2023-01-31 Jakub Jelinek PR c++/105593 * config/i386/avx512erintrin.h (_mm512_exp2a23_round_pd, _mm512_exp2a23_round_ps, _mm512_rcp28_round_pd, _mm512_rcp28_round_ps, _mm512_rsqrt28_round_pd, _mm512_rsqrt28_round_ps): Use _mm512_undefined_pd () or _mm512_undefined_ps () instead of using uninitialized automatic variable __W. * gcc.target/i386/sse-23.c: Add -Wuninitialized to dg-options. Jakub --- gcc/config/i386/avx512erintrin.h.jj 2023-01-16 11:52:15.944736113 +0100 +++ gcc/config/i386/avx512erintrin.h 2023-01-30 20:53:08.057769691 +0100 @@ -51,9 +51,8 @@ extern __inline __m512d __attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) _mm512_exp2a23_round_pd (__m512d __A, int __R) { - __m512d __W; return (__m512d) __builtin_ia32_exp2pd_mask ((__v8df) __A, - (__v8df) __W, + (__v8df) _mm512_undefined_pd (), (__mmask8) -1, __R); } @@ -79,9 +78,8 @@ extern __inline __m512 __attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) _mm512_exp2a23_round_ps (__m512 __A, int __R) { - __m512 __W; return (__m512) __builtin_ia32_exp2ps_mask ((__v16sf) __A, - (__v16sf) __W, + (__v16sf) _mm512_undefined_ps (), (__mmask16) -1, __R); } @@ -107,9 +105,8 @@ extern __inline __m512d __attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) _mm512_rcp28_round_pd (__m512d __A, int __R) { - __m512d __W; return (__m512d) __builtin_ia32_rcp28pd_mask ((__v8df) __A, - (__v8df) __W, + (__v8df) _mm512_undefined_pd (), (__mmask8) -1, __R); } @@ -135,9 +132,8 @@ extern __inline __m512 __attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) _mm512_rcp28_round_ps (__m512 __A, int __R) { - __m512 __W; return (__m512) __builtin_ia32_rcp28ps_mask ((__v16sf) __A, - (__v16sf) __W, + (__v16sf) _mm512_undefined_ps (), (__mmask16) -1, __R); } @@ -229,9 +225,8 @@ extern __inline __m512d __attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) _mm512_rsqrt28_round_pd (__m512d __A, int __R) { - __m512d __W; return (__m512d) __builtin_ia32_rsqrt28pd_mask ((__v8df) __A, - (__v8df) __W, + (__v8df) _mm512_undefined_pd (), (__mmask8) -1, __R); } @@ -257,9 +252,8 @@ extern __inline __m512 __attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) _mm512_rsqrt28_round_ps (__m512 __A, int __R) { - __m512 __W; return (__m512) __builtin_ia32_rsqrt28ps_mask ((__v16sf) __A, - (__v16sf) __W, + (__v16sf) _mm512_undefined_ps (), (__mmask16) -1, __R); } --- gcc/testsuite/gcc.target/i386/sse-23.c.jj 2022-11-07 10:30:42.831628746 +0100 +++ gcc/testsuite/gcc.target/i386/sse-23.c 2023-01-30 20:48:28.858838817 +0100 @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -Werror-implicit-function-declaration -march=k8" } */ +/* { dg-options "-O2 -Werror-implicit-function-declaration -Wuninitialized -march=k8" } */ /* { dg-add-options bind_pic_locally } */ #include