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 4A565385828D for ; Mon, 17 Jul 2023 13:26:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4A565385828D 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-9936b3d0286so648889566b.0 for ; Mon, 17 Jul 2023 06:26:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689600388; x=1692192388; h=to:in-reply-to:cc:references:message-id:date:subject:mime-version :from:content-transfer-encoding:from:to:cc:subject:date:message-id :reply-to; bh=hxsqeC6DYZoYN+/rYJ7aVPZQKYFFlJuL8qGhFD3H0J8=; b=Nw3ly9fS2VbeUBf61kFKbfss/4LDSHyfttfjF2JKN2rixc2FzxU8pl0woYK+qaaWev M2tbgdbXOnogfU2cl3gLo6M85HyS5WU8DYNqnDzNUINWLuTfQq8z7gLk+johjCqS6+Ik FQACKBhseEK+PST6uwJ4nXKJPOvrwre7L2IVauUGz2OK5YlSb07bWDvOBKpMZus8/fOB 7fUC88gbYnLHRrL2HoYnbQLDAZrzQDL1blbAzn9n7JuuQIBU7jq1u0LFrAuxrKof5T+O pKCuPnvvSbHXCZsDqzzEp/EhmrdDcwaiMuRLpZl+XnMYJ4Y1a232zXqX9+IRfrtgR3tQ WvEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689600388; x=1692192388; h=to:in-reply-to:cc:references:message-id:date:subject:mime-version :from:content-transfer-encoding:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hxsqeC6DYZoYN+/rYJ7aVPZQKYFFlJuL8qGhFD3H0J8=; b=OjRHUATy/YnNA4S7PYXWL60629GQl2c74MD1ra/m0wXZS+Fk0mRXF1JKKYh5LMYPMV Kg3c8Cn1a6uZV9PXnkWOfsLd0qZny/8ueyTBYw+/QaPI8FXvZL/4q/fFlRFQu+RpldVD lHaOg5NH4FAvd41VJHUxKEzp+QPliB4J826mID3xwV9+2xLYCEQYXe6nhO8GmuUKKWID nL38GrMulvsnQ2ekEWERwJG74SUamz6UyzrBlLe1533OVFDMXm9CLt93YHP0opdE5+kx 9IL5/6ZBFS8OZOxwucoIQ5E51mpq4SdFT3mlPqJT6wFf3bOYnZHv/FhWwN9grx9ag8tS xOcg== X-Gm-Message-State: ABy/qLbEw9BKJnD/6HfuoNbmj2DBRTaDpEJd2Kwqg3MmbK8UypyHT+DZ V1eU4zrps4DLC/MTAxUFFT0SKFTTDV4= X-Google-Smtp-Source: APBJJlEeq4gw7NFU070c/8Q2uC3qdb3yNwHcfaO9Ub1VxLO1iO90ewppSA/ptOrX5uBW3EZLwLhSgQ== X-Received: by 2002:a17:906:fb02:b0:994:673:8af6 with SMTP id lz2-20020a170906fb0200b0099406738af6mr9953839ejb.29.1689600388049; Mon, 17 Jul 2023 06:26:28 -0700 (PDT) Received: from smtpclient.apple (dynamic-095-118-045-083.95.118.pool.telefonica.de. [95.118.45.83]) by smtp.gmail.com with ESMTPSA id rv19-20020a17090710d300b0099297c99314sm9197183ejb.113.2023.07.17.06.26.27 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 17 Jul 2023 06:26:27 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: Richard Biener Mime-Version: 1.0 (1.0) Subject: Re: Fix optimize_mask_stores profile update Date: Mon, 17 Jul 2023 15:26:16 +0200 Message-Id: <48277DD7-7D8E-4071-A674-A42BB9F7C91D@gmail.com> References: Cc: gcc-patches@gcc.gnu.org In-Reply-To: To: Jan Hubicka X-Mailer: iPhone Mail (20F75) X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,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: > Am 17.07.2023 um 14:38 schrieb Jan Hubicka : >=20 > =EF=BB=BF >>=20 >>> On Mon, Jul 17, 2023 at 12:36=E2=80=AFPM Jan Hubicka via Gcc-patches >>> wrote: >>>=20 >>> Hi, >>> While looking into sphinx3 regression I noticed that vectorizer produces= >>> BBs with overall probability count 120%. This patch fixes it. >>> Richi, I don't know how to create a testcase, but having one would >>> be nice. >>>=20 >>> Bootstrapped/regtested x86_64-linux, commited last night (sorry for >>> late email) >>=20 >> This should trigger with sth like >>=20 >> for (i) >> if (cond[i]) >> out[i] =3D 1.; >>=20 >> so a masked store and then using AVX2+. ISTR we disable AVX masked >> stores on zen (but not AVX512). >=20 > OK, let me see if I can get a testcase out of that. >>> efalse =3D make_edge (bb, store_bb, EDGE_FALSE_VALUE); >>> /* Put STORE_BB to likely part. */ >>> efalse->probability =3D profile_probability::unlikely (); >>> + e->probability =3D efalse->probability.invert (); >>> store_bb->count =3D efalse->count (); >>=20 >> isn't the count also wrong? Or rather efalse should be likely(). We're= >> testing doing >>=20 >> if (!mask all zeros) >> masked-store >>=20 >> because a masked store with all zero mask can end up invoking COW page fa= ult >> handling multiple times (because it doesn't actually write). >=20 > Hmm, I only fixed the profile, efalse was already set to unlikely, but > indeed I think it should be likely. Maybe we can compute some bound on > actual probability by knowing if(cond[i]) probability. > If the loop always does factor many ones or zeros, the probability would > remain the same. > If that is p and they are all independent, the outcome would be > (1-p)^factor >=20 > sp we know the conditoinal shoul dbe in ragne (1-p)^factor....(1-p), > right? Yes. I think the heuristic was added for The case of bigger ranges with all 0/1 for Purely random one wouldn=E2=80=99t expect all zeros ever in practice. Maybe= the probability was also set with that special case in mind (which is of co= urse broken) Richard=20 > Honza >=20 >>=20 >> Note -Ofast allows store data races and thus does RMW instead of a masked= store. >>=20 >>> make_single_succ_edge (store_bb, join_bb, EDGE_FALLTHRU); >>> if (dom_info_available_p (CDI_DOMINATORS))