From patchwork Fri Dec 20 10:09:14 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bingfeng Mei X-Patchwork-Id: 303978 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 842602C02FF for ; Fri, 20 Dec 2013 21:09:27 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:content-type:mime-version; q=dns; s=default; b=GrVZ+2YZr4TuuED/0oweWwGw6c+0owWggDOoyP4pX2WQAMJvX2 9FDGTBY34o5+naE0fY7xpM5Yx7J2zwD+cGhs50KJn1QEnoIHWoBbk6INLyg++KI+ Up01rU/I/Jhvmq8hqVgNgHYbYyAOP1BwoZ+RTyxh+MT3BXItjZyCgRjKU= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:content-type:mime-version; s= default; bh=50fP6rrV/HLbz7wffW2JZWhMVfk=; b=yjmD8wltp/tdfwOf+R4c QyM8uK1TjVK6skfAR5dqADowIfK5YKNgcwmSb+CaZXCSyYktb+4pCyQI5Gf0Xmqt cIvPaZYCDYQzCVtvTgWDDbAwXlmizyeUKpi21MqrU1xXgIEjyEu+ELMV6gkYlI9v oDoo7RUN8zcQBO8oSpJnutI= Received: (qmail 5299 invoked by alias); 20 Dec 2013 10:09:19 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 5289 invoked by uid 89); 20 Dec 2013 10:09:18 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.8 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mail-gw3-out.broadcom.com Received: from mail-gw3-out.broadcom.com (HELO mail-gw3-out.broadcom.com) (216.31.210.64) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 20 Dec 2013 10:09:17 +0000 Received: from irvexchcas06.broadcom.com (HELO IRVEXCHCAS06.corp.ad.broadcom.com) ([10.9.208.53]) by mail-gw3-out.broadcom.com with ESMTP; 20 Dec 2013 02:11:00 -0800 Received: from SJEXCHCAS05.corp.ad.broadcom.com (10.16.203.12) by IRVEXCHCAS06.corp.ad.broadcom.com (10.9.208.53) with Microsoft SMTP Server (TLS) id 14.1.438.0; Fri, 20 Dec 2013 02:09:15 -0800 Received: from SJEXCHMB13.corp.ad.broadcom.com ([fe80::9d40:1e86:a7dc:c46a]) by SJEXCHCAS05.corp.ad.broadcom.com ([::1]) with mapi id 14.01.0438.000; Fri, 20 Dec 2013 02:09:14 -0800 From: Bingfeng Mei To: Bingfeng Mei , Jakub Jelinek CC: Richard Biener , "gcc-patches@gcc.gnu.org" Subject: [PING] RE: [PATCH] Vectorization for store with negative step Date: Fri, 20 Dec 2013 10:09:14 +0000 Message-ID: MIME-Version: 1.0 X-IsSubscribed: yes OK to commit? Thanks, Bingfeng -----Original Message----- From: gcc-patches-owner@gcc.gnu.org [mailto:gcc-patches-owner@gcc.gnu.org] On Behalf Of Bingfeng Mei Sent: 18 December 2013 16:25 To: Jakub Jelinek Cc: Richard Biener; gcc-patches@gcc.gnu.org Subject: RE: [PATCH] Vectorization for store with negative step Hi, Jakub, Sorry for all the formatting issues. Haven't submit a patch for a while :-). Please find the updated patch. Thanks, Bingfeng -----Original Message----- From: Jakub Jelinek [mailto:jakub@redhat.com] Sent: 18 December 2013 13:38 To: Bingfeng Mei Cc: Richard Biener; gcc-patches@gcc.gnu.org Subject: Re: [PATCH] Vectorization for store with negative step On Wed, Dec 18, 2013 at 01:31:05PM +0000, Bingfeng Mei wrote: simd_lane_access_p ? loop : NULL, - NULL_TREE, &dummy, gsi, &ptr_incr, + offset, &dummy, gsi, &ptr_incr, simd_lane_access_p, &inv_p); gcc_assert (bb_vinfo || !inv_p); } @@ -5306,6 +5352,21 @@ vectorizable_store (gimple stmt, gimple_ set_ptr_info_alignment (get_ptr_info (dataref_ptr), align, misalign); + if (negative) + { + tree perm_mask = perm_mask_for_reverse (vectype); + tree perm_dest = vect_create_destination_var (gimple_assign_rhs1 (stmt), vectype); + tree new_temp = make_ssa_name (perm_dest, NULL); + + /* Generate the permute statement. */ + gimple perm_stmt = gimple_build_assign_with_ops (VEC_PERM_EXPR, new_temp, + vec_oprnd, vec_oprnd, perm_mask); Too long lines. Jakub Index: gcc/ChangeLog =================================================================== --- gcc/ChangeLog (revision 206016) +++ gcc/ChangeLog (working copy) @@ -1,3 +1,9 @@ +2013-12-18 Bingfeng Mei + + PR tree-optimization/59544 + * tree-vect-stmts.c (perm_mask_for_reverse): Move before This should be a tab instead of 8 spaces. + vectorizable_store. (vectorizable_store): Handle negative step. Newline and tab after "store.", rather than space. Property changes on: gcc/testsuite/gcc.target/i386/pr59544.c ___________________________________________________________________ Added: svn:executable + * Please don't add such bogus property. Testcases aren't executable. Index: gcc/testsuite/ChangeLog =================================================================== --- gcc/testsuite/ChangeLog (revision 206016) +++ gcc/testsuite/ChangeLog (working copy) @@ -1,3 +1,8 @@ +2013-12-18 Bingfeng Mei + + PR tree-optimization/59544 + * gcc.target/i386/pr59544.c: New test Missing dot at the end of line. + 2013-12-16 Jakub Jelinek PR middle-end/58956 Index: gcc/tree-vect-stmts.c =================================================================== --- gcc/tree-vect-stmts.c (revision 206016) +++ gcc/tree-vect-stmts.c (working copy) @@ -4859,6 +4859,25 @@ ensure_base_align (stmt_vec_info stmt_in } +/* Given a vector type VECTYPE returns the VECTOR_CST mask that implements + reversal of the vector elements. If that is impossible to do, + returns NULL. */ + +static tree +perm_mask_for_reverse (tree vectype) +{ + int i, nunits; + unsigned char *sel; + + nunits = TYPE_VECTOR_SUBPARTS (vectype); + sel = XALLOCAVEC (unsigned char, nunits); + + for (i = 0; i < nunits; ++i) + sel[i] = nunits - 1 - i; + + return vect_gen_perm_mask (vectype, sel); +} + /* Function vectorizable_store. Check if STMT defines a non scalar data-ref (array/pointer/structure) that @@ -4902,6 +4921,8 @@ vectorizable_store (gimple stmt, gimple_ vec oprnds = vNULL; vec result_chain = vNULL; bool inv_p; + bool negative = false; + tree offset = NULL_TREE; vec vec_oprnds = vNULL; bool slp = (slp_node != NULL); unsigned int vec_num; @@ -4976,16 +4997,38 @@ vectorizable_store (gimple stmt, gimple_ if (!STMT_VINFO_DATA_REF (stmt_info)) return false; - if (tree_int_cst_compare (loop && nested_in_vect_loop_p (loop, stmt) - ? STMT_VINFO_DR_STEP (stmt_info) : DR_STEP (dr), - size_zero_node) < 0) + negative = tree_int_cst_compare (loop && nested_in_vect_loop_p (loop, stmt) + ? STMT_VINFO_DR_STEP (stmt_info) : DR_STEP (dr), + size_zero_node) < 0; The formatting looks wrong, do: negative = tree_int_cst_compare (loop && nested_in_vect_loop_p (loop, stmt) ? STMT_VINFO_DR_STEP (stmt_info) : DR_STEP (dr), size_zero_node) < 0; instead. + if (negative && ncopies > 1) { if (dump_enabled_p ()) dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, - "negative step for store.\n"); + "multiple types with negative step."); return false; } + if (negative) + { + gcc_assert (!grouped_store); + alignment_support_scheme = vect_supportable_dr_alignment (dr, false); + if (alignment_support_scheme != dr_aligned + && alignment_support_scheme != dr_unaligned_supported) Lots of places where you use 8 spaces instead of tab, please fix. + offset = size_int (-TYPE_VECTOR_SUBPARTS (vectype) + 1); + if (store_lanes_p) aggr_type = build_array_type_nelts (elem_type, vec_num * nunits); else @@ -5200,7 +5246,7 @@ vectorizable_store (gimple stmt, gimple_ dataref_ptr = vect_create_data_ref_ptr (first_stmt, aggr_type,