From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id 56F05385E00C for ; Thu, 2 Apr 2020 07:15:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 56F05385E00C Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 03273VDZ148119 for ; Thu, 2 Apr 2020 03:15:51 -0400 Received: from e06smtp03.uk.ibm.com (e06smtp03.uk.ibm.com [195.75.94.99]) by mx0b-001b2d01.pphosted.com with ESMTP id 30207163hx-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 02 Apr 2020 03:15:50 -0400 Received: from localhost by e06smtp03.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 2 Apr 2020 08:15:41 +0100 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp03.uk.ibm.com (192.168.101.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 2 Apr 2020 08:15:38 +0100 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 0327FjRi45875424 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 2 Apr 2020 07:15:45 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 40AF1AE051; Thu, 2 Apr 2020 07:15:45 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AC873AE061; Thu, 2 Apr 2020 07:15:43 +0000 (GMT) Received: from KewenLins-MacBook-Pro.local (unknown [9.197.245.104]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 2 Apr 2020 07:15:43 +0000 (GMT) To: GCC Patches Cc: Segher Boessenkool , Bill Schmidt , Richard Biener From: "Kewen.Lin" Subject: [PATCH] Fix PR94401 by considering reverse overrun Date: Thu, 2 Apr 2020 15:15:42 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------674DA2721B7ADB2366450AAA" Content-Language: en-US X-TM-AS-GCONF: 00 x-cbid: 20040207-0012-0000-0000-0000039CBAF4 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 20040207-0013-0000-0000-000021D9CD6E Message-Id: X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138, 18.0.676 definitions=2020-04-01_04:2020-03-31, 2020-04-01 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 malwarescore=0 spamscore=0 lowpriorityscore=0 adultscore=0 mlxlogscore=999 suspectscore=0 bulkscore=0 phishscore=0 priorityscore=1501 mlxscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004020060 X-Spam-Status: No, score=-26.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 02 Apr 2020 07:15:52 -0000 This is a multi-part message in MIME format. --------------674DA2721B7ADB2366450AAA Content-Type: text/plain; charset=gbk Content-Transfer-Encoding: 7bit Hi, The commit r10-7415 brings scalar type consideration to eliminate epilogue peeling for gaps, but it exposed one problem that the current handling doesn't consider the memory access type VMAT_CONTIGUOUS_REVERSE, for which the overrun happens on low address side. This patch is to make the code take care of it by updating the offset and construction element order accordingly. Bootstrapped/regtested on powerpc64le-linux-gnu P8 and aarch64-linux-gnu. BR, Kewen ----------- gcc/ChangeLog 2020-04-02 Kewen Lin PR tree-optimization/94401 * tree-vect-loop.c (vectorizable_load): Handle VMAT_CONTIGUOUS_REVERSE access type when loading halves of vector to avoid peeling for gaps. --------------674DA2721B7ADB2366450AAA Content-Type: text/plain; charset=UTF-8; x-mac-type="0"; x-mac-creator="0"; name="PR94401_REVERSE.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="PR94401_REVERSE.diff" diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c index 12beef6978c..3d27f59ba22 100644 --- a/gcc/tree-vect-stmts.c +++ b/gcc/tree-vect-stmts.c @@ -9590,11 +9590,20 @@ vectorizable_load (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi, if (new_vtype != NULL_TREE) ltype = half_vtype; } + tree offset = dataref_offset + ? dataref_offset + : build_int_cst (ref_type, 0); + if (ltype != vectype + && memory_access_type == VMAT_CONTIGUOUS_REVERSE) + offset = size_binop ( + PLUS_EXPR, + build_int_cst (ref_type, + DR_GROUP_GAP (first_stmt_info) + * tree_to_uhwi ( + TYPE_SIZE_UNIT (elem_type))), + offset); data_ref - = fold_build2 (MEM_REF, ltype, dataref_ptr, - dataref_offset - ? dataref_offset - : build_int_cst (ref_type, 0)); + = fold_build2 (MEM_REF, ltype, dataref_ptr, offset); if (alignment_support_scheme == dr_aligned) ; else if (DR_MISALIGNMENT (first_dr_info) == -1) @@ -9607,16 +9616,27 @@ vectorizable_load (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi, TYPE_ALIGN (elem_type)); if (ltype != vectype) { - vect_copy_ref_info (data_ref, DR_REF (first_dr_info->dr)); + vect_copy_ref_info (data_ref, + DR_REF (first_dr_info->dr)); tree tem = make_ssa_name (ltype); new_stmt = gimple_build_assign (tem, data_ref); - vect_finish_stmt_generation (stmt_info, new_stmt, gsi); + vect_finish_stmt_generation (stmt_info, new_stmt, + gsi); data_ref = NULL; vec *v; vec_alloc (v, 2); - CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, tem); - CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, - build_zero_cst (ltype)); + if (memory_access_type == VMAT_CONTIGUOUS_REVERSE) + { + CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, + build_zero_cst (ltype)); + CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, tem); + } + else + { + CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, tem); + CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, + build_zero_cst (ltype)); + } gcc_assert (new_vtype != NULL_TREE); if (new_vtype == vectype) new_stmt = gimple_build_assign ( --------------674DA2721B7ADB2366450AAA--