From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id B0065385742C for ; Wed, 21 Jul 2021 06:17:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B0065385742C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id B13C8224C8; Wed, 21 Jul 2021 06:17:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1626848274; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=BR+axdN6kXV2mEOtdCJoesKFxs55WuVOXMXZTOMz3eI=; b=iingJdD8Dm+u0VubsPJPxn3TCpqoCarQyoDzpDKWX9R8upJJNEv60oBxUJwuLauUt4+mb4 DODMe07IYx2vgEVl0152jGMg0T8K8NWfeuRaPvfzsd1hsOlTdUbWanT5+hVBPgCeW5lmda HDG34JTDEl9IfJ8xZCA833X7h+ITnQo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1626848274; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=BR+axdN6kXV2mEOtdCJoesKFxs55WuVOXMXZTOMz3eI=; b=/SpOvroG1ELJvkGgXhOZomcILFlt9EQRhQu8/yg9ExRuV9dkX95RNmS58UJVmtN5ub2cHG Jn2Zl8jCFUU85gDQ== Received: from murzim.suse.de (murzim.suse.de [10.160.4.192]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id AB488A3B89; Wed, 21 Jul 2021 06:17:54 +0000 (UTC) Date: Wed, 21 Jul 2021 08:17:54 +0200 (CEST) From: Richard Biener To: Richard Sandiford cc: gcc-patches@gcc.gnu.org, hongtao.liu@intel.com Subject: Re: [PATCH 2/2][RFC] Add loop masking support for x86 In-Reply-To: Message-ID: References: <73rrp0p-859r-oq2n-pss7-6744807s3qr5@fhfr.qr> User-Agent: Alpine 2.21 (LSU 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_NUMSUBJECT, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=no autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Jul 2021 06:17:56 -0000 On Tue, 20 Jul 2021, Richard Biener wrote: > On Thu, 15 Jul 2021, Richard Sandiford wrote: > > > Richard Biener writes: > > > The following extends the existing loop masking support using > > > SVE WHILE_ULT to x86 by proving an alternate way to produce the > > > mask using VEC_COND_EXPRs. So with --param vect-partial-vector-usage > > > you can now enable masked vectorized epilogues (=1) or fully > > > masked vector loops (=2). > > > > As mentioned on IRC, WHILE_ULT is supposed to ensure that every > > element after the first zero is also zero. That happens naturally > > for power-of-2 vectors if the start index is a multiple of the VF. > > (And at the moment, variable-length vectors are the only way of > > supporting non-power-of-2 vectors.) > > > > This probably works fine for =2 and =1 as things stand, since the > > vector IVs always start at zero. But if in future we have a single > > IV counting scalar iterations, and use it even for peeled prologue > > iterations, we could end up with a situation where the approximation > > is no longer safe. > > > > E.g. suppose we had a uint32_t scalar IV with a limit of (uint32_t)-3. > > If we peeled 2 iterations for alignment and then had a VF of 8, > > the final vector would have a start index of (uint32_t)-6 and the > > vector would be { -1, -1, -1, 0, 0, 0, -1, -1 }. > > > > So I think it would be safer to handle this as an alternative to > > using while, rather than as a direct emulation, so that we can take > > the extra restrictions into account. Alternatively, we could probably > > do { 0, 1, 2, ... } < { end - start, end - start, ... }. > > That doesn't end up working since in the last iteration with a > non-zero mask we'll compare with all underflowed values (start > will be > end). So while we compute a correct mask we cannot use > that for loop control anymore. Of course I can just use a signed comparison here (until we get V128QI and a QImode iterator). Richard.