From patchwork Tue Jul 10 17:10:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: will schmidt X-Patchwork-Id: 942109 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-481321-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=vnet.ibm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="LdsUEosQ"; 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 41Q7yR0n4dz9ryt for ; Wed, 11 Jul 2018 03:11:10 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:from:reply-to:to:cc:in-reply-to:references:content-type :date:mime-version:content-transfer-encoding:message-id; q=dns; s=default; b=thLYF+MWHUaCtzuSLpGvOnEYAqNeWKB7vC2Wt7yQeqDlkwVUke Aqv6KE3htmeJIrtox4lmH8UWch02IUT6vgL8sUaa9o/5e7NMt0FbJjBY3PpYUw87 0JQx7R0O8h8ZP5hhVITWV8vCJfJqjjVAw/PA4eLIt5Fl0dlU1J+QQqBo0= 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 :subject:from:reply-to:to:cc:in-reply-to:references:content-type :date:mime-version:content-transfer-encoding:message-id; s= default; bh=igOsmU2LBwos+vzB1Fy8YoTdN2E=; b=LdsUEosQYTZNdAqHPPUY 35AqYxaYV2yijFyzTYHHYi7JhDnWP4N+YYlUDqdBXroqNGBqGjcyQyo+749zq1HD tFtTWWlX80X19SVAxR5X5XPtFHdeY+9br3H9laXt84x+cpCkG5aNgAiJAdfg8Ec7 BFHCH4cZTib97I0MOJdrMLw= Received: (qmail 2984 invoked by alias); 10 Jul 2018 17:11:02 -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 2085 invoked by uid 89); 10 Jul 2018 17:11:02 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-27.0 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.2 spammy= X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0b-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.158.5) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 10 Jul 2018 17:10:59 +0000 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w6AH9esU075436 for ; Tue, 10 Jul 2018 13:10:58 -0400 Received: from e31.co.us.ibm.com (e31.co.us.ibm.com [32.97.110.149]) by mx0b-001b2d01.pphosted.com with ESMTP id 2k4xvt1qbf-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 10 Jul 2018 13:10:57 -0400 Received: from localhost by e31.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 10 Jul 2018 11:10:57 -0600 Received: from b03cxnp07028.gho.boulder.ibm.com (9.17.130.15) by e31.co.us.ibm.com (192.168.1.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Tue, 10 Jul 2018 11:10:53 -0600 Received: from b03ledav003.gho.boulder.ibm.com (b03ledav003.gho.boulder.ibm.com [9.17.130.234]) by b03cxnp07028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w6AHAqmR54984876 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 10 Jul 2018 10:10:52 -0700 Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 752B46A047; Tue, 10 Jul 2018 11:10:52 -0600 (MDT) Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 12E3D6A04F; Tue, 10 Jul 2018 11:10:51 -0600 (MDT) Received: from [9.10.86.107] (unknown [9.10.86.107]) by b03ledav003.gho.boulder.ibm.com (Postfix) with ESMTP; Tue, 10 Jul 2018 11:10:51 -0600 (MDT) Subject: [PATCH, rs6000 v4] enable gimple folding for vec_xl, vec_xst From: Will Schmidt Reply-To: will_schmidt@vnet.ibm.com To: Richard Biener Cc: Bill Schmidt , Segher Boessenkool , "William J. Schmidt" , David Edelsohn , GCC Patches In-Reply-To: References: <1531163298.17604.38.camel@brimstone.rchland.ibm.com> <98C3553C-87F5-48D4-A9CE-3ED0D5B88904@linux.ibm.com> Date: Tue, 10 Jul 2018 12:10:51 -0500 Mime-Version: 1.0 x-cbid: 18071017-8235-0000-0000-00000DD0A087 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00009346; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000266; SDB=6.01059389; UDB=6.00543701; IPR=6.00837309; MB=3.00022090; MTD=3.00000008; XFM=3.00000015; UTC=2018-07-10 17:10:55 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18071017-8236-0000-0000-000041D540E3 Message-Id: <1531242651.26783.9.camel@brimstone.rchland.ibm.com> X-IsSubscribed: yes Hi, Add support for Gimple folding for unaligned vector loads and stores. Regtest completed across variety of systems, P6,P7,P8,P9. [v2] Added the type for the MEM_REF, per feedback. Testcases for gimple-folding of the same are currently in-tree as powerpc/fold-vec-load-*.c and powerpc/fold-vec-store-*.c. [v3] Updated the alignment for the MEM_REF to be 4bytes. Updated/added/removed comments in the code for clarity. [v4] Updated the alignment for the stores to match what was done for the loads. Sniff tests passed for V4. Will do full regtest as well, just in case. OK for trunk assuming successful test results? Thanks -Will [gcc] 2018-07-10 Will Schmidt * config/rs6000/rs6000.c (rs6000_builtin_valid_without_lhs): Add vec_xst variants to the list. (rs6000_gimple_fold_builtin): Add support for folding unaligned vector loads and stores. diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 8bc4109..229cfac 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -15401,10 +15401,16 @@ rs6000_builtin_valid_without_lhs (enum rs6000_builtins fn_code) case ALTIVEC_BUILTIN_STVX_V8HI: case ALTIVEC_BUILTIN_STVX_V4SI: case ALTIVEC_BUILTIN_STVX_V4SF: case ALTIVEC_BUILTIN_STVX_V2DI: case ALTIVEC_BUILTIN_STVX_V2DF: + case VSX_BUILTIN_STXVW4X_V16QI: + case VSX_BUILTIN_STXVW4X_V8HI: + case VSX_BUILTIN_STXVW4X_V4SF: + case VSX_BUILTIN_STXVW4X_V4SI: + case VSX_BUILTIN_STXVD2X_V2DF: + case VSX_BUILTIN_STXVD2X_V2DI: return true; default: return false; } } @@ -15910,10 +15916,81 @@ rs6000_gimple_fold_builtin (gimple_stmt_iterator *gsi) gimple_set_location (g, loc); gsi_replace (gsi, g, true); return true; } + /* unaligned Vector loads. */ + case VSX_BUILTIN_LXVW4X_V16QI: + case VSX_BUILTIN_LXVW4X_V8HI: + case VSX_BUILTIN_LXVW4X_V4SF: + case VSX_BUILTIN_LXVW4X_V4SI: + case VSX_BUILTIN_LXVD2X_V2DF: + case VSX_BUILTIN_LXVD2X_V2DI: + { + arg0 = gimple_call_arg (stmt, 0); // offset + arg1 = gimple_call_arg (stmt, 1); // address + lhs = gimple_call_lhs (stmt); + location_t loc = gimple_location (stmt); + /* Since arg1 may be cast to a different type, just use ptr_type_node + here instead of trying to enforce TBAA on pointer types. */ + tree arg1_type = ptr_type_node; + tree lhs_type = TREE_TYPE (lhs); + /* In GIMPLE the type of the MEM_REF specifies the alignment. The + required alignment (power) is 4 bytes regardless of data type. */ + tree align_ltype = build_aligned_type (lhs_type, 4); + /* POINTER_PLUS_EXPR wants the offset to be of type 'sizetype'. Create + the tree using the value from arg0. The resulting type will match + the type of arg1. */ + gimple_seq stmts = NULL; + tree temp_offset = gimple_convert (&stmts, loc, sizetype, arg0); + tree temp_addr = gimple_build (&stmts, loc, POINTER_PLUS_EXPR, + arg1_type, arg1, temp_offset); + gsi_insert_seq_before (gsi, stmts, GSI_SAME_STMT); + /* Use the build2 helper to set up the mem_ref. The MEM_REF could also + take an offset, but since we've already incorporated the offset + above, here we just pass in a zero. */ + gimple *g; + g = gimple_build_assign (lhs, build2 (MEM_REF, align_ltype, temp_addr, + build_int_cst (arg1_type, 0))); + gimple_set_location (g, loc); + gsi_replace (gsi, g, true); + return true; + } + + /* unaligned Vector stores. */ + case VSX_BUILTIN_STXVW4X_V16QI: + case VSX_BUILTIN_STXVW4X_V8HI: + case VSX_BUILTIN_STXVW4X_V4SF: + case VSX_BUILTIN_STXVW4X_V4SI: + case VSX_BUILTIN_STXVD2X_V2DF: + case VSX_BUILTIN_STXVD2X_V2DI: + { + arg0 = gimple_call_arg (stmt, 0); /* Value to be stored. */ + arg1 = gimple_call_arg (stmt, 1); /* Offset. */ + tree arg2 = gimple_call_arg (stmt, 2); /* Store-to address. */ + location_t loc = gimple_location (stmt); + tree arg0_type = TREE_TYPE (arg0); + /* Use ptr_type_node (no TBAA) for the arg2_type. */ + tree arg2_type = ptr_type_node; + /* In GIMPLE the type of the MEM_REF specifies the alignment. The + required alignment (power) is 4 bytes regardless of data type. */ + tree align_stype = build_aligned_type (arg0_type, 4); + /* POINTER_PLUS_EXPR wants the offset to be of type 'sizetype'. Create + the tree using the value from arg1. */ + gimple_seq stmts = NULL; + tree temp_offset = gimple_convert (&stmts, loc, sizetype, arg1); + tree temp_addr = gimple_build (&stmts, loc, POINTER_PLUS_EXPR, + arg2_type, arg2, temp_offset); + gsi_insert_seq_before (gsi, stmts, GSI_SAME_STMT); + gimple *g; + g = gimple_build_assign (build2 (MEM_REF, align_stype, temp_addr, + build_int_cst (arg2_type, 0)), arg0); + gimple_set_location (g, loc); + gsi_replace (gsi, g, true); + return true; + } + /* Vector Fused multiply-add (fma). */ case ALTIVEC_BUILTIN_VMADDFP: case VSX_BUILTIN_XVMADDDP: case ALTIVEC_BUILTIN_VMLADDUHM: {