From patchwork Fri Oct 25 11:57:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Oliva X-Patchwork-Id: 2002364 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=Z6phsCd6; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; 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 [IPv6:2620:52:3:1:0:246e:9693:128c]) (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 4XZn5X5b0Mz1xwF for ; Sat, 26 Oct 2024 02:39:28 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B8E883858CDA for ; Fri, 25 Oct 2024 15:39:26 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pg1-x534.google.com (mail-pg1-x534.google.com [IPv6:2607:f8b0:4864:20::534]) by sourceware.org (Postfix) with ESMTPS id 66CE53858D21 for ; Fri, 25 Oct 2024 15:39:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 66CE53858D21 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 66CE53858D21 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::534 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1729870743; cv=none; b=B0PohRO9B5Atl5SwxrApljUbCrpPQFGXWKIB8gDjRub2Li96fiGURW4ahLgwNhdJm2gVwo8DuxdOiCsbr2miv/WV6YHjBblk5a21zS+u9V0CpoVTFYv4wmcOxilzGi+hRJRcuvkj/EmcgmdhgnPCHHtbBqLWvNLqJQQBteZqR1o= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1729870743; c=relaxed/simple; bh=qUGRzNZP6PJQSyuPxDCG1eDStJ5YrWEHd3+56E1031s=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=wRqLe5cVUglf6MOkO64gZwb96EsivKf3w+4pwvVgbqMDpz+WrMVuSnjwMNQoMBz6dZlXmjGSl5NrxqM8EZ1ZdjUppQ257R5h8XzhGfKL2p1NF5WoeiD7BbcoTtpG4JO1ZeAI7YoK/c6ZhzBiQQ6TpU8ZCy8mLZqVs5FWzEzC4ik= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pg1-x534.google.com with SMTP id 41be03b00d2f7-7163489149eso1537078a12.1 for ; Fri, 25 Oct 2024 08:39:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1729870740; x=1730475540; darn=gcc.gnu.org; h=mime-version:user-agent:message-id:in-reply-to:date:references :organization:subject:cc:to:from:from:to:cc:subject:date:message-id :reply-to; bh=WmL4r6m4J2PqDWjIc4xH14m1hN+EzrsHOF9g4h8H1OQ=; b=Z6phsCd6duSetpWJUuCrDfIq+wcltkVspFUzKyaspTiRQ5UuajWDNRLWHhB6vfS+1W A/Gry3wKHMPFaq5kVghdiXitjUUlJnb56/O2fjXm34hi0CQkuyxHIEN2TcyvPAWDoPgx vShNpjIvt9MEMPbffGPgjKX62KW1XA0gM/BCk0eIFlzuXwZxGX4UniDnEDYmQgvF+yFi gwPpbTHWzqOoOpRtcHYHeDIv0ORkDbCknsYmnuxAYDYSbJdmXsOMtPS/unBUY444olLC phlrW3CM5BjJ1CvcppNLNlwob3HGN1xSwSfvXg5R55P0bERAD51ejuMpsOfk1DXDN87d j2XA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729870740; x=1730475540; h=mime-version:user-agent:message-id:in-reply-to:date:references :organization:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WmL4r6m4J2PqDWjIc4xH14m1hN+EzrsHOF9g4h8H1OQ=; b=C+YAhbJi3OAAXqN/lU2Cr4vMnncrWW422n+xNL3YLNvM/xg/qxgKa3vpYw4mW9WGCw Lawy17VruToHB9aJUuIQhvRlNfJTCYZEmcvR/CB4ecXWoXwvq5fO9OGXjKomnBXeIqUa JWwSe6rPTtOBBfoeHGz1jaCUd5SQRipYfmJd5tSDhw8aW6AfWcurc06Pec0GZ0emElP2 FXG4OsQvO9csuYm2VyktGilFGX366+ZAu1q5qpBIaAhRibRee5+jZGtjfm7DgDVbLclH pEZs0rKyMCrweLzbtJbSpLUXrVtnfwoT5olK9hu5Wex4a3KVRIrDpt8V7W5Fealk8acg IgfA== X-Gm-Message-State: AOJu0YxiQ3IQ9dGZUd+0Mv82+I5fCsx/7igTrAp8ezYcIfPz7dm59du4 q4VsuqtOBIcTIEgCJ/HoMH/HjjAvvLXj7daQ3lJ0fMFGAZdUyr+uEzpvQThbzKTNWnNc6QebT41 pcw== X-Google-Smtp-Source: AGHT+IHYi4DE/zxzMhXxa0Ic93ScvmZZQnXs3+wM0IRvULCBf3pzMnYss90W/Sxuh/GXL/l3q4agAg== X-Received: by 2002:a05:6a21:3a4a:b0:1d9:77d1:5a8 with SMTP id adf61e73a8af0-1d978ad716cmr11938849637.4.1729870740136; Fri, 25 Oct 2024 08:39:00 -0700 (PDT) Received: from free.home ([2804:14c:4d1:44a5::1002]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72057921863sm1200276b3a.33.2024.10.25.08.38.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2024 08:38:59 -0700 (PDT) Received: from livre (livre.home [172.31.160.2]) by free.home (8.15.2/8.15.2) with ESMTPS id 49PBvLsT1633957 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 25 Oct 2024 08:57:21 -0300 From: Alexandre Oliva To: Richard Biener Cc: GCC Patches Subject: [PATCH #7/7] handle TRUTH_ANDIF cond exprs in ifcombine_replace_cond (was: Re: [PATCH] fold fold_truth_andor field merging into ifcombine) Organization: Free thinker, does not speak for AdaCore References: Date: Fri, 25 Oct 2024 08:57:21 -0300 In-Reply-To: (Alexandre Oliva's message of "Fri, 25 Oct 2024 08:07:13 -0300") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 X-Spam-Status: No, score=-10.0 required=5.0 tests=BAYES_00, DATE_IN_PAST_03_06, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, LIKELY_SPAM_BODY, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, WEIRD_QUOTING 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 The upcoming move of fold_truth_andor to ifcombine brings with it the possibility of TRUTH_ANDIF cond exprs. Handle them by splitting the cond so as to best use both BB insertion points, but only if they're contiguous. for gcc/ChangeLog * tree-ssa-ifcombine.c (ifcombine_replace_cond): Support TRUTH_ANDIF cond exprs. --- gcc/tree-ssa-ifcombine.cc | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/gcc/tree-ssa-ifcombine.cc b/gcc/tree-ssa-ifcombine.cc index 817c95b20252e..6194e92bd3816 100644 --- a/gcc/tree-ssa-ifcombine.cc +++ b/gcc/tree-ssa-ifcombine.cc @@ -518,6 +518,17 @@ ifcombine_replace_cond (gcond *inner_cond, bool inner_inv, gcond *outer_cond, bool outer_inv, tree cond, bool must_canon, tree cond2) { + /* Split cond into cond2 if they're contiguous. ??? We might be able to + handle ORIF as well, inverting both conditions, but it's not clear that + this would be enough, and it never comes up. */ + if (!cond2 + && TREE_CODE (cond) == TRUTH_ANDIF_EXPR + && single_pred (gimple_bb (inner_cond)) == gimple_bb (outer_cond)) + { + cond2 = TREE_OPERAND (cond, 1); + cond = TREE_OPERAND (cond, 0); + } + bool outer_p = cond2 || (single_pred (gimple_bb (inner_cond)) != gimple_bb (outer_cond)); bool result_inv = outer_p ? outer_inv : inner_inv;