Message ID | aebba1a8-0b9c-ab1a-49bd-7b54186dce9d@suse.cz |
---|---|
State | New |
Headers |
Return-Path: <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E2EDF3858409 for <patchwork@sourceware.org>; Tue, 14 Dec 2021 09:55:19 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id E75693858406 for <gcc-patches@gcc.gnu.org>; Tue, 14 Dec 2021 09:55:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E75693858406 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.cz Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id AE4C321125; Tue, 14 Dec 2021 09:55:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1639475701; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=5yU4XUeKDBeHhBuUCKk2JAvZ2oTV5OBdMFXO2js2B9k=; b=proUdVT8DWNfuGGvKuEfVIP0NkbaZorFuvAT/JaYxdDAg2oIDVsLUhHoeyTxFVis4GTfBq Qrkmm36UfGP8UA9W0YSGEMGn3T7zgiLlGBfI+j/bub/XbBBwLorJBR2/+Kh2IcSstCLsZQ m+iS6TpcIdZ1uWjwKP6aIr/BSsX4BUo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1639475701; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=5yU4XUeKDBeHhBuUCKk2JAvZ2oTV5OBdMFXO2js2B9k=; b=c5CqnzilceBgZjsHb95/3gqaB0jFLBI1gEr+rOxD7DCedPm5Rnoku1rIMAyvBBY57F3Wa6 BHka0hvgh/59LRAQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 9BF0113BA4; Tue, 14 Dec 2021 09:55:01 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id yH8dJfVpuGH5PQAAMHmgww (envelope-from <mliska@suse.cz>); Tue, 14 Dec 2021 09:55:01 +0000 Message-ID: <aebba1a8-0b9c-ab1a-49bd-7b54186dce9d@suse.cz> Date: Tue, 14 Dec 2021 10:55:01 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.4.0 From: =?utf-8?q?Martin_Li=C5=A1ka?= <mliska@suse.cz> Subject: [PATCH] i386: Fix emissing of __builtin_cpu_supports. To: gcc-patches@gcc.gnu.org Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, 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 <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> Cc: Stefan Kneifel <stefan.kneifel@bluewin.ch> Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> |
Series |
i386: Fix emissing of __builtin_cpu_supports.
|
|
Commit Message
Martin Liška
Dec. 14, 2021, 9:55 a.m. UTC
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(-)
Comments
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
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
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 <mliska@suse.cz> > 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
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 (); }