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: 148290 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:254a:b0:403:3b70:6f57 with SMTP id hf10csp106320vqb; Wed, 4 Oct 2023 05:48:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHjAem4A0YldPyeTC5D1jDlXoesn0qVp+/bn4lDqgGD0AlZ1aDfZ45EJUWXD0McZpWg+pgK X-Received: by 2002:a17:907:b0d:b0:9aa:20b2:35e7 with SMTP id h13-20020a1709070b0d00b009aa20b235e7mr2042896ejl.9.1696423736438; Wed, 04 Oct 2023 05:48:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696423736; cv=none; d=google.com; s=arc-20160816; b=zSL0lCZgpbXV0Y+Wf/6vPypyFsrMwqORN+Uq/DGRsVI7EpZjrOiJU9VGhRXnI/X4hR 8bPxpLRM8E3Cl3NNEMKpvs+Q+fJtFuqUKabtzBsu9DJxzoLYsfmIPOt5/ibThUh30wOq hOZAJH+eyVrFiBj6qNZZ0yHQR5cSLfJM/v4or1QU/K/XLoU8XMAk9yQYiChPw30AIJqS bZDNmg/jgr821JOlzJMnix06C/Yu9eBygB8ZgYJO0Q1KZp7Xb0zv7lAXmRUXv7cI6Vot 4yoQglRyoBGQn8GebkQwHh2UYMLhQ2zZ22i1CNM4669EvN8RH5f9Jb8DJM3CxXPmWc2G 5gCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature:dmarc-filter:delivered-to; bh=R0+kX3zO2wVNx4L3o+hv/C2RCWx2KqYaaqsZT6jsXOg=; fh=9YvKuYzPOH4H8p6ZxADoseEyE0mG6135swhZOYPib+Q=; b=kPl5JSRbUG/Itiwo+zQwAkNkpzhG0weamv8Sb62AJd1X/CH3UnpbMF0LN6Oo9Uljtp F3B4xMwyWEDv2Fx2cuSNq9QFeUnTHoLStO8g3S1X7A5QpsotVL+TuFSsel4n98kywrCH CamhCaTj3Vrj0YqTttNBShPL30eLFlPkl4EJgrs7YYSmP+aWkevwmPIP0mhPEf6nUWD2 xPCH9AYELqkRkkw81pKx8oNNbkW5Lz4lKCfZmoTISDx/U4D3jyKbaSZ8HJUX8mR0s/l8 wVuXuWC7kvqekjvqJdLFq9YibOX1nQCxV2SNZ5MYMvUY0hyj+0/6dqRh2R74/UutDw21 S3+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kolabnow.com header.s=dkim20160331 header.b=YyK8BAiJ; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id d14-20020a17090648ce00b009b637e88103si1713862ejt.379.2023.10.04.05.48.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 05:48:56 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@kolabnow.com header.s=dkim20160331 header.b=YyK8BAiJ; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9C8FB3954449 for ; Wed, 4 Oct 2023 12:42:56 +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+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778829216150633487 X-GMAIL-MSGID: 1778829216150633487 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);