From patchwork Wed Oct 4 12:39:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?J=C3=B8rgen_Kvalsvik?= X-Patchwork-Id: 1843318 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (4096-bit key; secure) header.d=kolabnow.com header.i=@kolabnow.com header.a=rsa-sha256 header.s=dkim20160331 header.b=YyK8BAiJ; 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 4S0vVc5P6dz20Zl for ; Wed, 4 Oct 2023 23:43:04 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2A7F3394D896 for ; Wed, 4 Oct 2023 12:42:44 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx.kolabnow.com (mx.kolabnow.com [212.103.80.155]) by sourceware.org (Postfix) with ESMTPS id CB48E3856DD0 for ; Wed, 4 Oct 2023 12:41:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CB48E3856DD0 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=lambda.is Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=lambda.is Received: from localhost (unknown [127.0.0.1]) by mx.kolabnow.com (Postfix) with ESMTP id 05C8D20922A5; Wed, 4 Oct 2023 14:41:05 +0200 (CEST) Authentication-Results: ext-mx-out011.mykolab.com (amavis); dkim=pass (4096-bit key) reason="pass (just generated, assumed good)" header.d=kolabnow.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kolabnow.com; h= content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:date:subject:subject:from:from:received :received:received; s=dkim20160331; t=1696423264; x=1698237665; bh=R0+kX3zO2wVNx4L3o+hv/C2RCWx2KqYaaqsZT6jsXOg=; b=YyK8BAiJkyeS wztXuetZdUKWXtEjsERvBXhjXwo+mfq2UA+kOEG6L10UrelCYUzsfuMDCdyYTDL3 iHIbeIR35bZGONkU3TbR1/iZWjk5klKmXRg0dBrY7/ozQ4ufTfJtDKuL86jyR4IO lsPLqaGSo98s/OWhhF7RbVjQBYmftzgjc+D5KIAmBAkzQC115W3Rvdzr2G8HxT5S uTCVKdBpQORWkcKie6NUjaf8olWzQdrbLH61TYMu1acKXQHTW4KFMxmbQ/4K33qb x+4DOcVZOfUvn6zZc9+HnCfEtd6kfOoPgEPL8hR2cH2bpu6UvzOqtSSCsGpdB3ol 0bfdQs6hOQpgYZgNdfg+JmjvDgAvLy1ogjDExP8TR9We0rxLhEJYdp3sM3ze/NQa 7DtLmsjiZ9Y5Co45jXkzBvfT1kImPJDFCpeRg1n0rTyPXRSdTzmLDPodFOx7JIA0 srmVQNqfyGcKnah6LTDpCt7/JPcSw1AfHY37ULL55O19nx79jpN+ugWWqRmd1nnr qEKJ9tF6VJ1HCI6GDH5aSn1hp0hisyhkHFoK3oWBzKDlJg/PdZoRS3pLYPQj95De zqFfONR7cH47U2ZbJlAh8gxr5hat6VQDr4qgIYWnDW/Mfp3eXIPahMruuS7WjVOK Ph0Hb0vI3FLgxgZIps5uuOnuCPXj7Qw= X-Virus-Scanned: amavis at mykolab.com X-Spam-Score: -0.999 X-Spam-Level: X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 Received: from mx.kolabnow.com ([127.0.0.1]) by localhost (ext-mx-out011.mykolab.com [127.0.0.1]) (amavis, port 10024) with ESMTP id dIO0eieje8BR; Wed, 4 Oct 2023 14:41:04 +0200 (CEST) Received: from int-mx009.mykolab.com (unknown [10.9.13.9]) by mx.kolabnow.com (Postfix) with ESMTPS id 490A720C81FD; Wed, 4 Oct 2023 14:41:04 +0200 (CEST) Received: from ext-subm010.mykolab.com (unknown [10.9.6.10]) by int-mx009.mykolab.com (Postfix) with ESMTPS id 39D9120D6AE9; Wed, 4 Oct 2023 14:41:04 +0200 (CEST) From: =?utf-8?q?J=C3=B8rgen_Kvalsvik?= To: gcc-patches@gcc.gnu.org Cc: mliska@suse.cz, jh@suse.cz, =?utf-8?q?J=C3=B8rgen_Kvalsvik?= Subject: [PATCH 18/22] Don't contract into random edge in multi-succ node Date: Wed, 4 Oct 2023 21:39:18 +0900 Message-Id: <20231004123921.634024-19-j@lambda.is> In-Reply-To: <20231004123921.634024-1-j@lambda.is> References: <20231004123921.634024-1-j@lambda.is> MIME-Version: 1.0 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 A check was missing for is-single when contracting, so if a multi-successor node that was not a condition node (e.g. a switch) a random edge would be picked and contracted into. --- gcc/testsuite/gcc.misc-tests/gcov-23.c | 48 ++++++++++++++++++++++++++ gcc/tree-profile.cc | 4 +++ 2 files changed, 52 insertions(+) diff --git a/gcc/testsuite/gcc.misc-tests/gcov-23.c b/gcc/testsuite/gcc.misc-tests/gcov-23.c index c4afc5e700d..856e97f5088 100644 --- a/gcc/testsuite/gcc.misc-tests/gcov-23.c +++ b/gcc/testsuite/gcc.misc-tests/gcov-23.c @@ -3,6 +3,7 @@ int id (int); int idp (int *); int err; +char c; /* This becomes problematic only under optimization for the case when the compiler cannot inline the function but have to generate a call. It is not @@ -72,4 +73,51 @@ exit: return a; } +/* Adapted from icu4c-73.1 common/ucase.cpp ucase_getLocaleCase (). */ +int +mcdc003 (const char *locale) +{ + /* extern, so its effect won't be optimized out. */ + c = *locale++; + if (c == 'z') /* conditions(0/2) true(0) false(0) */ + /* conditions(end) */ + { + return 1; + } + else if (c >= 'a') /* conditions(0/2) true(0) false(0) */ + /* conditions(end) */ + { + if (id (c)) /* conditions(0/2) true(0) false(0) */ + /* conditions(end) */ + c = *locale++; + } + else + { + if (c == 'T') + { + if (id (c)) /* conditions(0/2) true(0) false(0) */ + /* conditions(end) */ + c = *locale++; + if (id (c)) /* conditions(0/2) true(0) false(0) */ + /* conditions(end) */ + c = *locale++; + } + else if (c == 'L') + c = *locale++; + else if (c == 'E') + c = *locale++; + else if (c == 'N') + c = *locale++; + else if (c == 'H') + { + c = *locale++; + if (id (c)) /* conditions(0/2) true(0) false(0) */ + /* conditions(end) */ + c = *locale++; + } + } + + return 1; +} + /* { dg-final { run-gcov conditions { --conditions gcov-23.c } } } */ diff --git a/gcc/tree-profile.cc b/gcc/tree-profile.cc index 26e1924d444..ce679130ca0 100644 --- a/gcc/tree-profile.cc +++ b/gcc/tree-profile.cc @@ -297,6 +297,10 @@ contract_edge (edge e, sbitmap G = nullptr) return source; if (block_conditional_p (dest)) return e; + /* This happens for switches, and must be checked after the is-conditional + (which is also not single). */ + if (!single (dest->succs)) + return source; if (G) bitmap_set_bit (G, dest->index);