From patchwork Wed Nov 27 06:07:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kewen.Lin" X-Patchwork-Id: 1201346 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-514675-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="Hvtg99fa"; dkim-atps=neutral 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 47N9L26XJfz9sSg for ; Wed, 27 Nov 2019 17:07:52 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to:cc :from:subject:date:mime-version:content-type:message-id; q=dns; s=default; b=soqN6fq7dlsqtVssNPT8Hn6Dg0zWN+A/3YiqhbP3993Fx3lGcn QiiT72VRP6x588HJ1FLuFIc25e1lgT2vTCFnN1NTJl+ImCtlq/JTjG94dOZFJMOE O7BI7G+A1XGFNJIRSFfeTbwHframE9sEiFddwsFbmoqrFPwowrWORfx+k= 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:to:cc :from:subject:date:mime-version:content-type:message-id; s= default; bh=iutTKRqiRkagviSvrSpYWQe0dDI=; b=Hvtg99fa7VlzpSy68Njc 9sQWN9ssE/7rktnvYsg3Dz5ySo8a6avMCtwI2FL+W+HTuYEDqInUO1p9r/utrmxH 9OVhMWiDFGGcWCzkZAw4q7MpOXDFmfarusYpc8Tmlr+yYmDDvp7eyonnMRLiGY3r DBz8CZRTvI37QcbCBHzPP8o= Received: (qmail 123850 invoked by alias); 27 Nov 2019 06:07:46 -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 123841 invoked by uid 89); 27 Nov 2019 06:07:45 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-20.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.1 spammy=burnin, burn-in, sk:slp_tre, sk:SLP_TRE X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0a-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.156.1) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 27 Nov 2019 06:07:44 +0000 Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id xAR67Toj052292 for ; Wed, 27 Nov 2019 01:07:43 -0500 Received: from e06smtp01.uk.ibm.com (e06smtp01.uk.ibm.com [195.75.94.97]) by mx0a-001b2d01.pphosted.com with ESMTP id 2whhgc3h86-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 27 Nov 2019 01:07:42 -0500 Received: from localhost by e06smtp01.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 27 Nov 2019 06:07:40 -0000 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp01.uk.ibm.com (192.168.101.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 27 Nov 2019 06:07:37 -0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id xAR67abD59572420 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 27 Nov 2019 06:07:36 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 70B2D4C05A; Wed, 27 Nov 2019 06:07:36 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EA6D94C04E; Wed, 27 Nov 2019 06:07:34 +0000 (GMT) Received: from kewenlins-mbp.cn.ibm.com (unknown [9.200.146.243]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 27 Nov 2019 06:07:34 +0000 (GMT) To: GCC Patches Cc: Richard Guenther , Segher Boessenkool , Bill Schmidt From: "Kewen.Lin" Subject: [PATCH] Fix PR91790 by considering different first_stmt_info for realign Date: Wed, 27 Nov 2019 14:07:33 +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 x-cbid: 19112706-4275-0000-0000-00000386E789 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19112706-4276-0000-0000-0000389A74AC Message-Id: <9109e540-b08a-1849-89b7-e7c7d310e34a@linux.ibm.com> X-IsSubscribed: yes Hi, As PR91790 exposed, when we have one slp node whose first_stmt_info_for_drptr is different from first_stmt_info, it's possible that the first_stmt DR isn't initialized yet before stmt SLP_TREE_SCALAR_STMTS[0] of slp node. So we shouldn't use first_stmt_info for vect_setup_realignment, instead we can use the one based on first_stmt_info_for_drptr DR with additional adjustment by bumping the distance from first_stmt DR. Bootstrapped and tested on powerpc64le-linux-gnu (P8LE) and ppc64-redhat-linux (P7BE) which need to use realign_load. Is it ok for trunk? and backport to GCC 9 after some burn-in time? BR, Kewen ---- gcc/ChangeLog 2019-11-27 Kewen Lin PR tree-optimization/91790 * gcc/tree-vect-stmts.c (vectorizable_load): Use the adjusted DR for vect_setup_realignment when first_stmt_info is different from first_stmt_info_for_drptr. diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c index fb669cd..422947b 100644 --- a/gcc/tree-vect-stmts.c +++ b/gcc/tree-vect-stmts.c @@ -9186,18 +9186,27 @@ vectorizable_load (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi, compute_in_loop = true; } + bool diff_first_stmt_info + = first_stmt_info_for_drptr && first_stmt_info != first_stmt_info_for_drptr; + if ((alignment_support_scheme == dr_explicit_realign_optimized || alignment_support_scheme == dr_explicit_realign) && !compute_in_loop) { - msq = vect_setup_realignment (first_stmt_info, gsi, &realignment_token, - alignment_support_scheme, NULL_TREE, - &at_loop); + /* If we have different first_stmt_info, we can't set up realignment + here, since we can't guarantee first_stmt_info DR has been + initialized yet, use first_stmt_info_for_drptr DR by bumping the + distance from first_stmt_info DR instead as below. */ + if (!diff_first_stmt_info) + msq = vect_setup_realignment (first_stmt_info, gsi, &realignment_token, + alignment_support_scheme, NULL_TREE, + &at_loop); if (alignment_support_scheme == dr_explicit_realign_optimized) { phi = as_a (SSA_NAME_DEF_STMT (msq)); byte_offset = size_binop (MINUS_EXPR, TYPE_SIZE_UNIT (vectype), size_one_node); + gcc_assert (!first_stmt_info_for_drptr); } } else @@ -9253,8 +9262,7 @@ vectorizable_load (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi, dataref_ptr = unshare_expr (DR_BASE_ADDRESS (first_dr_info->dr)); dataref_offset = build_int_cst (ref_type, 0); } - else if (first_stmt_info_for_drptr - && first_stmt_info != first_stmt_info_for_drptr) + else if (diff_first_stmt_info) { dataref_ptr = vect_create_data_ref_ptr (first_stmt_info_for_drptr, @@ -9271,6 +9279,14 @@ vectorizable_load (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi, DR_INIT (ptrdr))); dataref_ptr = bump_vector_ptr (dataref_ptr, ptr_incr, gsi, stmt_info, diff); + if (alignment_support_scheme == dr_explicit_realign) + { + msq = vect_setup_realignment (first_stmt_info_for_drptr, gsi, + &realignment_token, + alignment_support_scheme, + dataref_ptr, &at_loop); + gcc_assert (!compute_in_loop); + } } else if (STMT_VINFO_GATHER_SCATTER_P (stmt_info)) vect_get_gather_scatter_ops (loop, stmt_info, &gs_info,