From patchwork Wed Sep 5 11:48:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Stubbs X-Patchwork-Id: 966326 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-485162-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="xYtpi6yP"; 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 42527V11jQz9s5c for ; Wed, 5 Sep 2018 21:49:57 +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:subject:date:message-id:in-reply-to:references:mime-version :content-type; q=dns; s=default; b=bp8la0MU/9gGDvlvfaOLmyBEjXbwg qknJ10njAph4dRjvTVjlo3XRlt/NsyEYyiz6vRiFsfAk49uaFtGe6FCAs0pfKNYC 73kTVLKSYsfN7KpSpXzSYmSC6fwgo161UCIXV8Y4QvLTs/sXknIDdBTIeOFpt3pH mC5IRL+0UmPjU4= 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:subject:date:message-id:in-reply-to:references:mime-version :content-type; s=default; bh=661HT4iTtuCyaUY+DjpXu8cSAhA=; b=xYt pi6yP8jfruKy7AlkMBc56NnLvYho7NdaMR97+hpZ7RzI1U7bZSrtDh/VRZFbJb/Z OKYcQSRzytzGU9VU4zdv8ANNHt9FJeGZyYnEtUyKgEvWWn5hUWgSAdCVzuwnrU3Y Hg24RB1cUNS/uO/faeaSHxxC19xdgtNiFAQawBaQ= Received: (qmail 80684 invoked by alias); 5 Sep 2018 11:49:38 -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 80412 invoked by uid 89); 5 Sep 2018 11:49:26 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=UNITS_PER_WORD, units_per_word X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 05 Sep 2018 11:49:23 +0000 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=svr-ies-mbx-01.mgc.mentorg.com) by relay1.mentorg.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-SHA384:256) id 1fxWJ1-0005TL-ET from Andrew_Stubbs@mentor.com for gcc-patches@gcc.gnu.org; Wed, 05 Sep 2018 04:49:07 -0700 Received: from build6-trusty-cs.sje.mentorg.com (137.202.0.90) by svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) with Microsoft SMTP Server (TLS) id 15.0.1320.4; Wed, 5 Sep 2018 12:49:03 +0100 From: To: Subject: [PATCH 01/25] Handle vectors that don't fit in an integer. Date: Wed, 5 Sep 2018 12:48:49 +0100 Message-ID: In-Reply-To: References: MIME-Version: 1.0 GCN vector sizes range between 64 and 512 bytes, none of which have correspondingly sized integer modes. This breaks a number of assumptions throughout the compiler, but I don't really want to create modes just for this purpose. Instead, this patch fixes up the cases that I've found, so far, such that the compiler tries something else, or fails to optimize, rather than just ICE. 2018-09-05 Andrew Stubbs Kwok Cheung Yeung Jan Hubicka Martin Jambor gcc/ * combine.c (gen_lowpart_or_truncate): Return clobber if there is not a integer mode if the same size as x. (gen_lowpart_for_combine): Fail if there is no integer mode of the same size. * expr.c (expand_expr_real_1): Force first operand to be in memory if it is a vector register and the result is in BLKmode. * tree-vect-stmts.c (vectorizable_store): Don't ICE when int_mode_for_size fails. (vectorizable_load): Likewise. --- gcc/combine.c | 13 ++++++++++++- gcc/expr.c | 8 ++++++++ gcc/tree-vect-stmts.c | 8 ++++---- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/gcc/combine.c b/gcc/combine.c index a2649b6..cbf9dae 100644 --- a/gcc/combine.c +++ b/gcc/combine.c @@ -8621,7 +8621,13 @@ gen_lowpart_or_truncate (machine_mode mode, rtx x) { /* Bit-cast X into an integer mode. */ if (!SCALAR_INT_MODE_P (GET_MODE (x))) - x = gen_lowpart (int_mode_for_mode (GET_MODE (x)).require (), x); + { + enum machine_mode imode = + int_mode_for_mode (GET_MODE (x)).require (); + if (imode == BLKmode) + return gen_rtx_CLOBBER (mode, const0_rtx); + x = gen_lowpart (imode, x); + } x = simplify_gen_unary (TRUNCATE, int_mode_for_mode (mode).require (), x, GET_MODE (x)); } @@ -11698,6 +11704,11 @@ gen_lowpart_for_combine (machine_mode omode, rtx x) if (omode == imode) return x; + /* This can happen when there is no integer mode corresponding + to a size of vector mode. */ + if (omode == BLKmode) + goto fail; + /* We can only support MODE being wider than a word if X is a constant integer or has a mode the same size. */ if (maybe_gt (GET_MODE_SIZE (omode), UNITS_PER_WORD) diff --git a/gcc/expr.c b/gcc/expr.c index cd5cf12..776254a 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -10569,6 +10569,14 @@ expand_expr_real_1 (tree exp, rtx target, machine_mode tmode, || maybe_gt (bitpos + bitsize, GET_MODE_BITSIZE (mode2))); + /* If the result is in BLKmode and the underlying object is a + vector in a register, and the size of the vector is larger than + the largest integer mode, then we must force OP0 to be in memory + as this is assumed in later code. */ + if (REG_P (op0) && VECTOR_MODE_P (mode2) && mode == BLKmode + && maybe_gt (bitsize, MAX_FIXED_MODE_SIZE)) + must_force_mem = 1; + /* Handle CONCAT first. */ if (GET_CODE (op0) == CONCAT && !must_force_mem) { diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c index 8d94fca..607a2bd 100644 --- a/gcc/tree-vect-stmts.c +++ b/gcc/tree-vect-stmts.c @@ -6702,12 +6702,12 @@ vectorizable_store (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi, supported. */ unsigned lsize = group_size * GET_MODE_BITSIZE (elmode); - elmode = int_mode_for_size (lsize, 0).require (); unsigned int lnunits = const_nunits / group_size; /* If we can't construct such a vector fall back to element extracts from the original vector type and element size stores. */ - if (mode_for_vector (elmode, lnunits).exists (&vmode) + if (int_mode_for_size (lsize, 0).exists (&elmode) + && mode_for_vector (elmode, lnunits).exists (&vmode) && VECTOR_MODE_P (vmode) && targetm.vector_mode_supported_p (vmode) && (convert_optab_handler (vec_extract_optab, @@ -7839,11 +7839,11 @@ vectorizable_load (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi, to a larger load. */ unsigned lsize = group_size * TYPE_PRECISION (TREE_TYPE (vectype)); - elmode = int_mode_for_size (lsize, 0).require (); unsigned int lnunits = const_nunits / group_size; /* If we can't construct such a vector fall back to element loads of the original vector type. */ - if (mode_for_vector (elmode, lnunits).exists (&vmode) + if (int_mode_for_size (lsize, 0).exists (&elmode) + && mode_for_vector (elmode, lnunits).exists (&vmode) && VECTOR_MODE_P (vmode) && targetm.vector_mode_supported_p (vmode) && (convert_optab_handler (vec_init_optab, vmode, elmode)