From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from nikam.ms.mff.cuni.cz (nikam.ms.mff.cuni.cz [195.113.20.16]) by sourceware.org (Postfix) with ESMTPS id 5AEB03858D28 for ; Mon, 17 Jul 2023 12:38:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5AEB03858D28 Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=ucw.cz Authentication-Results: sourceware.org; spf=none smtp.mailfrom=kam.mff.cuni.cz Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id 02DB22811B6; Mon, 17 Jul 2023 14:38:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ucw.cz; s=gen1; t=1689597527; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uEk2RGWdy4rSHIJ1Dyv+8og+IlvaHZuQKofza/Onv4s=; b=jBwPdM5ztw7pQCAG5Sxu2LanWIPKi+yOvyJOsnTL3YBVFgutKrqFROYMgB7BtMcL3jV4U+ kPz10J3uNC4leyZ3mEcrE1wY1oEsCwc3PkG6UW09Z1xvY1KyjKe9C3OFI+zTwCcCFnFYS+ PNgVC6IHT5K7Ak3LST+Ir2F9uZyCsU4= Date: Mon, 17 Jul 2023 14:38:46 +0200 From: Jan Hubicka To: Richard Biener , gcc-patches@gcc.gnu.org Subject: Re: Fix optimize_mask_stores profile update Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: > On Mon, Jul 17, 2023 at 12:36 PM Jan Hubicka via Gcc-patches > wrote: > > > > 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. > > > > Bootstrapped/regtested x86_64-linux, commited last night (sorry for > > late email) > > This should trigger with sth like > > for (i) > if (cond[i]) > out[i] = 1.; > > so a masked store and then using AVX2+. ISTR we disable AVX masked > stores on zen (but not AVX512). OK, let me see if I can get a testcase out of that. > > efalse = make_edge (bb, store_bb, EDGE_FALSE_VALUE); > > /* Put STORE_BB to likely part. */ > > efalse->probability = profile_probability::unlikely (); > > + e->probability = efalse->probability.invert (); > > store_bb->count = efalse->count (); > > isn't the count also wrong? Or rather efalse should be likely(). We're > testing doing > > if (!mask all zeros) > masked-store > > because a masked store with all zero mask can end up invoking COW page fault > handling multiple times (because it doesn't actually write). 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 sp we know the conditoinal shoul dbe in ragne (1-p)^factor....(1-p), right? Honza > > Note -Ofast allows store data races and thus does RMW instead of a masked store. > > > make_single_succ_edge (store_bb, join_bb, EDGE_FALLTHRU); > > if (dom_info_available_p (CDI_DOMINATORS))