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.133.124]) by sourceware.org (Postfix) with ESMTPS id 9799B3858400 for ; Tue, 14 Dec 2021 10:28:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9799B3858400 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-518-Nwj2ZHx6P9aGr-UBrSeSiw-1; Tue, 14 Dec 2021 05:28:33 -0500 X-MC-Unique: Nwj2ZHx6P9aGr-UBrSeSiw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D37711808327; Tue, 14 Dec 2021 10:28:32 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.2.16.169]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 43C0F1972E; Tue, 14 Dec 2021 10:28:32 +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 1BEASTen707643 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 14 Dec 2021 11:28:30 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.16.1/8.16.1/Submit) id 1BEASSBA707642; Tue, 14 Dec 2021 11:28:28 +0100 Date: Tue, 14 Dec 2021 11:28:28 +0100 From: Jakub Jelinek To: Martin =?utf-8?B?TGnFoWth?= Cc: gcc-patches@gcc.gnu.org, Stefan Kneifel Subject: Re: [PATCH] i386: Fix emissing of __builtin_cpu_supports. Message-ID: <20211214102828.GU2646553@tucnak> Reply-To: Jakub Jelinek References: MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, 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-List-Received-Date: Tue, 14 Dec 2021 10:28:42 -0000 On Tue, Dec 14, 2021 at 10:55:01AM +0100, Martin Liška wrote: > The patch fixes __builtin_cpu_supports("avx512vbmi2") which returns a negative > value (that's not allowed in the documentation). > > I also checked ppc target that does the same, and __builtin_cpu_is, which > are fine. > > Patch can bootstrap on x86_64-linux-gnu and survives regression tests. > > Ready to be installed? > Thanks, > Martin > > PR target/103661 > > gcc/ChangeLog: > > * config/i386/i386-builtins.c (fold_builtin_cpu): Compare to 0 > as API expects that non-zero values are returned. For > "avx512vbmi2" argument, we return now 1 << 31, which is a > negative integer value. > --- > gcc/config/i386/i386-builtins.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/gcc/config/i386/i386-builtins.c b/gcc/config/i386/i386-builtins.c > index 0fb14b55712..7e57b665c1e 100644 > --- a/gcc/config/i386/i386-builtins.c > +++ b/gcc/config/i386/i386-builtins.c > @@ -2353,7 +2353,8 @@ fold_builtin_cpu (tree fndecl, tree *args) > /* Return __cpu_model.__cpu_features[0] & field_val */ > final = build2 (BIT_AND_EXPR, unsigned_type_node, array_elt, > build_int_cstu (unsigned_type_node, field_val)); > - return build1 (CONVERT_EXPR, integer_type_node, final); > + return build2 (NE_EXPR, integer_type_node, final, > + build_int_cst (unsigned_type_node, 0)); > } > gcc_unreachable (); > } Wouldn't this be better done only if field_val has the msb set and keep the CONVERT_EXPR otherwise (why isn't it NOP_EXPR?)? Jakub