From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) by sourceware.org (Postfix) with ESMTPS id 9F4413857014 for ; Thu, 15 Jun 2023 09:51:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9F4413857014 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-ej1-x636.google.com with SMTP id a640c23a62f3a-982b1a18daeso41100766b.2 for ; Thu, 15 Jun 2023 02:51:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686822659; x=1689414659; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=+tx+GDHjxkxNNP1MnTlzhab/Wg+ce75vyO/TJTlldNI=; b=HayQANYPhfNG5Kb2XX2U87dy0VwzK9A/FZKxW9B7t18kRCSX32bAYpHRFbfdYJLGYi 4PnWOKuCHvIbwQYL2T2fYgcdlcS7qFrBxeG7A3KnXf6w5tfNH9fElEyK3ybDpxdwj+eO X3Ex0H/poGicZf/nZIZ3luv7/9ZtGYAfBYDPOuEI+RmzfFp3+cJlmT3ZWc1Oxr9L6KxM SrpaTzQRuy2TrDnFWIVY/R8FuLveJFcwDSLZJDfNcmCyIPY+ZFeCK6l/xR/HjDIIO5lz X67wKg8Xq4pB9Mj/9AY7gAvozkuB0/FHiJfe0WAPdO6JklAlmbQGZc2+yazgbpC9uWNM FYYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686822659; x=1689414659; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=+tx+GDHjxkxNNP1MnTlzhab/Wg+ce75vyO/TJTlldNI=; b=NnplBaHzOvM6/ygsS1pgXsoeyY/JuVbltZ9juu22gso1eT9BES4pnvuWm3OVNSVvBp BaE33Bb1AFdA93w0B0m8Vn3OXRZx4l56QMtruSq1AEsuND2N8KMoNEsnAnWP6DlekgtJ eQ8XxJKcg9hGS27Vb+i0hgnmiw0S4S4QViNy1EJMFT7oZNb/L1BHyXsnpcOwsU25wO6X 0eqbkp0WZ/PF85NXcnGPOU/LfiA5jMQB/JcMnul0tq3r9ZniwtEjl6RswEQTO8z0c2YM 4G+NKiecGflh5RmmnsRwmJtWMDprfYW+T/xt6o4egLZDDqhAjQVbZT2rzbRZbe3oKH0U CbAQ== X-Gm-Message-State: AC+VfDzs32Lo6hhwmEZVx5xgnjiDYGdsxou3PXXYYA3AN8R9sUlHraXm pOx3o2h7cJaQh4CuKzxLkoX9+WamByw= X-Google-Smtp-Source: ACHHUZ6fsIICxHALycCyDMq9DTBr/RQGKOnz4b1ca6iRVZNoGsuR/fONubBNi2ZbGFVkzFUNsA5k9Q== X-Received: by 2002:a17:907:d2a:b0:97d:cda7:f0c4 with SMTP id gn42-20020a1709070d2a00b0097dcda7f0c4mr17853224ejc.61.1686822659104; Thu, 15 Jun 2023 02:50:59 -0700 (PDT) Received: from ntb03-Void.cuni.cz (koleje-wifi-0041.koleje.cuni.cz. [78.128.191.41]) by smtp.gmail.com with ESMTPSA id oq19-20020a170906cc9300b00977e0bcff1esm9241695ejb.10.2023.06.15.02.50.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Jun 2023 02:50:58 -0700 (PDT) From: Filip Kastl To: gcc-patches@gcc.gnu.org Cc: Filip Kastl Subject: [PATCH] value-prof.cc: Correct edge prob calculation. Date: Thu, 15 Jun 2023 11:50:52 +0200 Message-Id: <20230615095052.13119-1-filip.kastl@gmail.com> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.8 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,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 List-Id: The mod-subtract optimization with ncounts==1 produced incorrect edge probabilities due to incorrect conditional probability calculation. This patch fixes the calculation. gcc/ChangeLog: * value-prof.cc (gimple_mod_subtract_transform): Correct edge prob calculation. Signed-off-by: Filip Kastl --- gcc/value-prof.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gcc/value-prof.cc b/gcc/value-prof.cc index f40e58ac4f2..580d6dd648d 100644 --- a/gcc/value-prof.cc +++ b/gcc/value-prof.cc @@ -1186,7 +1186,11 @@ gimple_mod_subtract_transform (gimple_stmt_iterator *si) if (all > 0) { prob1 = profile_probability::probability_in_gcov_type (count1, all); - prob2 = profile_probability::probability_in_gcov_type (count2, all); + if (all == count1) + prob2 = profile_probability::even (); + else + prob2 = profile_probability::probability_in_gcov_type (count2, all - + count1); } else { -- 2.40.1