From patchwork Tue Feb 20 17:18:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 128936 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp4868192ljc; Tue, 20 Feb 2018 09:18:18 -0800 (PST) X-Google-Smtp-Source: AH8x224TqzIhgPwIpFvu9p62KXFNnf6tgFITzLU0LlLo+5WgsFhVrQIzq3OxdvWLnUtK8OB1DNVe X-Received: by 10.167.130.12 with SMTP id k12mr318709pfi.73.1519147098500; Tue, 20 Feb 2018 09:18:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519147098; cv=none; d=google.com; s=arc-20160816; b=oBgk5pzguQ5LkwnJadn8HqlPll1191eYGihhYCH/BpPT0tFwEztSXff5rWUIOca+G5 wRCu58hEbUlR7Z9G/0Yc0PF0re7zFztj/zVnhm9H4R6nlVrQPtttw3sa/W872KttMI/X 6F5GlOYAWl4EIMtLyqyasad2Ie7MkzvbnIPhqFIeRrmbKVOUC3mwRiNIomqv+3IQI6Uq 8oh5tWr1uQ/GxOGl/idAIgk68LiZoqyjwT0Yk0+mcf78gdDtJTje4nLdZ4pdAmAqJ6el Uio206OCkZXa2Bv7zFQcMkus1UEtPygP27H//18ZN661fzIGAkhfVbd8YsRkk5jHKYeE 0Z/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:user-agent:message-id:date: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=L8OWABqB8IcEio4rhw9JIOk/xZUpJYgOXz70fbEraxs=; b=WxCh1BoLvuROhqHofLPc7I0PgQf9MseiAJxOGDpSG9lxL1QsxdsztkQFt6sCrWq4ps npeg0eWS7UzDS8kBSFVb0lHyLRnnZf7CXINOVQhPridnceuavQQ2sZtq6+RDmjraF/9p yGEx9sQyMYV81JW1jBMIprE1xMSuHq25yiSNyU6iXcGVNH9IGXOqsxSeeMAj41jWDfo/ FlqQXXar4f/MfFsqXrYGNfS22euoByuGBe2ZA+w/YzGL51mYbQrUrIotucEc5xGVxYSj O8woZ12uHvsqXrfwtC5eSwINQqwH15glrVV8YsJ0LmC9dJ+IoZd69Jr0aJQ52tQHJiXf 4Bow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=QPztEbgp; spf=pass (google.com: domain of gcc-patches-return-473606-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-473606-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 g5si1473180pgo.780.2018.02.20.09.18.18 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Feb 2018 09:18:18 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-473606-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=QPztEbgp; spf=pass (google.com: domain of gcc-patches-return-473606-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-473606-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:date:message-id:mime-version:content-type; q=dns; s= default; b=ECKGsVGQLY0yPqRUzz6MrGsimWh3GY/+0inUH8oqiNzGT/gvOKEDB D8Gx9Ge8FQxtDDfj24u8t5Gi06yBYQFiwHsSWHmm757Kq8sDXEmrDYpHFCotnDyK mkBGFS+IWHQcMJXApBiZBFvie1/4QYbR34lwb8jq/lEgVtj8CctHKc= 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:mime-version:content-type; s= default; bh=WSf9LraCKS/iH//oZMJzA6km8QY=; b=QPztEbgpua5sbLi8YMOC 8vW5fHUwE7lJcVYN3/ejjlFhIt5fwSVteVPvTkwgoSCFnsrJteRRFE6pXbCR+S/I isfZXU0Q7HyU45pvGyz42ic/FcNEA+9cNSzVi5qkg/Qb/D0ABKhEOatecVk1s4Ch IuETIcJo6tiKcyAIUu9lEro= Received: (qmail 72528 invoked by alias); 20 Feb 2018 17:18:07 -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 72516 invoked by uid 89); 20 Feb 2018 17:18:06 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-12.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-wr0-f176.google.com Received: from mail-wr0-f176.google.com (HELO mail-wr0-f176.google.com) (209.85.128.176) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 20 Feb 2018 17:18:05 +0000 Received: by mail-wr0-f176.google.com with SMTP id l43so16558314wrc.2 for ; Tue, 20 Feb 2018 09:18:04 -0800 (PST) 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:date:message-id :user-agent:mime-version; bh=L8OWABqB8IcEio4rhw9JIOk/xZUpJYgOXz70fbEraxs=; b=KBiBpZryq5Fh5zoVb337GnPgriaS+JhVmELflShS7RdbXxiGY8B/zH+1brKIMSr2u/ 9ES7fAHFjws4yUF8w/zRypcq9dNqe+Vd5nAiwZ79cYTZV/yti1+mCZMUAx54ZeUlcuP0 mjYsC3sWxv7TbzutSNP9rCZCbZBaZaZeQQQsqRBOfwfMGtwZMULab9pMaMX7DYttN1tW 1O6KQTogzKXmWHmhtd5JQtJHH+JxQID40QoIpL7uSvDhl+XDI6930CWAvj0/IUFEO9GW ZpraJp2nKW8h44/CvP7Nrpt6SRXkBTAsYvZQi4aiu17wxRNCv6/Da2jWSW/kPdPQt/OV Jt1Q== X-Gm-Message-State: APf1xPAzZMBDWvfU7a8K6rxFAnVSuY/TykPfCKHeItT0iJHmJxLHrpfm yP/yXvfp0FhRig7I6yP8mYRwRe9RrEM= X-Received: by 10.28.153.133 with SMTP id b127mr755623wme.105.1519147082613; Tue, 20 Feb 2018 09:18:02 -0800 (PST) Received: from localhost (79.58.7.51.dyn.plus.net. [51.7.58.79]) by smtp.gmail.com with ESMTPSA id 128sm1825762wmi.20.2018.02.20.09.18.01 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 20 Feb 2018 09:18:01 -0800 (PST) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: Fix find_widening_optab_handler_and_mode assertion (PR 84406) Date: Tue, 20 Feb 2018 17:18:00 +0000 Message-ID: <871shfshpz.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 r254302 tried to clean up find_widening_optab_handler_and_mode so that it really did only handle widening ops rather than simple single-mode ones. But this PR shows that I'd fluffed the MODE_PARTIAL_INT handling. It turns out that all four combinations of: {MODE_INT,MODE_PARTIAL_INT}->{MODE_INT,MODE_PARTIAL_INT} are possible, and GET_MODE_WIDER_MODE for a MODE_PARTIAL_INT returns a MODE_INT (which makes sense in retrospect). No test case since this is a build failure on affected targets. Tested on aarch64-linux-gnu, x86_64-linux-gnu and powerpc64le-linux-gnu. Also tested by Jozef on msp430-elf (thanks). OK to install? Richard 2018-02-20 Richard Sandiford gcc/ PR middle-end/84406 * optabs-query.c (find_widening_optab_handler_and_mode): If from_mode is a scalar_int_mode, assert that to_mode is a scalar_int_mode with greater precision. If to_mode is a MODE_PARTIAL_INT, stop the search at the associated MODE_INT. Index: gcc/optabs-query.c =================================================================== --- gcc/optabs-query.c 2018-01-13 18:01:51.236735252 +0000 +++ gcc/optabs-query.c 2018-02-20 17:16:11.783836883 +0000 @@ -473,9 +473,23 @@ find_widening_optab_handler_and_mode (op machine_mode from_mode, machine_mode *found_mode) { - gcc_checking_assert (GET_MODE_CLASS (from_mode) == GET_MODE_CLASS (to_mode)); - gcc_checking_assert (from_mode < to_mode); - FOR_EACH_MODE (from_mode, from_mode, to_mode) + machine_mode limit_mode = to_mode; + if (is_a (from_mode)) + { + gcc_checking_assert (is_a (to_mode) + && known_lt (GET_MODE_PRECISION (from_mode), + GET_MODE_PRECISION (to_mode))); + /* The modes after FROM_MODE are all MODE_INT, so the only + MODE_PARTIAL_INT mode we consider is FROM_MODE itself. + If LIMIT_MODE is MODE_PARTIAL_INT, stop at the containing + MODE_INT. */ + if (GET_MODE_CLASS (limit_mode) == MODE_PARTIAL_INT) + limit_mode = GET_MODE_WIDER_MODE (limit_mode).require (); + } + else + gcc_checking_assert (GET_MODE_CLASS (from_mode) == GET_MODE_CLASS (to_mode) + && from_mode < to_mode); + FOR_EACH_MODE (from_mode, from_mode, limit_mode) { enum insn_code handler = convert_optab_handler (op, to_mode, from_mode);