From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 45214 invoked by alias); 8 Dec 2015 19:28:51 -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 45199 invoked by uid 89); 8 Dec 2015 19:28:50 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,T_RP_MATCHES_RCVD 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, 08 Dec 2015 19:28:49 +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 AEC11A99; Tue, 8 Dec 2015 19:28:47 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-116-58.ams2.redhat.com [10.36.116.58]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id tB8JSjqx005160 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 8 Dec 2015 14:28:46 -0500 Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id tB8JSgiP028820; Tue, 8 Dec 2015 20:28:43 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id tB8JSeiJ028819; Tue, 8 Dec 2015 20:28:40 +0100 Date: Tue, 08 Dec 2015 19:28:00 -0000 From: Jakub Jelinek To: Richard Biener Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] Encode alignment info in MASK_{LOAD,STORE} ifns (PR tree-optimization/68786) Message-ID: <20151208192840.GN5675@tucnak.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes X-SW-Source: 2015-12/txt/msg00909.txt.bz2 Hi! As written in the PR, with MASK_{LOAD,STORE} ifns we lose info on the alignment of the point, unless the referenced SSA_NAME has pointer info with alignment mask, but that is just an optimization issue rather than requirement. As the second argument to these builtins is always 0 (used just to hold the pointer type for aliasing purposes), this patch uses the value of the second arg to hold alignment info. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2015-12-08 Jakub Jelinek PR tree-optimization/68786 * tree-if-conv.c: Include builtins.h. (predicate_mem_writes): Put result of get_object_alignment (ref) into second argument's value. * tree-vect-stmts.c (vectorizable_mask_load_store): Put minimum pointer alignment into second argument's value. * tree-data-ref.c (get_references_in_stmt): Use value of second argument for build_aligned_type, and only the type to build a zero second argument for MEM_REF. * internal-fn.c (expand_mask_load_optab_fn, expand_mask_store_optab_fn): Likewise. --- gcc/tree-if-conv.c.jj 2015-11-30 13:40:38.000000000 +0100 +++ gcc/tree-if-conv.c 2015-12-08 17:29:18.139186787 +0100 @@ -111,6 +111,7 @@ along with GCC; see the file COPYING3. #include "dbgcnt.h" #include "tree-hash-traits.h" #include "varasm.h" +#include "builtins.h" /* List of basic blocks in if-conversion-suitable order. */ static basic_block *ifc_bbs; @@ -2093,7 +2094,8 @@ predicate_mem_writes (loop_p loop) vect_sizes.safe_push (bitsize); vect_masks.safe_push (mask); } - ptr = build_int_cst (reference_alias_ptr_type (ref), 0); + ptr = build_int_cst (reference_alias_ptr_type (ref), + get_object_alignment (ref)); /* Copy points-to info if possible. */ if (TREE_CODE (addr) == SSA_NAME && !SSA_NAME_PTR_INFO (addr)) copy_ref_info (build2 (MEM_REF, TREE_TYPE (ref), addr, ptr), --- gcc/tree-vect-stmts.c.jj 2015-12-02 20:26:59.000000000 +0100 +++ gcc/tree-vect-stmts.c 2015-12-08 17:10:47.226768560 +0100 @@ -2058,10 +2058,11 @@ vectorizable_mask_load_store (gimple *st misalign = DR_MISALIGNMENT (dr); set_ptr_info_alignment (get_ptr_info (dataref_ptr), align, misalign); + tree ptr = build_int_cst (TREE_TYPE (gimple_call_arg (stmt, 1)), + misalign ? misalign & -misalign : align); new_stmt = gimple_build_call_internal (IFN_MASK_STORE, 4, dataref_ptr, - gimple_call_arg (stmt, 1), - vec_mask, vec_rhs); + ptr, vec_mask, vec_rhs); vect_finish_stmt_generation (stmt, new_stmt, gsi); if (i == 0) STMT_VINFO_VEC_STMT (stmt_info) = *vec_stmt = new_stmt; @@ -2107,10 +2108,11 @@ vectorizable_mask_load_store (gimple *st misalign = DR_MISALIGNMENT (dr); set_ptr_info_alignment (get_ptr_info (dataref_ptr), align, misalign); + tree ptr = build_int_cst (TREE_TYPE (gimple_call_arg (stmt, 1)), + misalign ? misalign & -misalign : align); new_stmt = gimple_build_call_internal (IFN_MASK_LOAD, 3, dataref_ptr, - gimple_call_arg (stmt, 1), - vec_mask); + ptr, vec_mask); gimple_call_set_lhs (new_stmt, make_ssa_name (vec_dest)); vect_finish_stmt_generation (stmt, new_stmt, gsi); if (i == 0) --- gcc/tree-data-ref.c.jj 2015-11-09 13:39:32.000000000 +0100 +++ gcc/tree-data-ref.c 2015-12-08 17:38:55.199094723 +0100 @@ -3872,6 +3872,8 @@ get_references_in_stmt (gimple *stmt, ve else if (stmt_code == GIMPLE_CALL) { unsigned i, n; + tree ptr, type; + unsigned int align; ref.is_read = false; if (gimple_call_internal_p (stmt)) @@ -3882,12 +3884,16 @@ get_references_in_stmt (gimple *stmt, ve break; ref.is_read = true; case IFN_MASK_STORE: - ref.ref = fold_build2 (MEM_REF, - ref.is_read - ? TREE_TYPE (gimple_call_lhs (stmt)) - : TREE_TYPE (gimple_call_arg (stmt, 3)), - gimple_call_arg (stmt, 0), - gimple_call_arg (stmt, 1)); + ptr = build_int_cst (TREE_TYPE (gimple_call_arg (stmt, 1)), 0); + align = tree_to_shwi (gimple_call_arg (stmt, 1)); + if (ref.is_read) + type = TREE_TYPE (gimple_call_lhs (stmt)); + else + type = TREE_TYPE (gimple_call_arg (stmt, 3)); + if (TYPE_ALIGN (type) != align) + type = build_aligned_type (type, align); + ref.ref = fold_build2 (MEM_REF, type, gimple_call_arg (stmt, 0), + ptr); references->safe_push (ref); return false; default: --- gcc/internal-fn.c.jj 2015-12-02 20:26:56.000000000 +0100 +++ gcc/internal-fn.c 2015-12-08 17:21:40.602605916 +0100 @@ -1911,16 +1911,20 @@ static void expand_mask_load_optab_fn (internal_fn, gcall *stmt, convert_optab optab) { struct expand_operand ops[3]; - tree type, lhs, rhs, maskt; + tree type, lhs, rhs, maskt, ptr; rtx mem, target, mask; + unsigned align; maskt = gimple_call_arg (stmt, 2); lhs = gimple_call_lhs (stmt); if (lhs == NULL_TREE) return; type = TREE_TYPE (lhs); - rhs = fold_build2 (MEM_REF, type, gimple_call_arg (stmt, 0), - gimple_call_arg (stmt, 1)); + ptr = build_int_cst (TREE_TYPE (gimple_call_arg (stmt, 1)), 0); + align = tree_to_shwi (gimple_call_arg (stmt, 1)); + if (TYPE_ALIGN (type) != align) + type = build_aligned_type (type, align); + rhs = fold_build2 (MEM_REF, type, gimple_call_arg (stmt, 0), ptr); mem = expand_expr (rhs, NULL_RTX, VOIDmode, EXPAND_WRITE); gcc_assert (MEM_P (mem)); @@ -1940,14 +1944,18 @@ static void expand_mask_store_optab_fn (internal_fn, gcall *stmt, convert_optab optab) { struct expand_operand ops[3]; - tree type, lhs, rhs, maskt; + tree type, lhs, rhs, maskt, ptr; rtx mem, reg, mask; + unsigned align; maskt = gimple_call_arg (stmt, 2); rhs = gimple_call_arg (stmt, 3); type = TREE_TYPE (rhs); - lhs = fold_build2 (MEM_REF, type, gimple_call_arg (stmt, 0), - gimple_call_arg (stmt, 1)); + ptr = build_int_cst (TREE_TYPE (gimple_call_arg (stmt, 1)), 0); + align = tree_to_shwi (gimple_call_arg (stmt, 1)); + if (TYPE_ALIGN (type) != align) + type = build_aligned_type (type, align); + lhs = fold_build2 (MEM_REF, type, gimple_call_arg (stmt, 0), ptr); mem = expand_expr (lhs, NULL_RTX, VOIDmode, EXPAND_WRITE); gcc_assert (MEM_P (mem)); Jakub