From patchwork Tue May 22 06:58:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 136513 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1246405lji; Mon, 21 May 2018 23:58:27 -0700 (PDT) X-Google-Smtp-Source: AB8JxZr7kDpIVmAMedZxjhtKuwKHYLgQqs1qU1pcnQQ876grQ/uWnhIi7ZMg7EbzqmoaHMptcsXU X-Received: by 2002:a17:902:9304:: with SMTP id bc4-v6mr23503532plb.189.1526972306931; Mon, 21 May 2018 23:58:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526972306; cv=none; d=google.com; s=arc-20160816; b=KzoIY/yplWddfw4Mr2Pxc2+tc0zAGhLCbbAl17WDgZk3gLjrYYVJeO6McKe+oYR9FM 3sJD8HVa1AhE1tTdGsDc0tGAKDXmH1pNh/3BJn6S9nz/qVZ9yIpreh5nHxvce+RVWyHn dQztx6TPo21E6vjcht52lyFhHcm4IFIuU3MOLsq3VXDA/8+HdlWzOY7HxD5cTl5cZbqQ maZ3ffU1zk14ovvaMOZqcLJgBJfycM2Gcd8B/Np8f3o4wsmyyV3UjTAthaOmkNftCGZQ nyILH/HMSzPNVvZeHThWlFXuTIaLU41qbjoTEd4iGnqul3Jy8+JjJYgGBMZ/zO/4AesX aCCg== 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=PU7GaOQhiEg1CLZwmoUuN209qqNIHAM9dBnoI67pv0o=; b=jU/+dhSVfiRjFgC0rsIDr7v4U9ih7pE2qxNWXByMz/RTigaQZqkIkZfY9RqgtEPl4f 5oXI1Ba7vdNP5FxOfnNmRDXRu8P8ylRJMRb0NfHHrm0t9QJayEvCdkrnuzVMO97okJdL Icg3ujIqDKTgVV03R8UhBiaESP5L/a0fI9AhwaZVor1X9RP3nsxqC4+w0L5aBEcApILh +Cv7lWO0/ddzJd1CzDcqhj8s/PWoTciwPSjUG13hg8wSFt3JqsYEfVZzELNnQ4zBOxMy GDfOnlP/1KA8TRo+Z42naC00SiQZMBxFkHWaNwrZA8d+n2ydxFxoLleQQs78BtYW0iPC SsPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=dZYEWz3Y; spf=pass (google.com: domain of gcc-patches-return-478136-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-478136-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 p80-v6si15891600pfi.345.2018.05.21.23.58.26 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 May 2018 23:58:26 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-478136-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=dZYEWz3Y; spf=pass (google.com: domain of gcc-patches-return-478136-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-478136-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=s2WevR0q+jYnLxkFUdeuC34lHq4R2nx2cHHwzhNradCt+kbCZ1Mgl tGYOLCo7D7KFh6OBJ38V/W1aZ9UBvxrE59uHSqeIX5sC2apXAWuBov3uJF2XrN1V n6mii1lO/L3ZtAum+1B0ar+PUsjv84Vzc5sWzmoiS+tedJ1sw1HOvc= 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=HNrrt69q5zCBn04rWZo2sGovOzE=; b=dZYEWz3YN/piUcbCsEkD DlNf6knFaspXQwJDWhQvMw/Uc3hpoklPG63R0uO+iCHc1pq075sG/IqLmdTlCd6U qn45amzWgiydpYW175iGgvwfwRLWWqNRUo+fwnbnMcMYpF8Fl4799z0rrmYp/VGV oVMnlMkiPLnZFeUeeEwYmmE= Received: (qmail 66787 invoked by alias); 22 May 2018 06:58:14 -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 66663 invoked by uid 89); 22 May 2018 06:58:11 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-wm0-f49.google.com Received: from mail-wm0-f49.google.com (HELO mail-wm0-f49.google.com) (74.125.82.49) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 22 May 2018 06:58:10 +0000 Received: by mail-wm0-f49.google.com with SMTP id f8-v6so30629206wmc.4 for ; Mon, 21 May 2018 23:58:09 -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:date:message-id :user-agent:mime-version; bh=PU7GaOQhiEg1CLZwmoUuN209qqNIHAM9dBnoI67pv0o=; b=q9Q998lj3lOqvixwxD3PbgbDGa1+zq9fJOeJFv28EqF3H4GPFvQLYkRq0EShUjZYzz yeBdcXFtfjUsBGcyr+PlkSqIzuXAXVW9MyEvWPXkbKAz3EIgo+6bzYBD5GSOEgmhamgG 7IvIOptRf/GBrtqLvGFuXlPtfmg1x+JDyNaOBmeZQNK20iGgEsweJMc4veWTs0UvbfeZ pAy9t5GZVaDJTSI7E196EhEC0wLSW5NErT6Vs9veKSyt0hSXtV4nq49i9/h54W2v+yp8 gtbfYNHrDzZGsptqxbkGDSDaS4sRWzFnAlYU2trw2+bor+1T64xyOrvBsZOvSlZsEovO M1Ug== X-Gm-Message-State: ALKqPwc7KP7sLGycuHCW4UbAN7O78B5fbaMGn9mFWHaygdNBFDHUbtQ3 D9za19+D4Z4cXmZI+JCV1vRq1m6cbpg= X-Received: by 2002:a1c:dca:: with SMTP id 193-v6mr182856wmn.36.1526972287764; Mon, 21 May 2018 23:58:07 -0700 (PDT) Received: from localhost (201.69.7.51.dyn.plus.net. [51.7.69.201]) by smtp.gmail.com with ESMTPSA id j129-v6sm1191521wmb.15.2018.05.21.23.58.06 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 21 May 2018 23:58:06 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: Handle a null lhs in expand_direct_optab_fn (PR85862) Date: Tue, 22 May 2018 07:58:05 +0100 Message-ID: <878t8cmb2a.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 This PR showed that the normal function for expanding directly-mapped internal functions didn't handle the case in which the call was only being kept for its side-effects. Tested on aarch64-linux-gnu (with and without SVE), aarch64_be-elf and x86_64-linux-gnu. OK to install? Richard 2018-05-22 Richard Sandiford gcc/ PR middle-end/85862 * internal-fn.c (expand_direct_optab_fn): Cope with a null lhs. gcc/testsuite/ PR middle-end/85862 * gcc.dg/torture/pr85862.c: New test. Index: gcc/internal-fn.c =================================================================== --- gcc/internal-fn.c 2018-05-18 09:26:37.734714355 +0100 +++ gcc/internal-fn.c 2018-05-22 07:56:26.130013854 +0100 @@ -2891,14 +2891,15 @@ expand_direct_optab_fn (internal_fn fn, insn_code icode = direct_optab_handler (optab, TYPE_MODE (types.first)); tree lhs = gimple_call_lhs (stmt); - tree lhs_type = TREE_TYPE (lhs); - rtx lhs_rtx = expand_expr (lhs, NULL_RTX, VOIDmode, EXPAND_WRITE); + rtx lhs_rtx = NULL_RTX; + if (lhs) + lhs_rtx = expand_expr (lhs, NULL_RTX, VOIDmode, EXPAND_WRITE); /* Do not assign directly to a promoted subreg, since there is no guarantee that the instruction will leave the upper bits of the register in the state required by SUBREG_PROMOTED_SIGN. */ rtx dest = lhs_rtx; - if (GET_CODE (dest) == SUBREG && SUBREG_PROMOTED_VAR_P (dest)) + if (dest && GET_CODE (dest) == SUBREG && SUBREG_PROMOTED_VAR_P (dest)) dest = NULL_RTX; create_output_operand (&ops[0], dest, insn_data[icode].operand[0].mode); @@ -2917,7 +2918,7 @@ expand_direct_optab_fn (internal_fn fn, } expand_insn (icode, nargs + 1, ops); - if (!rtx_equal_p (lhs_rtx, ops[0].value)) + if (lhs_rtx && !rtx_equal_p (lhs_rtx, ops[0].value)) { /* If the return value has an integral type, convert the instruction result to that type. This is useful for things that return an @@ -2931,7 +2932,7 @@ expand_direct_optab_fn (internal_fn fn, /* If this is a scalar in a register that is stored in a wider mode than the declared mode, compute the result into its declared mode and then convert to the wider mode. */ - gcc_checking_assert (INTEGRAL_TYPE_P (lhs_type)); + gcc_checking_assert (INTEGRAL_TYPE_P (TREE_TYPE (lhs))); rtx tmp = convert_to_mode (GET_MODE (lhs_rtx), ops[0].value, 0); convert_move (SUBREG_REG (lhs_rtx), tmp, SUBREG_PROMOTED_SIGN (lhs_rtx)); @@ -2940,7 +2941,7 @@ expand_direct_optab_fn (internal_fn fn, emit_move_insn (lhs_rtx, ops[0].value); else { - gcc_checking_assert (INTEGRAL_TYPE_P (lhs_type)); + gcc_checking_assert (INTEGRAL_TYPE_P (TREE_TYPE (lhs))); convert_move (lhs_rtx, ops[0].value, 0); } } Index: gcc/testsuite/gcc.dg/torture/pr85862.c =================================================================== --- /dev/null 2018-04-20 16:19:46.369131350 +0100 +++ gcc/testsuite/gcc.dg/torture/pr85862.c 2018-05-22 07:56:26.131013803 +0100 @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-fexceptions -fnon-call-exceptions" } */ +/* { dg-additional-options "-fexceptions -fnon-call-exceptions -mfma" { target i?86-*-* x86_64-*-* } } */ + +void +ki (double nq) +{ + double no = 1.1 * nq - nq; +}