From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2a07:de40:b251:101:10:150:64:2]) by sourceware.org (Postfix) with ESMTPS id 867533857011 for ; Tue, 12 Dec 2023 11:31:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 867533857011 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 867533857011 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a07:de40:b251:101:10:150:64:2 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702380686; cv=none; b=qSN6ORZ+Jxxm/RFXfgcyyoDczfsg8xN72FjUhfEfJfO6Rq4lWAq8N9c7yuCQWieZkXYKj8AVbORmLSyebfas6rgzoW3Angcvjs36q94t2UaclsbeoRDz+zJvJIQAWYGMIlRh7yMvoW5rCxAv3XDTY1vNWWtwHFsSN5bRj/PQJL0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702380686; c=relaxed/simple; bh=6SLlhjjW16rQh2ppil4G7ORzrU724YaVS8HicC4W95w=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:Date: From:To:Subject:Message-ID:MIME-Version; b=tsKdt+xxZxs5jgmQlQVywUdUfSyXRDAp3jmQMcFFdkWQj4Kc/OxZ6DGuDbgVYvEItvyinkEa2VbW0pSNwOf0RllGYDY3mw9Yq6WyAJ+Ndq5yvE0k020d4Cxaii4J7HlsjpHgLvM7bkPdxwTbwbtsNtQgPZRUHmSD4vZH7gGlW8M= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from [10.168.4.150] (unknown [10.168.4.150]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 1A7CF1FD09; Tue, 12 Dec 2023 11:31:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1702380681; 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=4Af8y0jdQyhKUxzdyH0++EPYStNK/k8dPo26V77iOPg=; b=evMwjDtJ+ndinHHHQTFebhQLqTdUuq/sTs7ETGWgqd54wKeBP53INE2EKgYCxINl/Yj3Bc /8ybWEON6bB/HfPAFCKZibcyVWfTooewwJFGMLeNeLbHx4BcgNkAXpVQeuViZgKqyTb/GM 2xTIsGbEfIeFad+1smhzHTZA/BYVDMs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1702380681; 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=4Af8y0jdQyhKUxzdyH0++EPYStNK/k8dPo26V77iOPg=; b=bT7LHb8IoAXJEplfeYioM57k274PtntYXxHk//Gl6XlHZPePdyODc9ZDj70nKp7rUcm2hO A3geS8eK0KuqueDA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1702380681; 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=4Af8y0jdQyhKUxzdyH0++EPYStNK/k8dPo26V77iOPg=; b=evMwjDtJ+ndinHHHQTFebhQLqTdUuq/sTs7ETGWgqd54wKeBP53INE2EKgYCxINl/Yj3Bc /8ybWEON6bB/HfPAFCKZibcyVWfTooewwJFGMLeNeLbHx4BcgNkAXpVQeuViZgKqyTb/GM 2xTIsGbEfIeFad+1smhzHTZA/BYVDMs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1702380681; 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=4Af8y0jdQyhKUxzdyH0++EPYStNK/k8dPo26V77iOPg=; b=bT7LHb8IoAXJEplfeYioM57k274PtntYXxHk//Gl6XlHZPePdyODc9ZDj70nKp7rUcm2hO A3geS8eK0KuqueDA== Date: Tue, 12 Dec 2023 12:30:18 +0100 (CET) From: Richard Biener To: Richard Sandiford cc: Tamar Christina , "gcc-patches@gcc.gnu.org" , nd , "jlaw@ventanamicro.com" Subject: Re: [PATCH 9/21]middle-end: implement vectorizable_early_exit for codegen of exit code In-Reply-To: Message-ID: References: <85570n66-1540-0r07-7q80-269p3o133585@fhfr.qr> <5r3p7378-q309-ooqo-7o76-q9r567ns1890@fhfr.qr> <3o102so4-34pp-3o01-o002-0q245oo10303@fhfr.qr> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Level: X-Spam-Score: -1.30 Authentication-Results: smtp-out2.suse.de; none X-Spam-Level: X-Spam-Score: -1.30 X-Spamd-Result: default: False [-1.30 / 50.00]; ARC_NA(0.00)[]; TO_DN_EQ_ADDR_SOME(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCPT_COUNT_FIVE(0.00)[5]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_COUNT_ZERO(0.00)[0]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; BAYES_HAM(-0.00)[11.59%] X-Spam-Flag: NO X-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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: On Tue, 12 Dec 2023, Richard Sandiford wrote: > Richard Biener writes: > > On Mon, 11 Dec 2023, Tamar Christina wrote: > >> @@ -5553,6 +5554,83 @@ integer_type_for_mask (tree var, vec_info *vinfo) > >> return build_nonstandard_integer_type (def_stmt_info->mask_precision, 1); > >> } > >> > >> +/* Function vect_recog_gcond_pattern > >> + > >> + Try to find pattern like following: > >> + > >> + if (a op b) > >> + > >> + where operator 'op' is not != and convert it to an adjusted boolean pattern > >> + > >> + mask = a op b > >> + if (mask != 0) > >> + > >> + and set the mask type on MASK. > >> + > >> + Input: > >> + > >> + * STMT_VINFO: The stmt at the end from which the pattern > >> + search begins, i.e. cast of a bool to > >> + an integer type. > >> + > >> + Output: > >> + > >> + * TYPE_OUT: The type of the output of this pattern. > >> + > >> + * Return value: A new stmt that will be used to replace the pattern. */ > >> + > >> +static gimple * > >> +vect_recog_gcond_pattern (vec_info *vinfo, > >> + stmt_vec_info stmt_vinfo, tree *type_out) > >> +{ > >> + gimple *last_stmt = STMT_VINFO_STMT (stmt_vinfo); > >> + gcond* cond = NULL; > >> + if (!(cond = dyn_cast (last_stmt))) > >> + return NULL; > >> + > >> + auto lhs = gimple_cond_lhs (cond); > >> + auto rhs = gimple_cond_rhs (cond); > >> + auto code = gimple_cond_code (cond); > >> + > >> + tree scalar_type = TREE_TYPE (lhs); > >> + if (VECTOR_TYPE_P (scalar_type)) > >> + return NULL; > >> + > >> + if (code == NE_EXPR && zerop (rhs)) > > > > I think you need && VECT_SCALAR_BOOLEAN_TYPE_P (scalar_type) here, > > an integer != 0 would not be an appropriate mask. I guess two > > relevant testcases would have an early exit like > > > > if (here[i] != 0) > > break; > > > > once with a 'bool here[]' and once with a 'int here[]'. > > > >> + return NULL; > >> + > >> + tree vecitype = get_vectype_for_scalar_type (vinfo, scalar_type); > >> + if (vecitype == NULL_TREE) > >> + return NULL; > >> + > >> + /* Build a scalar type for the boolean result that when vectorized matches the > >> + vector type of the result in size and number of elements. */ > >> + unsigned prec > >> + = vector_element_size (tree_to_poly_uint64 (TYPE_SIZE (vecitype)), > >> + TYPE_VECTOR_SUBPARTS (vecitype)); > >> + > >> + scalar_type > >> + = build_nonstandard_integer_type (prec, TYPE_UNSIGNED (scalar_type)); > >> + > >> + vecitype = get_vectype_for_scalar_type (vinfo, scalar_type); > >> + if (vecitype == NULL_TREE) > >> + return NULL; > >> + > >> + tree vectype = truth_type_for (vecitype); > > > > That looks awfully complicated. I guess one complication is that > > we compute mask_precision & friends before this pattern gets > > recognized. See vect_determine_mask_precision and its handling > > of tcc_comparison, see also integer_type_for_mask. For comparisons > > properly handled during pattern recog the vector type is determined > > in vect_get_vector_types_for_stmt via > > > > else if (vect_use_mask_type_p (stmt_info)) > > { > > unsigned int precision = stmt_info->mask_precision; > > scalar_type = build_nonstandard_integer_type (precision, 1); > > vectype = get_mask_type_for_scalar_type (vinfo, scalar_type, > > group_size); > > if (!vectype) > > return opt_result::failure_at (stmt, "not vectorized: unsupported" > > " data-type %T\n", scalar_type); > > > > Richard, do you have any advice here? I suppose vect_determine_precisions > > needs to handle the gcond case with bool != 0 somehow and for the > > extra mask producer we add here we have to emulate what it would have > > done, right? > > How about handling gconds directly in vect_determine_mask_precision? > In a sense it's not needed, since gconds are always roots, and so we > could calculate their precision on the fly instead. But handling it in > vect_determine_mask_precision feels like it should reduce the number > of special cases. Yeah, that sounds worth trying. Richard.