From patchwork Wed Jul 24 12:07:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 1964264 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=GOWA/YFb; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=h4byy1uP; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=GOWA/YFb; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=h4byy1uP; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WTXpy6l9vz1yXx for ; Wed, 24 Jul 2024 22:08:26 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1B61D3858D29 for ; Wed, 24 Jul 2024 12:08:25 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2a07:de40:b251:101:10:150:64:2]) by sourceware.org (Postfix) with ESMTPS id 953203858D26 for ; Wed, 24 Jul 2024 12:07:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 953203858D26 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 953203858D26 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a07:de40:b251:101:10:150:64:2 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1721822885; cv=none; b=ll/sUBPyKV4ER+1ceUEM3DIZZtZ916jWM4oa04ND54WAeyH2DxL2jtSxMpjEhWYvdJLtiJoX3oHdOQQJTvmsIAQSK39iXUxUSoxQFrhyzRjqDaG07DVOjAnx44naPm5pOiIbXus6W+VqmWVP7wUejU9l+TRD5OcLp9iDj7fySr0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1721822885; c=relaxed/simple; bh=vL75fpcK1DnO9M0psL9Qq0+z3YRTuNrqXn5yVUKqBP0=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:Date: From:To:Subject:MIME-Version; b=lrDHh5J9T+SvTRTLYkPxZDJwt0cs3B4+CJPhPPoCjxWw0HA+oMkIj8XIdunVKQL+F8Xrr+QAD4lWmaVYxYUA/o6tp2bUzgocwyFNQC6WLTQFW+qBLre1nuAJJKreGIuKRkZL9T8IV6GTiSJLHp/5ZcD5K+d5jXtOtEm8HSRRXj4= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from murzim.nue2.suse.org (unknown [10.168.4.243]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 95BDD1F797 for ; Wed, 24 Jul 2024 12:07:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1721822873; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=hi986NOh5NlVtILikCqj6VRUUNgHpIGmnciKyjhQgoc=; b=GOWA/YFbqrrmT5AyqJyb9h25Z65uvyPjlkXmmhFB6lmPe++A9xxnC0Ox0gEjD5wismR6NN 8S7vZGFK9Bo7i54Sp0UUFn12ekd/5EJI5i53iFoxmVHW3XjB6c33Z6GZVGmJSmxC9sJwYs 5nuBWKbX6PzDbmz1Pej9ZXCqtWgQp2I= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1721822873; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=hi986NOh5NlVtILikCqj6VRUUNgHpIGmnciKyjhQgoc=; b=h4byy1uPfPXPS2wnP2LViZPtquZvgpWgGePQME/BbyGVtJ8Ll92KRLci/NDTMBnEBu6mVa IAUkvEIi4eDwmlDA== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1721822873; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=hi986NOh5NlVtILikCqj6VRUUNgHpIGmnciKyjhQgoc=; b=GOWA/YFbqrrmT5AyqJyb9h25Z65uvyPjlkXmmhFB6lmPe++A9xxnC0Ox0gEjD5wismR6NN 8S7vZGFK9Bo7i54Sp0UUFn12ekd/5EJI5i53iFoxmVHW3XjB6c33Z6GZVGmJSmxC9sJwYs 5nuBWKbX6PzDbmz1Pej9ZXCqtWgQp2I= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1721822873; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=hi986NOh5NlVtILikCqj6VRUUNgHpIGmnciKyjhQgoc=; b=h4byy1uPfPXPS2wnP2LViZPtquZvgpWgGePQME/BbyGVtJ8Ll92KRLci/NDTMBnEBu6mVa IAUkvEIi4eDwmlDA== Date: Wed, 24 Jul 2024 14:07:53 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] tree-optimization/116057 - wrong code with CCP and vector CTORs MIME-Version: 1.0 X-Spamd-Result: default: False [2.39 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_SPAM_LONG(2.99)[0.855]; MISSING_MID(2.50)[]; MIME_GOOD(-0.10)[text/plain]; RCVD_COUNT_ZERO(0.00)[0]; ARC_NA(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; MISSING_XM_UA(0.00)[]; FROM_HAS_DN(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; TO_DN_NONE(0.00)[]; MIME_TRACE(0.00)[0:+] X-Spam-Score: 2.39 X-Spam-Status: No, score=-10.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, MISSING_MID, SPF_HELO_NONE, SPF_PASS, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org Message-Id: <20240724120825.1B61D3858D29@sourceware.org> The following fixes an issue with CCPs likely_value when faced with a vector CTOR containing undef SSA names and constants. This should be classified as CONSTANT and not UNDEFINED. Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. PR tree-optimization/116057 * tree-ssa-ccp.cc (likely_value): Also walk CTORs in stmt operands to look for constants. * gcc.dg/torture/pr116057.c: New testcase. --- gcc/testsuite/gcc.dg/torture/pr116057.c | 20 ++++++++++++++++++++ gcc/tree-ssa-ccp.cc | 11 +++++++++++ 2 files changed, 31 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/torture/pr116057.c diff --git a/gcc/testsuite/gcc.dg/torture/pr116057.c b/gcc/testsuite/gcc.dg/torture/pr116057.c new file mode 100644 index 00000000000..a7021c8e746 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr116057.c @@ -0,0 +1,20 @@ +/* { dg-do run } */ +/* { dg-additional-options "-Wno-psabi" } */ + +#define vect8 __attribute__((vector_size(8))) + +vect8 int __attribute__((noipa)) +f(int a) +{ + int b; + vect8 int t={1,1}; + if(a) return t; + return (vect8 int){0, b}; +} + +int main () +{ + if (f(0)[0] != 0) + __builtin_abort (); + return 0; +} diff --git a/gcc/tree-ssa-ccp.cc b/gcc/tree-ssa-ccp.cc index de83d26d311..44711018e0e 100644 --- a/gcc/tree-ssa-ccp.cc +++ b/gcc/tree-ssa-ccp.cc @@ -762,6 +762,17 @@ likely_value (gimple *stmt) continue; if (is_gimple_min_invariant (op)) has_constant_operand = true; + else if (TREE_CODE (op) == CONSTRUCTOR) + { + unsigned j; + tree val; + FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (op), j, val) + if (CONSTANT_CLASS_P (val)) + { + has_constant_operand = true; + break; + } + } } if (has_constant_operand)