From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 45770 invoked by alias); 28 Jul 2015 20:02:10 -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 45761 invoked by uid 89); 28 Jul 2015 20:02:10 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Tue, 28 Jul 2015 20:02:09 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 32C8891C21 for ; Tue, 28 Jul 2015 20:02:08 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-116-30.ams2.redhat.com [10.36.116.30]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t6SK26LW026986 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Tue, 28 Jul 2015 16:02:07 -0400 Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.14.9/8.14.9) with ESMTP id t6SK250B025770 for ; Tue, 28 Jul 2015 22:02:05 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.14.9/8.14.9/Submit) id t6SK24bp025769 for gcc-patches@gcc.gnu.org; Tue, 28 Jul 2015 22:02:04 +0200 Resent-From: Jakub Jelinek Resent-Date: Tue, 28 Jul 2015 22:02:04 +0200 Resent-Message-ID: <20150728200204.GF1750@tucnak.redhat.com> Resent-To: gcc-patches@gcc.gnu.org Date: Tue, 28 Jul 2015 20:34:00 -0000 From: Jakub Jelinek To: "Kumar, Venkataramanan" Cc: "Richard Beiner (richard.guenther@gmail.com)" , "gcc-patches@gcc.gnu.org" Subject: Re: [RFC] [Patch]: Try and vectorize with shift for mult expr with power 2 integer constant. Message-ID: <20150728195340.GX1780@tucnak.redhat.com> Reply-To: Jakub Jelinek References: <7794A52CE4D579448B959EED7DD0A4723DD1F787@satlexdag06.amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <7794A52CE4D579448B959EED7DD0A4723DD1F787@satlexdag06.amd.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes X-SW-Source: 2015-07/txt/msg02404.txt.bz2 Message-ID: <20150728203400.ePJEaaIFUoS4pIBAyJc-_dCZu8ysOYDpkZSvFPn4LG4@z> Hi! > This is just an initial patch and tries to optimize integer type power 2 > constants. I wanted to get feedback on this . I bootstrapped and reg > tested on aarch64-none-linux-gnu . Thanks for working on it. ChangeLog entry for the patch is missing, probably also some testcases. > @@ -90,6 +94,7 @@ static vect_recog_func_ptr vect_vect_recog_func_ptrs[NUM_PATTERNS] = { > vect_recog_rotate_pattern, > vect_recog_vector_vector_shift_pattern, > vect_recog_divmod_pattern, > + vect_recog_multconst_pattern, > vect_recog_mixed_size_cond_pattern, > vect_recog_bool_pattern}; Please watch formatting, the other lines are tab indented, so please use a tab rather than 8 spaces. > @@ -2147,6 +2152,87 @@ vect_recog_vector_vector_shift_pattern (vec *stmts, > return pattern_stmt; > } > Function comment is missing here. > +static gimple > +vect_recog_multconst_pattern (vec *stmts, > + tree *type_in, tree *type_out) About the function name, wonder if just vect_recog_mult_pattern wouldn't be enough. > + rhs_code = gimple_assign_rhs_code (last_stmt); > + switch (rhs_code) > + { > + case MULT_EXPR: > + break; > + default: > + return NULL; > + } This looks too weird, I'd just do if (gimple_assign_rhs_code (last_stmt) != MULT_EXPR) return NULL; (you handle just one pattern). > + /* If the target can handle vectorized multiplication natively, > + don't attempt to optimize this. */ > + optab = optab_for_tree_code (rhs_code, vectype, optab_default); Supposedly you can use MULT_EXPR directly here. > + /* If target cannot handle vector left shift then we cannot > + optimize and bail out. */ > + optab = optab_for_tree_code (LSHIFT_EXPR, vectype, optab_vector); > + if (!optab > + || optab_handler (optab, TYPE_MODE (vectype)) == CODE_FOR_nothing) > + return NULL; > + > + if (integer_pow2p (oprnd1)) > + { > + /* Pattern detected. */ > + if (dump_enabled_p ()) > + dump_printf_loc (MSG_NOTE, vect_location, > + "vect_recog_multconst_pattern: detected:\n"); > + > + tree shift; > + shift = build_int_cst (itype, tree_log2 (oprnd1)); > + pattern_stmt = gimple_build_assign (vect_recog_temp_ssa_var (itype, NULL), > + LSHIFT_EXPR, oprnd0, shift); > + if (dump_enabled_p ()) > + dump_gimple_stmt_loc (MSG_NOTE, vect_location, TDF_SLIM, pattern_stmt, > + 0); > + stmts->safe_push (last_stmt); > + *type_in = vectype; > + *type_out = vectype; > + return pattern_stmt; > + } Trailing whitespace. The integer_pow2p case (have you checked signed multiply by INT_MIN?) is only one of the cases you can actually handle, you can look at expand_mult for many other cases - e.g. multiplication by negated powers of 2, or call choose_mult_variant and handle whatever it returns. Jakub