From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id E75693858406 for ; 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 ); Tue, 14 Dec 2021 09:55:01 +0000 Message-ID: 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?= Subject: [PATCH] i386: Fix emissing of __builtin_cpu_supports. To: gcc-patches@gcc.gnu.org Content-Language: en-US Cc: Stefan Kneifel 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Dec 2021 09:55:04 -0000 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 (); } -- 2.34.1