From patchwork Wed Feb 14 16:39:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hubicka X-Patchwork-Id: 201036 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp1341645dyb; Wed, 14 Feb 2024 08:40:01 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXc2E/JKlDDOoHkKU31zT7Pi8jzvn1Jam8ubPRIG6iIlB3w2+6hdqRMxd3a0k0B8tmJGL6jIS4H78ropWorlIW+LsgMrg== X-Google-Smtp-Source: AGHT+IESZqZNLZZJlM/lqEJJF+5PXc/MI5CocyQK/jSAgCPVvWAkn53cwFIzlzkf+GZI89u3ZmQ6 X-Received: by 2002:a05:6808:10c4:b0:3c0:4565:e985 with SMTP id s4-20020a05680810c400b003c04565e985mr3944124ois.48.1707928801137; Wed, 14 Feb 2024 08:40:01 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707928801; cv=pass; d=google.com; s=arc-20160816; b=kXLDmO9S98sGPTJS3vvfiJbLpA1HmBezrJM/1YvzVsN++Zm+UmWe/vCKyOjVyYSEVi j2HSlvqky1PRbCgKD3afI4/qV9wMUqUWUr9U6FWWaN1GUTahU1PcfcTSTultVVcPOjey nnMgI3yLtc+9kgmpUnqBIMWrpz70yoGbHMWoI6zMZcl+CfQHSqc+6bROI0U0CbfOqQY1 o0b/9kE2BL7bcpwgHsmTdvsij/zjF/s2D6/oXWzV/9cih/ERZP0VYwlzQhL70PNKChkh ivEGRwU3aUCZdK8Q9Rr6kOVxoenBACLmqKHsIH/jSHHPXx/yNdw4GAVCAbfmkis1T4rG PG3g== ARC-Message-Signature: i=2; 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-disposition :mime-version:message-id:subject:to:from:date:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=Ujd7pxLgtyVUvF88VD4KwDAeCg3lVQk8vVwiXQ1eyiw=; fh=EbY+ryICwFvSTtBZ6Cij4Xx93wVnGB4w9ahkeiIDUMM=; b=KtQndJcvFS1DnjdAHWodI8hPSWnz6PAIpL4UJCjbFFYOntm5mObeiTMRs+56VYv0Rh CfIz3gcEYcB1T++e0eRfho4NQToRLnEGS9XeZZRFDuHdc/utaX0tQt33rzLX4YJiX9cy 4Aqo3HtPW5dhXbhSnc9HOmqL8DDsgdjU46DnTTb61q7o3Da4AoLNNg0n1hF/qQ1t6shA KJpyZlqA/iOEWxMegaBsni9AdNtBA32DLNyP1qvcCkMMBYM3mpW5MD9QLoETUtAwScgs DF5+j3BGTfptTulKndg2ospvV/NhXW00Wp8r/ZcXwhXRc1mX3ZY6ZwMbz3KOOhSLlQX2 BgCQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ucw.cz header.s=gen1 header.b=Lk2ZT8Mh; arc=pass (i=1); 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"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ucw.cz X-Forwarded-Encrypted: i=2; AJvYcCW1ab7dM+plQ7aXyvdS5BIFsBG6URxN5Ez/WRKvtowxxNrdVBiomnjj4pXN2bl4KCaV2RwTSx9eG0nrNxL/X0OTtE+yFg== Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id c12-20020a05620a0cec00b007871aa6b53esi4173892qkj.564.2024.02.14.08.40.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 08:40:01 -0800 (PST) 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=@ucw.cz header.s=gen1 header.b=Lk2ZT8Mh; arc=pass (i=1); 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"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ucw.cz Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D1CFB3860742 for ; Wed, 14 Feb 2024 16:40:00 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from nikam.ms.mff.cuni.cz (nikam.ms.mff.cuni.cz [195.113.20.16]) by sourceware.org (Postfix) with ESMTPS id 2B5BB38582A1 for ; Wed, 14 Feb 2024 16:39:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2B5BB38582A1 Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=ucw.cz Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=kam.mff.cuni.cz ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 2B5BB38582A1 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=195.113.20.16 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707928763; cv=none; b=FaZ+RDWbpQEKRHWoDPXJb9nGQg3vRc7kN0Vh+Ehm26WDzervOP7xJdCkqS+brdfdw47NtruBZROebtLZM0YtsrnxYvO7mr+6jF8VyYEDMSNuCPOOP5bRg6nYYeA6EIvEXpxlnZC99rwj+1/3Tax7R+h/VJ9E6STlpMdyK16YZnk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707928763; c=relaxed/simple; bh=G1RDfnjISf6PxQGAaTnPWnfx7ri146cJ1fCef9PbeCY=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=JnicutiQaMmk/gAFh1ZO+0io7aehWS3n0yeUo2mvkMpHkrDt1j6kld6OE9VFCj1i9FxgEg0igMKkSqhn76JO8PeGoi5FhvMfanlee3GXTFuhboRMcT9GidWcPBRl4JJ/BES3AvT2YNmuE6K5r8TqPGMmL3mnPcHrqWp2jF6OZQ8= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id B20EE281C72; Wed, 14 Feb 2024 17:39:20 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ucw.cz; s=gen1; t=1707928760; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=Ujd7pxLgtyVUvF88VD4KwDAeCg3lVQk8vVwiXQ1eyiw=; b=Lk2ZT8MhuejmoU4dGLYRaeMJeJfHJQNBaeY+bPYqlsDQPl0mKBWqIwdKbbsHm3dh4d54ZV wRr5ToxJU8eJiMzbkyV0AeBpdzhMdFJPWGbI+mSIadSodhHcpZc0NBEjnXSu88AvF1zeMd gHbGJxbL10WzMWQwH+OOdxkOUfG2/PM= Date: Wed, 14 Feb 2024 17:39:20 +0100 From: Jan Hubicka To: gcc-patches@gcc.gnu.org Subject: Fix ICE in loop splitting Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-10.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, JMQ_SPF_NEUTRAL, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790893150471416520 X-GMAIL-MSGID: 1790893150471416520 Hi, as demonstrated in the testcase, I forgot to check that profile is present in tree-ssa-loop-split. Bootstrapped and regtested x86_64-linux, comitted. PR tree-optimization/111054 gcc/ChangeLog: * tree-ssa-loop-split.cc (split_loop): Check for profile being present. gcc/testsuite/ChangeLog: * gcc.c-torture/compile/pr111054.c: New test. diff --git a/gcc/testsuite/gcc.c-torture/compile/pr111054.c b/gcc/testsuite/gcc.c-torture/compile/pr111054.c new file mode 100644 index 00000000000..3c0d6e816b9 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr111054.c @@ -0,0 +1,11 @@ +/* { dg-additional-options "-fno-guess-branch-probability" } */ +void *p, *q; +int i, j; + +void +foo (void) +{ + for (i = 0; i < 20; i++) + if (i < j) + p = q; +} diff --git a/gcc/tree-ssa-loop-split.cc b/gcc/tree-ssa-loop-split.cc index 04215fe7937..c0bb1b71d17 100644 --- a/gcc/tree-ssa-loop-split.cc +++ b/gcc/tree-ssa-loop-split.cc @@ -712,7 +712,8 @@ split_loop (class loop *loop1) ? true_edge->probability.to_sreal () : (sreal)1; sreal scale2 = false_edge->probability.reliable_p () ? false_edge->probability.to_sreal () : (sreal)1; - sreal div1 = loop1_prob.to_sreal (); + sreal div1 = loop1_prob.initialized_p () + ? loop1_prob.to_sreal () : (sreal)1/(sreal)2; /* +1 to get header interations rather than latch iterations and then -1 to convert back. */ if (div1 != 0)