From patchwork Mon Oct 23 17:34:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 116830 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp4898270qgn; Mon, 23 Oct 2017 10:34:44 -0700 (PDT) X-Received: by 10.99.98.6 with SMTP id w6mr12413276pgb.189.1508780084374; Mon, 23 Oct 2017 10:34:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508780084; cv=none; d=google.com; s=arc-20160816; b=T0odepglZIyWGCpcLfGmw18X3yxLA3RNUaa/DjRVp5gMQojeOQRHntbGwNwXhYQyNs es898IN/BEWavsLcyNp8Og8Moyzvxniuv0T9P5GUDQ6cG+G0w5V9mWyF4+1c1hEx1SDn YdV/duT3yn6sp1yQTRkGC6nOO6rxz841UfBdIFjB71sVQHNH02qh4cHvHFbB0Z6/wOUx X33cOh8F6gdQ2sNxhT7f7jFRC5In4VNErF20GRerVjyg4OD8+18r0VpL/gWhq/H9nuEl 6SY975MSL7YRtVzcQ587Vcws/UiC0aEijdHNl1e11y/U4zLYIyH3fWOZ0RrinXAXgL2k Uhlg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:user-agent:message-id:in-reply-to:date:references :subject:mail-followup-to:to:from:delivered-to:sender:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :mailing-list:dkim-signature:domainkey-signature :arc-authentication-results; bh=5p7+kakjrIRUqJjHIgZHF7/lMyr/1Rs1uOF35zLhMqQ=; b=E+Oe7NcOGTwxF4wF2icyYdOw/SB83OEWuNp2pCU8dHgTtnzP9JVsOS4IOlSwc2kK54 5xnot24oUEsN/iMnKMfTNGRPZj+ohRRHvuqGCgODomgkpGpVlIRFI898Ulab4f52PmTs vxhC6loimRNbeEPVeqQSpq8iBga08XblG/ZCjl/aTjqJzi2PD0bVvzVGon2p3IWG6prc qk6tmJa4s8sPortUUYQz9A2+tgW4rYXcd8vutQfqRIGdF1JnK17kxs/sVnU86LxS+48+ QOWXyBP61f6ltTn/S8LAOWePTX28pfrvYMxjB46TYd5ibRdjZssoeFljGUSUwd/vWx8N FABg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=KwqN0gYK; spf=pass (google.com: domain of gcc-patches-return-464861-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-464861-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id v207si5081241pgb.657.2017.10.23.10.34.44 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Oct 2017 10:34:44 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-464861-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=KwqN0gYK; spf=pass (google.com: domain of gcc-patches-return-464861-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-464861-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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:references:date:in-reply-to:message-id:mime-version :content-type; q=dns; s=default; b=o5JYB9RQRKQ7fDrUzLAcHGYgNeqir 0qwuTrGots9KdbEgNTz98TPauV9LycqiOA2mGEvzXPXe9SDJYdkUO/AkIxbJ+JTL nMudWVLHyCPxoIIKEeTUR+FmVfqOS1doZ3niKPMoXjdUaabOhLvmqZzbDPSUOLLX 4Gj84JI/DOmbHA= 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:references:date:in-reply-to:message-id:mime-version :content-type; s=default; bh=hE4xp87NRK4j2IUm+vDzWy85vCs=; b=Kwq N0gYK8xYckziectgjbspJWZ/yso+iC3XEt4amfKl0Q0W8gr7u8XVM0T3+rd1SQaU WlszH3ZlSSCsG+GOFbf+w02YAqhrQ7U6N3hVOycb+ZyXKRk4Ut6QM/x1/KmUKSuw zkEteQl/55L92oAHPwMdzKSf1RBCxGCOw6pC/eYU= Received: (qmail 60639 invoked by alias); 23 Oct 2017 17:34: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 60621 invoked by uid 89); 23 Oct 2017 17:34:29 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-wm0-f46.google.com Received: from mail-wm0-f46.google.com (HELO mail-wm0-f46.google.com) (74.125.82.46) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 23 Oct 2017 17:34:28 +0000 Received: by mail-wm0-f46.google.com with SMTP id q124so11033196wmb.0 for ; Mon, 23 Oct 2017 10:34:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:mail-followup-to:subject:references:date :in-reply-to:message-id:user-agent:mime-version; bh=5p7+kakjrIRUqJjHIgZHF7/lMyr/1Rs1uOF35zLhMqQ=; b=a6NNCMRJlKmWeCGw5KwkypDUeqhpYVswkcS+s3GMZKGOxqZRmWXz1xkIwA9I8QWoWe 6Oxgp44xrxvPBewrjthVhXdJvBHp+Lsmgr9ioPxy3u0x+9xe51hSVdEp2tcCVcfLGIcb 5fP/7plQVZ+eAsNvCgec0Ou6gaC/lELPkm4f5X9n/Jfk5pQBeFbmNkE+gxRBRMYFmpf0 A6/uyFcmGLC9JabptnMtyVJYUFMMv0vJj2U4odGlJc2LS4Rkcn4xpc3xNMe1CiZSt73D I5+6zcOOgylTPP7qjcDolvt6x+2UUpWrJcIHprDlkngU3f7yvQhg0qCg7eIbobh5iLYh 0Bzg== X-Gm-Message-State: AMCzsaVGACLvBI6RgV5BYySfvs+fGnOW+tUrFHbRQ/u0tnz/gE4hcdeN UL1SjhqGhnx6IG0crLr8uZlePZHjOgQ= X-Google-Smtp-Source: ABhQp+RYRubL1Yn5tEp/xzGm7rr6fAYhvAghIugv9G128jVDAKa2cC683uHr9PP8ltjGqbN63WV/6Q== X-Received: by 10.28.125.139 with SMTP id y133mr6180490wmc.25.1508780066204; Mon, 23 Oct 2017 10:34:26 -0700 (PDT) Received: from localhost ([2.26.27.199]) by smtp.gmail.com with ESMTPSA id l80sm5444067wmb.2.2017.10.23.10.34.25 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Oct 2017 10:34:25 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [085/nnn] poly_int: expand_vector_ubsan_overflow References: <871sltvm7r.fsf@linaro.org> Date: Mon, 23 Oct 2017 18:34:24 +0100 In-Reply-To: <871sltvm7r.fsf@linaro.org> (Richard Sandiford's message of "Mon, 23 Oct 2017 17:54:32 +0100") Message-ID: <87lgk1g44f.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 This patch makes expand_vector_ubsan_overflow cope with a polynomial number of elements. 2017-10-23 Richard Sandiford Alan Hayward David Sherwood gcc/ * internal-fn.c (expand_vector_ubsan_overflow): Handle polynomial numbers of elements. Index: gcc/internal-fn.c =================================================================== --- gcc/internal-fn.c 2017-10-23 17:11:39.913311438 +0100 +++ gcc/internal-fn.c 2017-10-23 17:22:51.056325855 +0100 @@ -1872,7 +1872,7 @@ expand_mul_overflow (location_t loc, tre expand_vector_ubsan_overflow (location_t loc, enum tree_code code, tree lhs, tree arg0, tree arg1) { - int cnt = TYPE_VECTOR_SUBPARTS (TREE_TYPE (arg0)); + poly_uint64 cnt = TYPE_VECTOR_SUBPARTS (TREE_TYPE (arg0)); rtx_code_label *loop_lab = NULL; rtx cntvar = NULL_RTX; tree cntv = NULL_TREE; @@ -1882,6 +1882,8 @@ expand_vector_ubsan_overflow (location_t tree resv = NULL_TREE; rtx lhsr = NULL_RTX; rtx resvr = NULL_RTX; + unsigned HOST_WIDE_INT const_cnt = 0; + bool use_loop_p = (!cnt.is_constant (&const_cnt) || const_cnt > 4); if (lhs) { @@ -1902,7 +1904,7 @@ expand_vector_ubsan_overflow (location_t } } } - if (cnt > 4) + if (use_loop_p) { do_pending_stack_adjust (); loop_lab = gen_label_rtx (); @@ -1921,10 +1923,10 @@ expand_vector_ubsan_overflow (location_t rtx arg1r = expand_normal (arg1); arg1 = make_tree (TREE_TYPE (arg1), arg1r); } - for (int i = 0; i < (cnt > 4 ? 1 : cnt); i++) + for (unsigned int i = 0; i < (use_loop_p ? 1 : const_cnt); i++) { tree op0, op1, res = NULL_TREE; - if (cnt > 4) + if (use_loop_p) { tree atype = build_array_type_nelts (eltype, cnt); op0 = uniform_vector_p (arg0); @@ -1964,7 +1966,7 @@ expand_vector_ubsan_overflow (location_t false, false, false, true, &data); break; case MINUS_EXPR: - if (cnt > 4 ? integer_zerop (arg0) : integer_zerop (op0)) + if (use_loop_p ? integer_zerop (arg0) : integer_zerop (op0)) expand_neg_overflow (loc, res, op1, true, &data); else expand_addsub_overflow (loc, MINUS_EXPR, res, op0, op1, @@ -1978,7 +1980,7 @@ expand_vector_ubsan_overflow (location_t gcc_unreachable (); } } - if (cnt > 4) + if (use_loop_p) { struct separate_ops ops; ops.code = PLUS_EXPR; @@ -1991,7 +1993,8 @@ expand_vector_ubsan_overflow (location_t EXPAND_NORMAL); if (ret != cntvar) emit_move_insn (cntvar, ret); - do_compare_rtx_and_jump (cntvar, GEN_INT (cnt), NE, false, + rtx cntrtx = gen_int_mode (cnt, TYPE_MODE (sizetype)); + do_compare_rtx_and_jump (cntvar, cntrtx, NE, false, TYPE_MODE (sizetype), NULL_RTX, NULL, loop_lab, profile_probability::very_likely ()); }