From patchwork Tue Nov 20 19:40:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 1000688 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-490554-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="j3kBCyNz"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="UeFqg5uT"; 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 42zwzg0GWQz9s9G for ; Wed, 21 Nov 2018 06:40:46 +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 :mime-version:from:date:message-id:subject:to:content-type; q= dns; s=default; b=BU5RHxe1bc9o7NWhNvX5z4wVu35I/rp7W7ftC2yS17VNhS Sm3UhM9bW4TnHmUcDHZYsJCBuN+rCrgaLHbYMiXuAvC4ezuys9XtnytGS9kvGlqI wbiOwRsCL8XEG57tnyRPmf9qNHQPZEx4CyfIP7iUykWI9dzVfvBE0e2zNwYTo= 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 :mime-version:from:date:message-id:subject:to:content-type; s= default; bh=ewvMkiKMPdjxzUNZNMy1m74WBek=; b=j3kBCyNzDINIQcRh8BZs MPBYNHDtRRUMgeb6eLsQUaAIlcpBVw+tbD6ZlzKNZeeFpWG7ZGLs2bnWzUyNsszD SRFaaP10FxbGxYe2Y8pBNKbWpLuqG6fsRnmEi13UFDZ1HlpPufuupNI6RFHVchpM 1bju6HnMhjaG5WqTNTwST8Q= Received: (qmail 102381 invoked by alias); 20 Nov 2018 19:40:39 -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 102370 invoked by uid 89); 20 Nov 2018 19:40:39 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.0 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:2942, pr88070c, pr88070.c, liberty X-HELO: mail-it1-f196.google.com Received: from mail-it1-f196.google.com (HELO mail-it1-f196.google.com) (209.85.166.196) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 20 Nov 2018 19:40:37 +0000 Received: by mail-it1-f196.google.com with SMTP id h65so5389540ith.3 for ; Tue, 20 Nov 2018 11:40:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=F11E3NaQGwJh5oh4RG/rlNqIGl8Spt+wNI5aEUWqzwo=; b=UeFqg5uTL9GkuTjyUREGDUcCkZEa9CoW4fUu07coYj4HmnZ/PuGib9fqIAePs3lLKd 1mjwsYe3Mhx7ZXd9jmCMHkKFBNzMtCamTe9WZhwHzzR8LIgo+qDpyxlUmTPVMUCIVHFn po7sNygcX04pt4LQQloBjqMA4UrDbXjl4WteYIV3zsV3ou+vElJjIVkOvQT+/dkuDDuJ urhw6l//LD3hwIUXxCdrhOJXFCNAuSkehwQTWe4WwMDPbGUlo5RO2apIAK2Z4oh0SPu9 G9Px/bAu7j23n9nfdSiPx30adkbfFRddhGD1dSDifEDqUGwX6ZRGS+V7Bd2PY9KK+HBQ tzVQ== MIME-Version: 1.0 From: Uros Bizjak Date: Tue, 20 Nov 2018 20:40:24 +0100 Message-ID: Subject: [PATCH v2, target]: Fix PR 88070, ICE in create_pre_exit, at mode-switching.c:438 To: "gcc-patches@gcc.gnu.org" Hello! Attached patch is a different approach to the problem of split return copies in create_pre_exit. It turns out that for vzeroupper insertion pass, we actually don't need to insert a mode switch before the return copy, it is enough to split edge to exit block - so we can emit vzeroupper at the function exit edge. Since x86 is the only target that uses optimize mode switching after reload, I took the liberty and used !reload_completed for the condition when we don't need to search for return copy. Sure, with the big comment as evident from the patch. 2018-11-20 Uros Bizjak PR target/88070 * mode-switching.c (create_pre_exit): After reload, always split the fallthrough edge to the exit block. testsuite/ChangeLog: 2018-11-20 Uros Bizjak PR target/88070 * gcc.target/i386/pr88070.c: New test. Patch was bootstrapped and regression tested on x86_64-linux-gnu {,-m32}. Committed to mainline SVN. Uros. Index: mode-switching.c =================================================================== --- mode-switching.c (revision 266278) +++ mode-switching.c (working copy) @@ -248,8 +248,22 @@ create_pre_exit (int n_entities, int *entity_map, gcc_assert (!pre_exit); /* If this function returns a value at the end, we have to insert the final mode switch before the return value copy - to its hard register. */ - if (EDGE_COUNT (EXIT_BLOCK_PTR_FOR_FN (cfun)->preds) == 1 + to its hard register. + + x86 targets use mode-switching infrastructure to + conditionally insert vzeroupper instruction at the exit + from the function where there is no need to switch the + mode before the return value copy. The vzeroupper insertion + pass runs after reload, so use !reload_completed as a stand-in + for x86 to skip the search for the return value copy insn. + + N.b.: the code below assumes that the return copy insn + immediately precedes its corresponding use insn. This + assumption does not hold after reload, since sched1 pass + can schedule the return copy insn away from its + corresponding use insn. */ + if (!reload_completed + && EDGE_COUNT (EXIT_BLOCK_PTR_FOR_FN (cfun)->preds) == 1 && NONJUMP_INSN_P ((last_insn = BB_END (src_bb))) && GET_CODE (PATTERN (last_insn)) == USE && GET_CODE ((ret_reg = XEXP (PATTERN (last_insn), 0))) == REG) Index: testsuite/gcc.target/i386/pr88070.c =================================================================== --- testsuite/gcc.target/i386/pr88070.c (nonexistent) +++ testsuite/gcc.target/i386/pr88070.c (working copy) @@ -0,0 +1,12 @@ +/* PR target/88070 */ +/* { dg-do compile } */ +/* { dg-options "-O -fexpensive-optimizations -fnon-call-exceptions -fschedule-insns -fno-dce -fno-dse -mavx" } */ + +typedef float vfloat2 __attribute__ ((__vector_size__ (2 * sizeof (float)))); + +vfloat2 +test1float2 (float c) +{ + vfloat2 v = { c, c }; + return v; +}