From patchwork Mon Dec 9 15:21:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Stubbs X-Patchwork-Id: 1206376 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-515530-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="pYZQYapQ"; 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 47Wn424gxmz9sR0 for ; Tue, 10 Dec 2019 02:22:09 +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:from :subject:to:cc:message-id:date:mime-version:content-type; q=dns; s=default; b=NIrSm7oguirpNzwGu9jguA6hsbExzuDjVjodqLk+cSakkbwGUs yO975i+fTwhRbK8ZxwPyeH3Ujt7hiqc/iodcSwvMCb1fsjzgK5i2K5VBsxhbD6DQ OSt6YMx1OtRnwUS0mDra4AlPeabhllqkvPVxmwXHCkq4R+6llbDrogGpA= 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 :subject:to:cc:message-id:date:mime-version:content-type; s= default; bh=ZO/fFM9W91ueTW4qMm07WXjfah4=; b=pYZQYapQpZ2BSzPneTer oFk96XRu2rI0ORbvIdDpmKdT2bkIKWIdAlo9cVrW85tW4vDN7Bjgj+UgFPPTXwWH UPriKxNLL/51VX0vdnf0zDaZka2rIKGF121dwybBDGriaHY+6GV936Ik24JcjdOd U8NyTnSOdDhKfpGU+y209G0= Received: (qmail 101819 invoked by alias); 9 Dec 2019 15:22:01 -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 101802 invoked by uid 89); 9 Dec 2019 15:22:01 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-18.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT autolearn=ham version=3.3.1 spammy=poly_uint64, sk:type_ve, sk:TYPE_VE X-HELO: esa2.mentor.iphmx.com Received: from esa2.mentor.iphmx.com (HELO esa2.mentor.iphmx.com) (68.232.141.98) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 09 Dec 2019 15:21:59 +0000 IronPort-SDR: l2FkkCxqbUniU8z0jFSOS+x3x5HgoVPbNxHSGaieCNV0FOYHPuNZEj9ftisB42wmmD2PMLfBOM 21O1EMRvbbdNcowhVyhBmdkN3uCxHWNexJ+aKwXMNAr/Z2HRd4x9+hrl40o/qAIFpQ/HFgrbjc fRWN9Hs5yEYkANpCD1RWuPB3IlGZEXskNja2rPQcSGUMSEtkx8QGxBKbjXRJlbrtoAfdt9cA3q wVSxr2K20zlU+O71DHrcmLGDtj8BrZGBsBf1rFYwk9NtAZcvYGFTgymAX9P5rJsd8RHRbGZYQO rao= Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa2.mentor.iphmx.com with ESMTP; 09 Dec 2019 07:21:58 -0800 IronPort-SDR: apO/Pg2tJ5MZezQ0AQMmG5S/rCHjjBVK9ymjqnxOx38H8avhQ/eJ8oOCzkLcKd45GrvpUhQN7v dnwN017On6KjzYVGG8Pv2daELIW7GfKPAS3tVLmkty5b06EiCrVvoH1sDOIzhbx6dOvz+mjXnp 1TBWeMfIX3zk0vT3RYpt/aNjJqPqjkODkTwm1eMZo6Jnxcmy0Mm4QeffBjMP6gOSW/6gQkRr1p GCTVrd5UH/pZThT9ZbQDu85kUT5ZuhNbsXDbv3NK00m/59iqK8fse7IeDuAGpeHBwbSUSZNNwK +l8= From: Andrew Stubbs Subject: [RFC, vectorizer] Fix ICE with masked vectors To: "gcc-patches@gcc.gnu.org" CC: Richard Sandiford Message-ID: Date: Mon, 9 Dec 2019 15:21:52 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.1 MIME-Version: 1.0 Hi, This patch fixes an ICE in testcase gcc.dg/vect/vect-ctor-1.c: during GIMPLE pass: vect dump file: vect-ctor-1.c.159t.vect .../gcc.dg/vect/vect-ctor-1.c: In function 'intrapred_luma_16x16': .../gcc.dg/vect/vect-ctor-1.c:9:6: internal compiler error: in exact_div, at poly-int.h:2162 0xdf845f poly_int<1u, poly_result::is_poly>::type, poly_coeff_pair_traits::is_poly>::type>::result_kind>::type> exact_div<1u, unsigned long, unsigned long>(poly_int_pod<1u, unsigned long> const&, unsigned long) /scratch/astubbs/amd/src/gcc-mainline/gcc/poly-int.h:2162 0xdf649a poly_int<1u, poly_result::result_kind>::type> exact_div<1u, unsigned long, unsigned long>(poly_int_pod<1u, unsigned long> const&, poly_int_pod<1u, unsigned long> const&) /scratch/astubbs/amd/src/gcc-mainline/gcc/poly-int.h:2175 0x1c473cd vect_get_num_vectors /scratch/astubbs/amd/src/gcc-mainline/gcc/tree-vectorizer.h:1520 0x1c4bd35 vect_enhance_data_refs_alignment(_loop_vec_info*) /scratch/astubbs/amd/src/gcc-mainline/gcc/tree-vect-data-refs.c:1798 0x1596732 vect_analyze_loop_2 /scratch/astubbs/amd/src/gcc-mainline/gcc/tree-vect-loop.c:2095 0x15980f3 vect_analyze_loop(loop*, vec_info_shared*) /scratch/astubbs/amd/src/gcc-mainline/gcc/tree-vect-loop.c:2536 0x15d7b36 try_vectorize_loop_1 /scratch/astubbs/amd/src/gcc-mainline/gcc/tree-vectorizer.c:892 0x15d831f try_vectorize_loop /scratch/astubbs/amd/src/gcc-mainline/gcc/tree-vectorizer.c:1044 0x15d84f9 vectorize_loops() /scratch/astubbs/amd/src/gcc-mainline/gcc/tree-vectorizer.c:1125 0x144f0af execute /scratch/astubbs/amd/src/gcc-mainline/gcc/tree-ssa-loop.c:414 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See for instructions. The problem is that exact_div is being asked to do "8 / 64", which it won't. The comment on the function says "NUNITS should be based on the vectorization factor, so it is always a known multiple of the number of elements in VECTYPE". This is on the amdgcn target where the vectorization factor is always 64, but smaller tasks can be vectorized using masking. I think what's happening here is that the assumption described in the comment is invalid in the presence of masked vectors. The attached patch fixes the ICE in the testcase, but I suspect does not go far enough. Can it happen that NUNITS can be greater than the vectorization factor, but not a multiple? Is this even a valid fix in the first place? Must it be conditionalized on masking being available? Is the exactness even worth checking, in the presence of exceptions? Thanks Andrew WIP Fix vect-ctor-1.c ICE diff --git a/gcc/tree-vectorizer.h b/gcc/tree-vectorizer.h index 51a13f1d207..bf1c3eeda85 100644 --- a/gcc/tree-vectorizer.h +++ b/gcc/tree-vectorizer.h @@ -1513,6 +1513,10 @@ vect_use_loop_mask_for_alignment_p (loop_vec_info loop_vinfo) static inline unsigned int vect_get_num_vectors (poly_uint64 nunits, tree vectype) { + /* Masked vectors can cause partial vector use. */ + if (known_lt (nunits, TYPE_VECTOR_SUBPARTS (vectype))) + return 1; + return exact_div (nunits, TYPE_VECTOR_SUBPARTS (vectype)).to_constant (); }