From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 106109 invoked by alias); 5 Nov 2019 12:58:29 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 106068 invoked by uid 89); 5 Nov 2019 12:58:28 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-7.5 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mail-lf1-f50.google.com Received: from mail-lf1-f50.google.com (HELO mail-lf1-f50.google.com) (209.85.167.50) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 05 Nov 2019 12:58:25 +0000 Received: by mail-lf1-f50.google.com with SMTP id v8so15007562lfa.12 for ; Tue, 05 Nov 2019 04:58:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=1pk9USCrr0yjLLF7vDSpYrwCPyq+vLzjKPWo4AQLpIU=; b=WLU9VI2BU9vOk8Yb/v3PwMrZPzqoFF0AgU0pR4n+nVQHFQgEOuHPdQznZab9iQ6rhf +i2TU4vxKlWlT2gF8GSH8GIH+TLwpeWwhVtKggqcSs5DnKt4qkQxEPtljV9g2mt3bD8T B8bNAteAu9eJVE0OvozY9W/zIWwlmq0d78zvHrsc06HU5P1AXjCu9p1YT2o7waJwD8EN Tdps4rtjtDy0/dFpPb4rwP1PGs4bFuCrkLsCC2l3QwhVT50MbHdqk8XWYAv+6f3zZSym Rn/ElamgFcBO+NfcmvhlMIbab8jF7fwe6DnPTXNIcJmgHcIBbghugRNo1FvMosE69weH BaCg== MIME-Version: 1.0 References: In-Reply-To: From: Richard Biener Date: Tue, 05 Nov 2019 12:58:00 -0000 Message-ID: Subject: Re: [13/n] Allow mixed vector sizes within a single vectorised stmt To: Richard Sandiford Cc: GCC Patches Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes X-SW-Source: 2019-11/txt/msg00271.txt.bz2 On Fri, Oct 25, 2019 at 2:49 PM Richard Sandiford wrote: > > Although a previous patch allowed mixed vector sizes within a vector > region, we generally still required equal vector sizes within a vector > stmt. Specifically, vect_get_vector_types_for_stmt computes two vector > types: the vector type corresponding to STMT_VINFO_VECTYPE and the > vector type that determines the minimum vectorisation factor for the > stmt ("nunits_vectype"). It then required these two types to be > the same size. > > There doesn't seem to be any need for that restriction though. AFAICT, > all vectorizable_* functions either do their own compatibility checks > or don't need to do them (because gimple guarantees that the scalar > types are compatible). > > It should always be the case that nunits_vectype has at least as many > elements as the other vectype, but that's something we can assert for. > > I couldn't resist a couple of other tweaks while there: > > - there's no need to compute nunits_vectype if its element type is > the same as STMT_VINFO_VECTYPE's. > > - it's useful to distinguish the nunits_vectype from the main vectype > in dump messages > > - when reusing the existing STMT_VINFO_VECTYPE, it's useful to say so > in the dump, and say what the type is OK. Thanks, Richard. > > 2019-10-24 Richard Sandiford > > gcc/ > * tree-vect-stmts.c (vect_get_vector_types_for_stmt): Don't > require vectype and nunits_vectype to have the same size; > instead assert that nunits_vectype has at least as many > elements as vectype. Don't compute a separate nunits_vectype > if the scalar type is obviously the same as vectype's. > Tweak dump messages. > > Index: gcc/tree-vect-stmts.c > =================================================================== > --- gcc/tree-vect-stmts.c 2019-10-25 13:27:26.205687511 +0100 > +++ gcc/tree-vect-stmts.c 2019-10-25 13:27:32.877640367 +0100 > @@ -11973,7 +11973,12 @@ vect_get_vector_types_for_stmt (stmt_vec > tree vectype; > tree scalar_type = NULL_TREE; > if (STMT_VINFO_VECTYPE (stmt_info)) > - *stmt_vectype_out = vectype = STMT_VINFO_VECTYPE (stmt_info); > + { > + *stmt_vectype_out = vectype = STMT_VINFO_VECTYPE (stmt_info); > + if (dump_enabled_p ()) > + dump_printf_loc (MSG_NOTE, vect_location, > + "precomputed vectype: %T\n", vectype); > + } > else > { > gcc_assert (!STMT_VINFO_DATA_REF (stmt_info)); > @@ -12005,7 +12010,7 @@ vect_get_vector_types_for_stmt (stmt_vec > > if (dump_enabled_p ()) > dump_printf_loc (MSG_NOTE, vect_location, > - "get vectype for scalar type: %T\n", scalar_type); > + "get vectype for scalar type: %T\n", scalar_type); > vectype = get_vectype_for_scalar_type (vinfo, scalar_type); > if (!vectype) > return opt_result::failure_at (stmt, > @@ -12022,42 +12027,38 @@ vect_get_vector_types_for_stmt (stmt_vec > > /* Don't try to compute scalar types if the stmt produces a boolean > vector; use the existing vector type instead. */ > - tree nunits_vectype; > - if (VECTOR_BOOLEAN_TYPE_P (vectype)) > - nunits_vectype = vectype; > - else > + tree nunits_vectype = vectype; > + if (!VECTOR_BOOLEAN_TYPE_P (vectype) > + && *stmt_vectype_out != boolean_type_node) > { > /* The number of units is set according to the smallest scalar > type (or the largest vector size, but we only support one > vector size per vectorization). */ > - if (*stmt_vectype_out != boolean_type_node) > + HOST_WIDE_INT dummy; > + scalar_type = vect_get_smallest_scalar_type (stmt_info, &dummy, &dummy); > + if (scalar_type != TREE_TYPE (vectype)) > { > - HOST_WIDE_INT dummy; > - scalar_type = vect_get_smallest_scalar_type (stmt_info, > - &dummy, &dummy); > + if (dump_enabled_p ()) > + dump_printf_loc (MSG_NOTE, vect_location, > + "get vectype for smallest scalar type: %T\n", > + scalar_type); > + nunits_vectype = get_vectype_for_scalar_type (vinfo, scalar_type); > + if (!nunits_vectype) > + return opt_result::failure_at > + (stmt, "not vectorized: unsupported data-type %T\n", > + scalar_type); > + if (dump_enabled_p ()) > + dump_printf_loc (MSG_NOTE, vect_location, "nunits vectype: %T\n", > + nunits_vectype); > } > - if (dump_enabled_p ()) > - dump_printf_loc (MSG_NOTE, vect_location, > - "get vectype for scalar type: %T\n", scalar_type); > - nunits_vectype = get_vectype_for_scalar_type (vinfo, scalar_type); > } > - if (!nunits_vectype) > - return opt_result::failure_at (stmt, > - "not vectorized: unsupported data-type %T\n", > - scalar_type); > - > - if (maybe_ne (GET_MODE_SIZE (TYPE_MODE (vectype)), > - GET_MODE_SIZE (TYPE_MODE (nunits_vectype)))) > - return opt_result::failure_at (stmt, > - "not vectorized: different sized vector " > - "types in statement, %T and %T\n", > - vectype, nunits_vectype); > + > + gcc_assert (*stmt_vectype_out == boolean_type_node > + || multiple_p (TYPE_VECTOR_SUBPARTS (nunits_vectype), > + TYPE_VECTOR_SUBPARTS (*stmt_vectype_out))); > > if (dump_enabled_p ()) > { > - dump_printf_loc (MSG_NOTE, vect_location, "vectype: %T\n", > - nunits_vectype); > - > dump_printf_loc (MSG_NOTE, vect_location, "nunits = "); > dump_dec (MSG_NOTE, TYPE_VECTOR_SUBPARTS (nunits_vectype)); > dump_printf (MSG_NOTE, "\n");