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: 918031 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-478136-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="M2MAwtYC"; 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 40qmgz4TWnz9s3T for ; Tue, 22 May 2018 16:58:21 +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:mime-version:content-type; q=dns; s= default; b=ytbLZoDbBRQ6LHZt1U85WLtOMXXRalGVir3AKWxQrzGJ0G4JMGY/C TfdKRNWCm5OjdXk0TIE9ZkQ5jLpO4iKyTBCzTNgwzTItWVdhsW08FAaT/zzit5UN 2KH7qYKOLyETkrNEKCmwqP+OBg3TOGEkooNI3zMf6oAsqSPu8Yqdf8= 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=M2MAwtYCHhBc492xpxWg wVU73B1dlzYsay8fAmxVCH3Knz5/yhVEyXrkg2dKnhNVGJQ/+PyqIPQfC5kOBhi7 1KWe/LYIEC/4fD6zmfHYfyaFdFyI8IIWHy8RsGKeuArHQkwX3FKQEN7qkZZv3mde pW4ftcwzdK/Zh2z7HohWk0c= 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-Google-Smtp-Source: AB8JxZoCevPuMFzLMakWfNJgDgeCKfHxAKJCY3tvToamZ00TVrZz1I/+4eeZZvQgDCur6WTQiQxJUg== 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; +}