From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) by sourceware.org (Postfix) with ESMTPS id C18783858D1E for ; Fri, 11 Nov 2022 14:04:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C18783858D1E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ed1-x534.google.com with SMTP id l11so7771863edb.4 for ; Fri, 11 Nov 2022 06:04:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=VDKtNEiTs8pWGfqvXFuYWaEtjMn5FMK+EABmgY4cDNM=; b=N91gdsd+DKPBK4fT+785gqRFG0e8bYuKZytWWRtALYfQ1D5UhQVaFS+TiXGVvAIPLS 3ASWwwdqeu5nVG9YeWVXvfjFunbr2lWJeMupXAU+RrOxFH3WZbgFW+X+E4Q3CP6jj72j 4FUmnWiN0d7E0b+8IwhvwGxORmQfodVoSEBW5jEgxiIzQLJb/fc+Tzj9Ay1Wn7BMVydV oR9pR5xnXBqelwrPsoyNIRbPQ1Wb8LBxOvPHXSUEgOO7BDAEepRjXonPZF4vZ4w/ynVG pPLT/tu+6sOSWiiyqYwUdkx9bICdmnTHkwUQzgqlX9yNm+peE63RvyCRx7o3VIcTkKuL ZrtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=VDKtNEiTs8pWGfqvXFuYWaEtjMn5FMK+EABmgY4cDNM=; b=CQSZLQnQED/vMRfYLqxYwREzuwUeoknWtYCKhbnN+8ikfvD+o0TOojQi2Gviu5EvKj 8CAWrCQdmtD/t54R47tQjEmqX0VdTdxFPqk4iXHv2UFeB36vKiGkzmLEdkGSoQXXuFaI mbfAtPhNqF1R5jQWGq+vCHvXM3DkB3bDtvw6y25IyFuUbWHav9OPCBDuUHceOJyIvbui nMCedhUaG01L4r5ZXwd4hBo8Wtllm/hO8nfNGSS6tOJ+EGhqJr+rYQ5SMj0u8vJIvk3J 3dwRBmGxiTAu2TwbD6ve9oZqtClsumtvzaFG8nZlHiMe2Nq+GIsnUjE2DKtxatGVxrPg p0Jg== X-Gm-Message-State: ANoB5pkLh4xkFiNVjaOC0YRLduXEgFWFqoEblX0DphlGvDr9MB3uKVit 6FIMnZK9uZINoDbELTwmiBD9e/F3E8GeMny8MZk= X-Google-Smtp-Source: AA0mqf4KJCciQsXtpmgojmU2QAxPvYAe3a0MQTeq2cdPQBnD6+I/gy6Al8cL9WgZ9jSCZJBJFpMXyjmwlmwRkQxfuos= X-Received: by 2002:aa7:da49:0:b0:461:8503:2b46 with SMTP id w9-20020aa7da49000000b0046185032b46mr1598313eds.202.1668175472274; Fri, 11 Nov 2022 06:04:32 -0800 (PST) MIME-Version: 1.0 References: <20220726111853.F03813857805@sourceware.org> In-Reply-To: <20220726111853.F03813857805@sourceware.org> From: Richard Biener Date: Fri, 11 Nov 2022 15:04:19 +0100 Message-ID: Subject: Re: [PATCH] tree-optimization/105142 - improve maybe_fold_comparisons_from_match_pd fix To: Richard Biener Cc: gcc-patches@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,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: On Tue, Jul 26, 2022 at 1:18 PM Richard Biener via Gcc-patches wrote: > > The following improves on the fix for PR105142 which restricted the > expression lookup used for maybe_fold_comparisons_from_match_pd to > avoid picking up flow-sensitive info for use in places where guarding > conditions do not hold. Instead of not allowing to expand SSA > definitions there the following temporarily clears flow-sensitive > info on the SSA names and restores it when finished matching. > > Bootstrapped on x86_64-unknown-linux-gnu, testing in progress. Better late then never - I have now pushed this after re-bootstrapping and testing this on x86_64-unknown-linux-gnu. Richard. > PR tree-optimization/105142 > * gimple-fold.cc (fosa_unwind): New global. > (follow_outer_ssa_edges): When the SSA definition to follow > is does not dominate fosa_bb, temporarily clear flow-sensitive > info. > (maybe_fold_comparisons_from_match_pd): Set up unwind stack > for follow_outer_ssa_edges and unwind flow-sensitive info > clearing after matching. > --- > gcc/gimple-fold.cc | 19 ++++++++++++++++++- > 1 file changed, 18 insertions(+), 1 deletion(-) > > diff --git a/gcc/gimple-fold.cc b/gcc/gimple-fold.cc > index a1704784bc9..876ef45434e 100644 > --- a/gcc/gimple-fold.cc > +++ b/gcc/gimple-fold.cc > @@ -6886,6 +6886,7 @@ and_comparisons_1 (tree type, enum tree_code code1, tree op1a, tree op1b, > } > > static basic_block fosa_bb; > +static vec > *fosa_unwind; > static tree > follow_outer_ssa_edges (tree val) > { > @@ -6899,7 +6900,15 @@ follow_outer_ssa_edges (tree val) > && (def_bb == fosa_bb > || dominated_by_p (CDI_DOMINATORS, fosa_bb, def_bb)))) > return val; > - return NULL_TREE; > + /* If the definition does not dominate fosa_bb temporarily reset > + flow-sensitive info. */ > + if (val->ssa_name.info.range_info) > + { > + fosa_unwind->safe_push (std::make_pair > + (val, val->ssa_name.info.range_info)); > + val->ssa_name.info.range_info = NULL; > + } > + return val; > } > return val; > } > @@ -6958,9 +6967,14 @@ maybe_fold_comparisons_from_match_pd (tree type, enum tree_code code, > type, gimple_assign_lhs (stmt1), > gimple_assign_lhs (stmt2)); > fosa_bb = outer_cond_bb; > + auto_vec, 8> unwind_stack; > + fosa_unwind = &unwind_stack; > if (op.resimplify (NULL, (!outer_cond_bb > ? follow_all_ssa_edges : follow_outer_ssa_edges))) > { > + fosa_unwind = NULL; > + for (auto p : unwind_stack) > + p.first->ssa_name.info.range_info = p.second; > if (gimple_simplified_result_is_gimple_val (&op)) > { > tree res = op.ops[0]; > @@ -6982,6 +6996,9 @@ maybe_fold_comparisons_from_match_pd (tree type, enum tree_code code, > return build2 ((enum tree_code)op.code, op.type, op0, op1); > } > } > + fosa_unwind = NULL; > + for (auto p : unwind_stack) > + p.first->ssa_name.info.range_info = p.second; > > return NULL_TREE; > } > -- > 2.35.3