From patchwork Mon Dec 3 15:12:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 1006976 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-491506-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="W6xCpkq+"; 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 437pPx3dJ4z9s47 for ; Tue, 4 Dec 2018 02:12:20 +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:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=snIhBKUVm+TP1NZaCU1fpjllVDZ/uExVWokIEEw2fc77hioEg/5jW zKoipmqK3Bv7ApsP3PdZBTX9lxVNZJ/0XMFvakL9FS12qTUK6j++wX52lGTOhkq7 WpS0xxGzc1R2/rijeTvrmzbfRRB4LzTLyCD+1tXjrceXJO8sMbX5aI= 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:subject:message-id:mime-version:content-type; s= default; bh=cmmWuujoVG08R05sf55t8IU04Z4=; b=W6xCpkq+uaY3wXphs7h0 7+LIiFH6aY2naAxmrKfjjn1KLmuq41Ecoiz+id2YqAQOFedAljlMMW56E1jttcC1 pUzzvzNfkDsxEea49IC7we3Pb1squFdX8Hri5c8Dd8PrrrNwtqsN1l0RFqQ0Qd9E HnyRG1m5ZyblLpJryfqf7Ss= Received: (qmail 41439 invoked by alias); 3 Dec 2018 15:12:13 -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 41422 invoked by uid 89); 3 Dec 2018 15:12:11 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.9 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.2 spammy=fre, restricts, Hx-languages-length:1747, FRE X-HELO: mx1.suse.de Received: from mx2.suse.de (HELO mx1.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 03 Dec 2018 15:12:06 +0000 Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 2F296ADDF for ; Mon, 3 Dec 2018 15:12:04 +0000 (UTC) Date: Mon, 3 Dec 2018 16:12:04 +0100 (CET) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] Tighten PRE/FRE elimination Message-ID: User-Agent: Alpine 2.20 (LSU 67 2015-01-07) MIME-Version: 1.0 It happily inserted int->float casts if sth goes wrong in VN or elimination. The following restricts it to the expected re-instantiation of function pointer casts. Bootstrapped and tested on x86_64-unknown-linux-gnu, applied. Richard. 2018-12-03 Richard Biener * tree-ssa-sccvn.c (eliminate_dom_walker::eliminate_stmt): Only allow expected function-pointer cast re-instantiation. Index: gcc/tree-ssa-sccvn.c =================================================================== --- gcc/tree-ssa-sccvn.c (revision 266733) +++ gcc/tree-ssa-sccvn.c (working copy) @@ -4984,10 +4984,6 @@ eliminate_dom_walker::eliminate_stmt (ba return; /* Else replace its RHS. */ - bool can_make_abnormal_goto - = is_gimple_call (stmt) - && stmt_can_make_abnormal_goto (stmt); - if (dump_file && (dump_flags & TDF_DETAILS)) { fprintf (dump_file, "Replaced "); @@ -4997,12 +4993,23 @@ eliminate_dom_walker::eliminate_stmt (ba fprintf (dump_file, " in "); print_gimple_stmt (dump_file, stmt, 0); } - eliminations++; + + bool can_make_abnormal_goto = (is_gimple_call (stmt) + && stmt_can_make_abnormal_goto (stmt)); gimple *orig_stmt = stmt; if (!useless_type_conversion_p (TREE_TYPE (lhs), TREE_TYPE (sprime))) - sprime = fold_convert (TREE_TYPE (lhs), sprime); + { + /* We preserve conversions to but not from function or method + types. This asymmetry makes it necessary to re-instantiate + conversions here. */ + if (POINTER_TYPE_P (TREE_TYPE (lhs)) + && FUNC_OR_METHOD_TYPE_P (TREE_TYPE (TREE_TYPE (lhs)))) + sprime = fold_convert (TREE_TYPE (lhs), sprime); + else + gcc_unreachable (); + } tree vdef = gimple_vdef (stmt); tree vuse = gimple_vuse (stmt); propagate_tree_value_into_stmt (gsi, sprime);