From patchwork Thu Dec 13 20:56:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Vladimir Makarov X-Patchwork-Id: 1013146 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-492409-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="ZejgWkP7"; 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 43G5Zq0d8bz9s4s for ; Fri, 14 Dec 2018 07:56:49 +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:from :subject:to:message-id:date:mime-version:content-type; q=dns; s= default; b=gqiw+qndIAK0haq80LIzC685bBvfI7TMpQo2vexMKr9XW+TBiaSPZ KnRxecVaLZA7etJCw3u7yt2I/dR25zOChp1Gai42f9dsC/B0bnZ/BXt7F9KCmsBO U0IrVIEmP83/ZzcH+YqAQxwnyFoGp0yDmhpYPtMDEssmNSd85MaXIU= 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 :subject:to:message-id:date:mime-version:content-type; s= default; bh=B7cwwIHx1YjHxNjGHeLq5WeFrdU=; b=ZejgWkP70j3OxjcyC2Qv X7B+VcGtCKPM+qKOL7tr+oOSTjUkV1DWeZJSh6pzkD6sNpGlbbA5GDl+L7SJhc0t MmYSs/Lb1oWR44qNUzD0erX7oJ3XoEh3o4sngbHrkO2vYE6XiR/T4QgxY7zvnrcl sl1/XF9mYeTgiQFy6J2zle4= Received: (qmail 35151 invoked by alias); 13 Dec 2018 20:56:42 -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 35139 invoked by uid 89); 13 Dec 2018 20:56:41 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-10.6 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, KAM_NUMSUBJECT, KAM_SHORT, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=ftrapv X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Dec 2018 20:56:39 +0000 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0729E3002081 for ; Thu, 13 Dec 2018 20:56:38 +0000 (UTC) Received: from tobol.usersys.redhat.com (unused-10-15-17-174.yyz.redhat.com [10.15.17.174]) by smtp.corp.redhat.com (Postfix) with ESMTP id BFC8C5D6A9 for ; Thu, 13 Dec 2018 20:56:37 +0000 (UTC) From: Vladimir Makarov Subject: patch to fix PR88414 To: gcc-patches Message-ID: Date: Thu, 13 Dec 2018 15:56:37 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.1 MIME-Version: 1.0 X-IsSubscribed: yes The following patch fixes    https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88414 The patch was bootstrapped and tested on x86-64. Committed as rev. 267109. Index: ChangeLog =================================================================== --- ChangeLog (revision 267108) +++ ChangeLog (working copy) @@ -1,3 +1,14 @@ +2018-12-13 Vladimir Makarov + + PR rtl-optimization/88414 + * lra-int.h (lra_asm_error_p): New. + * lra-assigns.c (lra_assign): Check lra_asm_error_p for checking + call crossed pseudo assignment correctness. + (lra_split_hard_reg_for): Set up lra_asm_error_p. + * lra-constraints.c (curr_insn_transform): Ditto. + * lra.c (lra_asm_error_p): New. + (lra): Reset lra_asm_error_p. + 2018-12-13 Jakub Jelinek PR rtl-optimization/88416 Index: lra-int.h =================================================================== --- lra-int.h (revision 266678) +++ lra-int.h (working copy) @@ -288,6 +288,7 @@ typedef struct lra_insn_recog_data *lra_ extern FILE *lra_dump_file; +extern bool lra_asm_error_p; extern bool lra_reg_spill_p; extern HARD_REG_SET lra_no_alloc_regs; Index: lra.c =================================================================== --- lra.c (revision 266678) +++ lra.c (working copy) @@ -2334,6 +2334,9 @@ bitmap_head lra_subreg_reload_pseudos; /* File used for output of LRA debug information. */ FILE *lra_dump_file; +/* True if we found an asm error. */ +bool lra_asm_error_p; + /* True if we should try spill into registers of different classes instead of memory. */ bool lra_reg_spill_p; @@ -2371,7 +2374,8 @@ lra (FILE *f) bool live_p, inserted_p; lra_dump_file = f; - + lra_asm_error_p = false; + timevar_push (TV_LRA); /* Make sure that the last insn is a note. Some subsequent passes Index: lra-constraints.c =================================================================== --- lra-constraints.c (revision 267108) +++ lra-constraints.c (working copy) @@ -3940,6 +3940,7 @@ curr_insn_transform (bool check_only_p) fatal_insn ("unable to generate reloads for:", curr_insn); error_for_asm (curr_insn, "inconsistent operand constraints in an %"); + lra_asm_error_p = true; /* Avoid further trouble with this insn. Don't generate use pattern here as we could use the insn SP offset. */ lra_set_insn_deleted (curr_insn); Index: lra-assigns.c =================================================================== --- lra-assigns.c (revision 266678) +++ lra-assigns.c (working copy) @@ -1615,7 +1615,10 @@ lra_assign (bool &fails_p) bitmap_initialize (&all_spilled_pseudos, ®_obstack); create_live_range_start_chains (); setup_live_pseudos_and_spill_after_risky_transforms (&all_spilled_pseudos); - if (flag_checking && !flag_ipa_ra) + if (! lra_asm_error_p && flag_checking && !flag_ipa_ra) + /* Check correctness of allocation for call-crossed pseudos but + only when there are no asm errors as in the case of errors the + asm is removed and it can result in incorrect allocation. */ for (i = FIRST_PSEUDO_REGISTER; i < max_regno; i++) if (lra_reg_info[i].nrefs != 0 && reg_renumber[i] >= 0 && lra_reg_info[i].call_p @@ -1783,7 +1786,7 @@ lra_split_hard_reg_for (void) insn = lra_insn_recog_data[u]->insn; if (asm_noperands (PATTERN (insn)) >= 0) { - asm_p = true; + lra_asm_error_p = asm_p = true; error_for_asm (insn, "% operand has impossible constraints"); /* Avoid further trouble with this insn. Index: testsuite/ChangeLog =================================================================== --- testsuite/ChangeLog (revision 267108) +++ testsuite/ChangeLog (working copy) @@ -1,3 +1,8 @@ +2018-12-13 Vladimir Makarov + + PR rtl-optimization/88414 + * gcc.target/i386/pr88414.c: New. + 2018-12-13 Marek Polacek PR c++/88216 - ICE with class type in non-type template parameter. Index: testsuite/gcc.target/i386/pr88414.c =================================================================== --- testsuite/gcc.target/i386/pr88414.c (nonexistent) +++ testsuite/gcc.target/i386/pr88414.c (working copy) @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -ftrapv" } */ + +unsigned int +foo (unsigned int *x, const unsigned int *y, int z, unsigned int w) +{ + unsigned int a, b, c, s; + int j; + j = -z; + x -= j; + y -= j; + a = 0; + do + { + asm volatile ("" : "=d" (b), "=d" (c) : "r" (y[j]), "d" (w)); /* { dg-error "'asm' operand has impossible constraints" } */ + c += a; + a = (c < a) + b; + s = x[j]; + c = s + c; + a += (c < s); + x[j] = c; + } + while (++j != 0); + return a; +}