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 268E93858D28 for ; Tue, 14 Dec 2021 16:12:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 268E93858D28 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-274-X55LOzlTPaOZQqc0AX6GBA-1; Tue, 14 Dec 2021 11:12:25 -0500 X-MC-Unique: X55LOzlTPaOZQqc0AX6GBA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A4B70760C0; Tue, 14 Dec 2021 16:12:23 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.2.16.169]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1731C74EB7; Tue, 14 Dec 2021 16:12:22 +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 1BEGCK87735869 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 14 Dec 2021 17:12:20 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.16.1/8.16.1/Submit) id 1BEGCJT2735868; Tue, 14 Dec 2021 17:12:19 +0100 Date: Tue, 14 Dec 2021 17:12:19 +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: <20211214161219.GX2646553@tucnak> Reply-To: Jakub Jelinek References: <20211214102828.GU2646553@tucnak> <80d628c2-ea0d-c542-b0bb-399d83b7292d@suse.cz> MIME-Version: 1.0 In-Reply-To: <80d628c2-ea0d-c542-b0bb-399d83b7292d@suse.cz> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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 16:12:29 -0000 On Tue, Dec 14, 2021 at 04:07:55PM +0100, Martin Liška wrote: > On 12/14/21 11:28, Jakub Jelinek wrote: > > Wouldn't this be better done only if field_val has the msb set > > Yes, updated in the attached patch. > > > and keep the CONVERT_EXPR otherwise (why isn't it NOP_EXPR?)? > > Dunno, but I can prepare a separate patch (likely stage1 material, > right)? Note that are other places that also use CONVERT_EXPR. > > Patch can bootstrap on x86_64-linux-gnu and survives regression tests. > > Ready to be installed? > Thanks, > Martin > From 227450e9f3a506fdfcff67aa45135fe31f3f91f6 Mon Sep 17 00:00:00 2001 > From: Martin Liska > Date: Mon, 13 Dec 2021 15:34:30 +0100 > Subject: [PATCH] i386: Fix emissing of __builtin_cpu_supports. > > 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 (do that > it mask == 31). > For "avx512vbmi2" argument, we return now 1 << 31, which is a > negative integer value. > --- > gcc/config/i386/i386-builtins.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/gcc/config/i386/i386-builtins.c b/gcc/config/i386/i386-builtins.c > index 0fb14b55712..bca244fc011 100644 > --- a/gcc/config/i386/i386-builtins.c > +++ b/gcc/config/i386/i386-builtins.c > @@ -2353,7 +2353,11 @@ 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); > + if (isa_names_table[i].feature == 31) > + return build2 (NE_EXPR, integer_type_node, final, > + build_int_cst (unsigned_type_node, 0)); > + else > + return build1 (CONVERT_EXPR, integer_type_node, final); > } > gcc_unreachable (); > } I'd use INT_TYPE_SIZE - 1 instead of 31. Otherwise LGTM. Jakub