From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675152574; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type; bh=COhEBUODxzlkOrKqAw0uvYQm3bh3wZbXXWH+91W98NI=; b=Ax/22KWyte3E9wC7nTTCY9Fg8r/Dn3bLU+6k4eSkmzn402tOMMEy/YjECG46mxrDIxUpw2 KlRarKoh2EtvfjX4BVYPDy522Wq7zf7I5+siiHKscQ7ph+A9AKAFaGHyDb9ZqPGjzUvwFp o4Zd0QJgbkMHTzs+uaXIqZh27Y+K5Sg= 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 From: Jakub Jelinek To: Hongtao Liu , Uros Bizjak Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] i386: Fix up -Wuninitialized warnings in avx512erintrin.h [PR105593] Message-ID: Reply-To: Jakub Jelinek 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-Type: text/plain; charset=us-ascii 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 List-Id: 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. --- 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 Jakub