From patchwork Tue May 8 10:37:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allan Sandfeld Jensen X-Patchwork-Id: 910108 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-477341-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=carewolf.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="gCd3sjYI"; 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 40gGCQ14FWz9s0W for ; Tue, 8 May 2018 20:37:37 +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:from :to:cc:subject:date:message-id:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=o1qEAyxhrtVuANox mZUV2toZAO+8yQN7/+ablRIgJbrKdjNjMsUTpKscXu6TUL4/A40C6DxL0k19PrVW GpU0JpIVErztuExA35433lCXh+aPsclCHRb3dRCEr2F6FDgDLbQiFJ/XpUvuLyjt 5R7gXV8sWMNCxq61yhz8PNQSZHU= 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:mime-version:content-type :content-transfer-encoding; s=default; bh=vdtQTzh/TYkr21gK52INW4 AJMZo=; b=gCd3sjYI8nMnRbHvSFnfglzhrni27Lcj1g62V2lh+SHKEXceBDw9oD kGDuyJ3Dm30hSIPu95x0qG/K29DmLsorfnJ8XGqmIIKAOQrydopD+IM2uob23P2Q YlipcwLJQN7aKALu4RmQV7uF2Cf86ySQcVX1eRhTFpSe569Ig6EtE= Received: (qmail 7913 invoked by alias); 8 May 2018 10:37:30 -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 7897 invoked by uid 89); 8 May 2018 10:37:29 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy= X-HELO: mailrelay2-3.pub.mailoutpod1-cph3.one.com Received: from mailrelay2-3.pub.mailoutpod1-cph3.one.com (HELO mailrelay2-3.pub.mailoutpod1-cph3.one.com) (46.30.212.11) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 08 May 2018 10:37:27 +0000 X-HalOne-Cookie: fd6f748d40faf4bfbd3d9d50139bd35e3aaafc50 X-HalOne-ID: cb433113-52ab-11e8-bb71-d0431ea8a290 Received: from twilight.localnet (unknown [62.220.2.194]) by mailrelay2.pub.mailoutpod1-cph3.one.com (Halon) with ESMTPSA id cb433113-52ab-11e8-bb71-d0431ea8a290; Tue, 08 May 2018 10:37:24 +0000 (UTC) From: Allan Sandfeld Jensen To: gcc-patches@gcc.gnu.org Cc: Richard Sandiford Subject: [Patch] Use two source permute for vector initialization (PR 85692) Date: Tue, 08 May 2018 12:37:23 +0200 Message-ID: <2034460.3Q4jJ9Mvva@twilight> MIME-Version: 1.0 X-IsSubscribed: yes I have tried to fix PR85692 that I opened. 2018-05-08 Allan Sandfeld Jense PR tree-optimization/85692 * tree-ssa-forwprop.c (simplify_vector_constructor): Detect two source permute operations as well. diff --git a/gcc/tree-ssa-forwprop.c b/gcc/tree-ssa-forwprop.c index 58ec6b47a5b..fbee8064160 100644 --- a/gcc/tree-ssa-forwprop.c +++ b/gcc/tree-ssa-forwprop.c @@ -2004,7 +2004,7 @@ simplify_vector_constructor (gimple_stmt_iterator *gsi) { gimple *stmt = gsi_stmt (*gsi); gimple *def_stmt; - tree op, op2, orig, type, elem_type; + tree op, op2, orig1, orig2, type, elem_type; unsigned elem_size, i; unsigned HOST_WIDE_INT nelts; enum tree_code code, conv_code; @@ -2022,8 +2022,9 @@ simplify_vector_constructor (gimple_stmt_iterator *gsi) elem_type = TREE_TYPE (type); elem_size = TREE_INT_CST_LOW (TYPE_SIZE (elem_type)); - vec_perm_builder sel (nelts, nelts, 1); - orig = NULL; + vec_perm_builder sel (nelts, 2, nelts); + orig1 = NULL; + orig2 = NULL; conv_code = ERROR_MARK; maybe_ident = true; FOR_EACH_VEC_SAFE_ELT (CONSTRUCTOR_ELTS (op), i, elt) @@ -2063,10 +2064,26 @@ simplify_vector_constructor (gimple_stmt_iterator *gsi) return false; op1 = gimple_assign_rhs1 (def_stmt); ref = TREE_OPERAND (op1, 0); - if (orig) + if (orig1) { - if (ref != orig) - return false; + if (ref == orig1 || orig2) + { + if (ref != orig1 && ref != orig2) + return false; + } + else + { + if (TREE_CODE (ref) != SSA_NAME) + return false; + if (! VECTOR_TYPE_P (TREE_TYPE (ref)) + || ! useless_type_conversion_p (TREE_TYPE (op1), + TREE_TYPE (TREE_TYPE (ref)))) + return false; + if (TREE_TYPE (orig1) != TREE_TYPE (ref)) + return false; + orig2 = ref; + maybe_ident = false; + } } else { @@ -2076,12 +2093,14 @@ simplify_vector_constructor (gimple_stmt_iterator *gsi) || ! useless_type_conversion_p (TREE_TYPE (op1), TREE_TYPE (TREE_TYPE (ref)))) return false; - orig = ref; + orig1 = ref; } unsigned int elt; if (maybe_ne (bit_field_size (op1), elem_size) || !constant_multiple_p (bit_field_offset (op1), elem_size, &elt)) return false; + if (orig2 && ref == orig2) + elt += nelts; if (elt != i) maybe_ident = false; sel.quick_push (elt); @@ -2089,14 +2108,17 @@ simplify_vector_constructor (gimple_stmt_iterator *gsi) if (i < nelts) return false; - if (! VECTOR_TYPE_P (TREE_TYPE (orig)) + if (! VECTOR_TYPE_P (TREE_TYPE (orig1)) || maybe_ne (TYPE_VECTOR_SUBPARTS (type), - TYPE_VECTOR_SUBPARTS (TREE_TYPE (orig)))) + TYPE_VECTOR_SUBPARTS (TREE_TYPE (orig1)))) return false; + if (!orig2) + orig2 = orig1; + tree tem; if (conv_code != ERROR_MARK - && (! supportable_convert_operation (conv_code, type, TREE_TYPE (orig), + && (! supportable_convert_operation (conv_code, type, TREE_TYPE (orig1), &tem, &conv_code) || conv_code == CALL_EXPR)) return false; @@ -2104,16 +2126,16 @@ simplify_vector_constructor (gimple_stmt_iterator *gsi) if (maybe_ident) { if (conv_code == ERROR_MARK) - gimple_assign_set_rhs_from_tree (gsi, orig); + gimple_assign_set_rhs_from_tree (gsi, orig1); else - gimple_assign_set_rhs_with_ops (gsi, conv_code, orig, + gimple_assign_set_rhs_with_ops (gsi, conv_code, orig1, NULL_TREE, NULL_TREE); } else { tree mask_type; - vec_perm_indices indices (sel, 1, nelts); + vec_perm_indices indices (sel, 2, nelts); if (!can_vec_perm_const_p (TYPE_MODE (type), indices)) return false; mask_type @@ -2125,15 +2147,14 @@ simplify_vector_constructor (gimple_stmt_iterator *gsi) return false; op2 = vec_perm_indices_to_tree (mask_type, indices); if (conv_code == ERROR_MARK) - gimple_assign_set_rhs_with_ops (gsi, VEC_PERM_EXPR, orig, orig, op2); + gimple_assign_set_rhs_with_ops (gsi, VEC_PERM_EXPR, orig1, orig2, op2); else { gimple *perm - = gimple_build_assign (make_ssa_name (TREE_TYPE (orig)), - VEC_PERM_EXPR, orig, orig, op2); - orig = gimple_assign_lhs (perm); + = gimple_build_assign (make_ssa_name (TREE_TYPE (orig1)), + VEC_PERM_EXPR, orig1, orig2, op2); gsi_insert_before (gsi, perm, GSI_SAME_STMT); - gimple_assign_set_rhs_with_ops (gsi, conv_code, orig, + gimple_assign_set_rhs_with_ops (gsi, conv_code, gimple_assign_lhs (perm), NULL_TREE, NULL_TREE); } }