From patchwork Fri Jan 13 00:36:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 42884 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp3675wrt; Thu, 12 Jan 2023 16:37:06 -0800 (PST) X-Google-Smtp-Source: AMrXdXsf+AJ+p///vkXM7TlcKkn7GEtw4rrZ44NSyt9bnyotgT2ZuS+uozuO7eKg14JzXHJPS/ds X-Received: by 2002:a17:906:6881:b0:84d:4d6c:a462 with SMTP id n1-20020a170906688100b0084d4d6ca462mr13009931ejr.25.1673570226060; Thu, 12 Jan 2023 16:37:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673570226; cv=none; d=google.com; s=arc-20160816; b=NruWesBXFIsL4FSxq8fHWVBQbkyqXL+EwbVVHw/7hGAsulDLQVvqXprH37PAZHHZDP JrhsnrFEBX3VHqBtCs8vY611BdaGpgxp9oAArANPioYSKtRHTwppQTgBz9+tZJJauZTp 4ejKQSBxjYb3tWCfwws+LNx+0xSB9RmDj2M681cuusVh6XhSyiJiwgNwc7Qz29MI4uem gY6Ve3081h7z77CE2m4l+wgnCjFJJt37EgdSFHmrKeP8imtFE9fYSUkMkcxo7E3+vgMD gMLoHiS/YX+Q98VoOWWi6WOBz/ddlHGLQzb469WPPmBAb1UExGzhc06lpyUnGe478JEF Etew== 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=Dx5x4/tY31o1VYo9rchHqjaeQvsuKlA+TPxWzPTGzkM=; b=Vihv5hdsL4/eVy3WYWXsg9BwZyTAvI9ZHh21FigPC/VJIH4f4HniVv0OFgHR1ZGbze PFYUmqE2yit4ihe/wEoAuOJRwwRhko2nxQ9Hx+ymTt7gEo2+Qxy+I8DvmfxMa6qHnW8d lTqdSbN+ePvQLOQMK2UeBjO7nZ4vn4UHusZG3ry4k5bGzO731HjKwH+rKy0zUVpKoG3l Nwr82wUX1kDXbQCev+AHuAjCFB5mMjI17fzVsAGThdhcvEbRemJcKFdPnJs1xj/9BFbG +11udiA4QL1naqMYTDhdwlCFTRXwFT2a7EmJVZdw6wQO6yVE+VLLqR6suTXg158qx7KC 0S+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=vY6ufZEl; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id hs9-20020a1709073e8900b0086a9cbb1c34si198345ejc.361.2023.01.12.16.37.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Jan 2023 16:37:06 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=vY6ufZEl; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 CE62F3858C74 for ; Fri, 13 Jan 2023 00:37:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CE62F3858C74 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1673570224; bh=Dx5x4/tY31o1VYo9rchHqjaeQvsuKlA+TPxWzPTGzkM=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=vY6ufZEl+0eF1wlQewX8O+lFi7Sf2ZR1vEbhIknEGE3TSz3uR3fH0P39cHq574Wl8 BJDIxIHwv+ckSHha8w2N2o+e0y7vTY+UuQITs7qwvawxnicbO/V3VDUMRw+WWIndRX SU+mINcaxGkJrkkfaHa+WSlL3ebh+7+lyCVF5p90= 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.133.124]) by sourceware.org (Postfix) with ESMTPS id 56DD03858C66 for ; Fri, 13 Jan 2023 00:36:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 56DD03858C66 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-282-PgEzRLD-Nka3vYqKQtqZKA-1; Thu, 12 Jan 2023 19:36:09 -0500 X-MC-Unique: PgEzRLD-Nka3vYqKQtqZKA-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6786A3C02543; Fri, 13 Jan 2023 00:36:09 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.223]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2001D140EBF6; Fri, 13 Jan 2023 00:36:09 +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 30D0a6pU1350338 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 13 Jan 2023 01:36:06 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 30D0a5FN1350337; Fri, 13 Jan 2023 01:36:05 +0100 Date: Fri, 13 Jan 2023 01:36:05 +0100 To: Uros Bizjak Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] x86: Avoid -Wuninitialized warnings on _mm*_undefined_* in C++ [PR105593] Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 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?1754865573071302557?= X-GMAIL-MSGID: =?utf-8?q?1754865573071302557?= Hi! In https://gcc.gnu.org/pipermail/gcc-patches/2023-January/609844.html I've posted a patch to allow ignoring -Winit-self using GCC diagnostic pragmas, such that one can mark self-initialization as intentional disabling of -Wuninitialized warnings. The following incremental patch uses that in the x86 intrinsic headers. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk if the above mentioned patch is approved/committed? 2023-01-13 Jakub Jelinek PR c++/105593 gcc/ * config/i386/xmmintrin.h (_mm_undefined_ps): Temporarily disable -Winit-self using pragma GCC diagnostic ignored. * config/i386/emmintrin.h (_mm_undefined_pd, _mm_undefined_si128): Likewise. * config/i386/avxintrin.h (_mm256_undefined_pd, _mm256_undefined_ps, _mm256_undefined_si256): Likewise. * config/i386/avx512fintrin.h (_mm512_undefined_pd, _mm512_undefined_ps, _mm512_undefined_epi32): Likewise. * config/i386/avx512fp16intrin.h (_mm_undefined_ph, _mm256_undefined_ph, _mm512_undefined_ph): Likewise. gcc/testsuite/ * g++.target/i386/pr105593.C: New test. Jakub --- gcc/config/i386/xmmintrin.h.jj 2022-11-07 10:30:42.741629972 +0100 +++ gcc/config/i386/xmmintrin.h 2023-01-12 15:33:21.685483809 +0100 @@ -112,7 +112,10 @@ typedef float __v4sf __attribute__ ((__v extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__)) _mm_undefined_ps (void) { +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Winit-self" __m128 __Y = __Y; +#pragma GCC diagnostic pop return __Y; } --- gcc/config/i386/emmintrin.h.jj 2022-03-14 14:48:04.299055735 +0100 +++ gcc/config/i386/emmintrin.h 2023-01-12 15:33:04.148735997 +0100 @@ -99,7 +99,10 @@ _mm_setr_pd (double __W, double __X) extern __inline __m128d __attribute__((__gnu_inline__, __always_inline__, __artificial__)) _mm_undefined_pd (void) { +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Winit-self" __m128d __Y = __Y; +#pragma GCC diagnostic pop return __Y; } @@ -785,7 +788,10 @@ _mm_move_epi64 (__m128i __A) extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__)) _mm_undefined_si128 (void) { +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Winit-self" __m128i __Y = __Y; +#pragma GCC diagnostic pop return __Y; } --- gcc/config/i386/avxintrin.h.jj 2022-01-11 23:11:21.763298965 +0100 +++ gcc/config/i386/avxintrin.h 2023-01-12 15:34:15.395711408 +0100 @@ -1207,21 +1207,30 @@ _mm256_movemask_ps (__m256 __A) extern __inline __m256d __attribute__((__gnu_inline__, __always_inline__, __artificial__)) _mm256_undefined_pd (void) { +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Winit-self" __m256d __Y = __Y; +#pragma GCC diagnostic pop return __Y; } extern __inline __m256 __attribute__((__gnu_inline__, __always_inline__, __artificial__)) _mm256_undefined_ps (void) { +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Winit-self" __m256 __Y = __Y; +#pragma GCC diagnostic pop return __Y; } extern __inline __m256i __attribute__((__gnu_inline__, __always_inline__, __artificial__)) _mm256_undefined_si256 (void) { +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Winit-self" __m256i __Y = __Y; +#pragma GCC diagnostic pop return __Y; } --- gcc/config/i386/avx512fintrin.h.jj 2022-04-25 13:54:38.277309716 +0200 +++ gcc/config/i386/avx512fintrin.h 2023-01-12 15:35:09.868928035 +0100 @@ -185,7 +185,10 @@ extern __inline __m512 __attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) _mm512_undefined_ps (void) { +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Winit-self" __m512 __Y = __Y; +#pragma GCC diagnostic pop return __Y; } @@ -195,7 +198,10 @@ extern __inline __m512d __attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) _mm512_undefined_pd (void) { +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Winit-self" __m512d __Y = __Y; +#pragma GCC diagnostic pop return __Y; } @@ -203,7 +209,10 @@ extern __inline __m512i __attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) _mm512_undefined_epi32 (void) { +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Winit-self" __m512i __Y = __Y; +#pragma GCC diagnostic pop return __Y; } --- gcc/config/i386/avx512fp16intrin.h.jj 2022-11-21 10:28:24.284544313 +0100 +++ gcc/config/i386/avx512fp16intrin.h 2023-01-12 15:35:41.070479329 +0100 @@ -204,7 +204,10 @@ extern __inline __m128h __attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) _mm_undefined_ph (void) { +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Winit-self" __m128h __Y = __Y; +#pragma GCC diagnostic pop return __Y; } @@ -212,7 +215,10 @@ extern __inline __m256h __attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) _mm256_undefined_ph (void) { +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Winit-self" __m256h __Y = __Y; +#pragma GCC diagnostic pop return __Y; } @@ -220,7 +226,10 @@ extern __inline __m512h __attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) _mm512_undefined_ph (void) { +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Winit-self" __m512h __Y = __Y; +#pragma GCC diagnostic pop return __Y; } --- gcc/testsuite/g++.target/i386/pr105593.C.jj 2023-01-12 15:58:59.668363504 +0100 +++ gcc/testsuite/g++.target/i386/pr105593.C 2023-01-12 16:01:17.785377769 +0100 @@ -0,0 +1,20 @@ +// PR c++/105593 +// { dg-do compile { target c++14 } } +// { dg-options "-mavx512fp16 -W -Wall -O2" } + +#include + +auto f1 () { return _mm_undefined_pd (); } +auto f2 () { return _mm_undefined_ps (); } +auto f3 () { return _mm_undefined_si128 (); } +auto f4 () { return _mm_undefined_ph (); } +auto f5 () { return _mm256_undefined_pd (); } +auto f6 () { return _mm256_undefined_ps (); } +auto f7 () { return _mm256_undefined_si256 (); } +auto f8 () { return _mm256_undefined_ph (); } +auto f9 () { return _mm512_undefined_pd (); } +auto f10 () { return _mm512_undefined_ps (); } +auto f11 () { return _mm512_undefined_epi32 (); } +auto f12 () { return _mm512_undefined_ph (); } + +// { dg-bogus "is used uninitialized" "" { target *-*-* } 0 }