From patchwork Wed Apr 11 19:03:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 897394 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-476239-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="M7EAnd/9"; 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 40LvQs4txzz9s1s for ; Thu, 12 Apr 2018 05:35:49 +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:date :from:to:cc:subject:message-id:reply-to:mime-version :content-type; q=dns; s=default; b=qoRRSqxffHttFxe8Q3ixePN8kOgaw RYh14XIc3rIMYs3LYu2w08dMi4xuaUEr0OMflhw7t90/7bBAtibH/3Y+C6dbfmSK v7T+9Uk8nzsDo+mVTf/QtRJ7zoa3LoArBDlKmRrc/qMmxljD0F8qDzdHSAcwdr3a qOTMU0zgG46Pis= 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:date :from:to:cc:subject:message-id:reply-to:mime-version :content-type; s=default; bh=5XdWY5dAA8LT1WkBwW/2NmPPfC0=; b=M7E And/97RLX5LmRbPBPeyBozXAn3KUEw1GElqD+4gZtO99OYZLY/RpH5ZX/NiBH8go ji97851IG2J+r5SJOnBLSO0OaYSeyamzB5xrPxkvNyk8ZsMkQ/rE01o6c+/Ftrsm 3lxdIJPcS6C0kZTHIDLZfl+OziIZQdnmjRrMAdHU= Received: (qmail 127705 invoked by alias); 11 Apr 2018 19:35:32 -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 127652 invoked by uid 89); 11 Apr 2018 19:35:31 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3 autolearn=ham version=3.3.2 spammy=furthermore, thusly, 9337 X-HELO: mx1.redhat.com Received: from mx3-rdu2.redhat.com (HELO mx1.redhat.com) (66.187.233.73) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 11 Apr 2018 19:35:30 +0000 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 565048DC36 for ; Wed, 11 Apr 2018 19:35:25 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.36.118.110]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9F583215CDC6 for ; Wed, 11 Apr 2018 19:35:24 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id w3BJ3hA6023798; Wed, 11 Apr 2018 21:03:44 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id w3BJ3hNO023797; Wed, 11 Apr 2018 21:03:43 +0200 Date: Wed, 11 Apr 2018 21:03:43 +0200 From: Jakub Jelinek To: Richard Biener , Jeff Law Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix copyprop_hardreg_forward_1 (PR rtl-optimization/85342) Message-ID: <20180411190343.GC8577@tucnak> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.9.2 (2017-12-15) X-IsSubscribed: yes Hi! When switching regcprop.c to use validate_* and apply_change_group, I have added code to restore recog_data.operands[i] if they have been replaced after apply_change_group failure. That is bogus though, when apply_change_group fails, recog_data.insn is NULL and rest of recog_data structure is complete garbage; and nothing in copyprop_hardreg_forward_1 seems to use it afterwards anyway, just will call extract_insn on the next insn. Furthermore, the "fixups" were only for the recog_data structure operands itself, nothing else, the instruction itself has been already corrected by cancel_changes. Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2018-04-11 Jakub Jelinek PR rtl-optimization/85342 * regcprop.c (copyprop_hardreg_forward_1): Remove replaced array, use a bool scalar var inside of the loop instead. Don't try to update recog_data.operand after failed apply_change_group. * gcc.target/i386/pr85342.c: New test. Jakub --- gcc/regcprop.c.jj 2018-01-04 00:43:17.996703342 +0100 +++ gcc/regcprop.c 2018-04-11 16:17:29.883575142 +0200 @@ -751,7 +751,6 @@ copyprop_hardreg_forward_1 (basic_block bool is_asm, any_replacements; rtx set; rtx link; - bool replaced[MAX_RECOG_OPERANDS]; bool changed = false; struct kill_set_value_data ksvd; @@ -934,7 +933,7 @@ copyprop_hardreg_forward_1 (basic_block eldest live copy that's in an appropriate register class. */ for (i = 0; i < n_ops; i++) { - replaced[i] = false; + bool replaced = false; /* Don't scan match_operand here, since we've no reg class information to pass down. Any operands that we could @@ -951,26 +950,26 @@ copyprop_hardreg_forward_1 (basic_block if (recog_data.operand_type[i] == OP_IN) { if (op_alt[i].is_address) - replaced[i] + replaced = replace_oldest_value_addr (recog_data.operand_loc[i], alternative_class (op_alt, i), VOIDmode, ADDR_SPACE_GENERIC, insn, vd); else if (REG_P (recog_data.operand[i])) - replaced[i] + replaced = replace_oldest_value_reg (recog_data.operand_loc[i], alternative_class (op_alt, i), insn, vd); else if (MEM_P (recog_data.operand[i])) - replaced[i] = replace_oldest_value_mem (recog_data.operand[i], - insn, vd); + replaced = replace_oldest_value_mem (recog_data.operand[i], + insn, vd); } else if (MEM_P (recog_data.operand[i])) - replaced[i] = replace_oldest_value_mem (recog_data.operand[i], - insn, vd); + replaced = replace_oldest_value_mem (recog_data.operand[i], + insn, vd); /* If we performed any replacement, update match_dups. */ - if (replaced[i]) + if (replaced) { int j; rtx new_rtx; @@ -989,13 +988,6 @@ copyprop_hardreg_forward_1 (basic_block { if (! apply_change_group ()) { - for (i = 0; i < n_ops; i++) - if (replaced[i]) - { - rtx old = *recog_data.operand_loc[i]; - recog_data.operand[i] = old; - } - if (dump_file) fprintf (dump_file, "insn %u: reg replacements not verified\n", --- gcc/testsuite/gcc.target/i386/pr85342.c.jj 2018-04-11 16:25:50.564848408 +0200 +++ gcc/testsuite/gcc.target/i386/pr85342.c 2018-04-11 16:26:05.534856581 +0200 @@ -0,0 +1,29 @@ +/* PR rtl-optimization/85342 */ +/* { dg-do compile { target int128 } } */ +/* { dg-options "-O2 -mavx512vl" } */ + +typedef unsigned char U __attribute__((vector_size (64))); +typedef unsigned int V __attribute__((vector_size (64))); +typedef unsigned __int128 W __attribute__((vector_size (64))); +int i; +V g, h, z, k, l, m; +U j; + +W +bar (W o, W p) +{ + U q; + o |= (W){q[0]} >= o; + o += 1 < o; + j |= (U){} == j; + return i + (W)q + (W)g + (W)h + (W)z + o + (W)j + (W)k + (W)l + (W)m + p; +} + +W +foo (U u) +{ + U q; + W r = bar ((W)(U){0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ~0}, (W)q); + u += (U)bar ((W){~0}, r); + return (W)u; +}