From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 194A43858D38 for ; Tue, 23 Apr 2024 08:18:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 194A43858D38 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 194A43858D38 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=1713860287; cv=none; b=ZS7dGKJ0IU8zYQd6iBPQ0cYERCqKPKV+8+cLzzWuJ2ZJG5aLVwMIGX5boFZ4YOmQ7p+q3XOv9mfnP2vmFy9mfrT8HUIPFNs52x3BuF4Hy6ABXVQ0iZqgaVFAX0LRe1ZtD1JBIS6wMtgNECKzWSxRqJKteEIWUt1qBdrMb0ejN6s= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713860287; c=relaxed/simple; bh=YwvP1nwBr2ibNElbLb4dTSythOtX5gdqoZ3MoOAt6Ms=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:Date: From:To:Subject:MIME-Version; b=pKwk9re7gd4XjXruS7c5uVD14GvrOW9ZIcHhCIzJMjWZZIyzvRyxAvDbimR9MrQ5xiLdDruT98Yg+5OvQxTt4QF3lVvFzokEDPl+iunn7Q2WGGQVhQPahLQaY1A/PFqr8FcN1x8Fo3CL2c04nXjXyp/ie8/WuqWCo3lsbsbodFo= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from [10.168.5.241] (unknown [10.168.5.241]) (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 ED1295FB5A for ; Tue, 23 Apr 2024 08:18:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1713860281; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=edSAHOG3C+vuBjjUjeb93tytfnig5461E+Zvmx2cXbM=; b=RNVB6YepKYOQHEAdksElBzDWhxfBUNCny/draRZXuU0YVGzz30OG7XkzATQf9x16t+yg9H 4inM3U8vnLGgKywrxnoBaFSbf5fSon2UkSgpJGV1ceH4D2vxT8ErRh8ZuOFK67RThItFt3 Wf/gBIrQvQiRCRDqfOWROdrPQcwuA1g= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1713860281; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=edSAHOG3C+vuBjjUjeb93tytfnig5461E+Zvmx2cXbM=; b=RByqRtHz9Q+kO7uWywYy8iKXMQ2Bea+7D2Ei/CBoCFMrjenNEkPb8EwshqkudEzNujPukO gf4jSF0aB6WnA4CA== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1713860280; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=edSAHOG3C+vuBjjUjeb93tytfnig5461E+Zvmx2cXbM=; b=vGf3Ux/RHXMO25mRpmX3ElDzu9ymD+HPjyVFW0spR/+AckEUt18RzkE+kTaeApY9UuV2DA Ee3elnCuNrdeWtqMDCDUUvpMc7VLW/5tlr7QfxLJ/gUiriVJZDmrODAdAvfQqa7aLn4MHW 3Y1OMLj5ydaizgIkjZ3SeLi1nB2zbAE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1713860280; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=edSAHOG3C+vuBjjUjeb93tytfnig5461E+Zvmx2cXbM=; b=9J3XBlYqQ5Q+ydbrGlptIDk4uA7OUzYgaLIcIvm3ArtXxE+qvQ7FpWnmzJ0UXgeZ3i8aHf QZ6UcIaxExrbL7Aw== Date: Tue, 23 Apr 2024 10:18:00 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] tree-optimization/114799 - SLP and patterns MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Level: X-Spamd-Result: default: False [0.20 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MISSING_MID(2.50)[]; NEURAL_SPAM_SHORT(1.77)[0.590]; NEURAL_HAM_LONG(-0.97)[-0.969]; MIME_GOOD(-0.10)[text/plain]; ARC_NA(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; MISSING_XM_UA(0.00)[]; RCVD_COUNT_ZERO(0.00)[0]; FROM_HAS_DN(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FROM_EQ_ENVFROM(0.00)[]; TO_DN_NONE(0.00)[]; MIME_TRACE(0.00)[0:+] X-Spam-Score: 0.20 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 List-Id: Message-ID: <20240423081800.D5V7XYQ3Knp3OjdH8lylPJg8nb3Th_zLosNaFVDAqCc@z> The following plugs a hole with computing whether a SLP node has any pattern stmts which is important to know when we want to replace it by a CTOR from external defs. Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. PR tree-optimization/114799 * tree-vect-slp.cc (vect_get_and_check_slp_defs): Properly update ->any_pattern when swapping operands. * gcc.dg/vect/bb-slp-pr114799.c: New testcase. --- gcc/testsuite/gcc.dg/vect/bb-slp-pr114799.c | 16 ++++++++++++++++ gcc/tree-vect-slp.cc | 6 ++++++ 2 files changed, 22 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/vect/bb-slp-pr114799.c diff --git a/gcc/testsuite/gcc.dg/vect/bb-slp-pr114799.c b/gcc/testsuite/gcc.dg/vect/bb-slp-pr114799.c new file mode 100644 index 00000000000..70572fe703b --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/bb-slp-pr114799.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-fno-tree-forwprop" } */ + +unsigned long x; +unsigned char y; + +void +foo (void) +{ + unsigned long tt = y; + tt+=255; + unsigned short t1 = tt; + t1 = 254 - t1; + tt += ((unsigned long)t1); + x = tt; +} diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc index 109f318c7d6..3eb326d20b5 100644 --- a/gcc/tree-vect-slp.cc +++ b/gcc/tree-vect-slp.cc @@ -888,6 +888,12 @@ vect_get_and_check_slp_defs (vec_info *vinfo, unsigned char swap, (*oprnds_info)[i+1]->def_stmts[stmt_num]); std::swap ((*oprnds_info)[i]->ops[stmt_num], (*oprnds_info)[i+1]->ops[stmt_num]); + /* After swapping some operands we lost track whether an + operand has any pattern defs so be conservative here. */ + if ((*oprnds_info)[i]->any_pattern + || (*oprnds_info)[i+1]->any_pattern) + (*oprnds_info)[i]->any_pattern + = (*oprnds_info)[i+1]->any_pattern = true; swapped = true; continue; } -- 2.35.3