From patchwork Tue Apr 11 07:34:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 749372 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 3w2Jhp48tHz9s7n for ; Tue, 11 Apr 2017 17:34:18 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="RyIDJ/p9"; dkim-atps=neutral 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:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; q=dns; s=default; b=H3nHTDZjFGydd65 XUEdE0ykQWWNLosrC2Oa7L3W0gDib0SUITxHJG72Ia0GFOSGQswmTT7CjX+jh//j 7a6doqN7C6q/Km+GjUEMLGu7PD1BOC2JH6ZdL/hLsF71gqL3SrlTGUR+Mb+K8rqa ZnAFZt5SjLWzHWhxVPffCQTJfceo= 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:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; s=default; bh=0SfonEZVK+1J5jMnEr8vy FRHkpY=; b=RyIDJ/p9t5mYTLtE4TRLZLPIuV3ddism3J4jyg8nrlpXcBKnE0Mr+ cx2B/2CLBuqkUayd4AYT0HBizS/sVzceNMfLnqef6LHzLr23esdaucVELjLEdhc2 /EM/0r+LdGPwNE3X6mZlQdNOACUca1v0r3ToAn7zKW21ihP+dqBRhc= Received: (qmail 46644 invoked by alias); 11 Apr 2017 07:34:08 -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 45671 invoked by uid 89); 11 Apr 2017 07:34:08 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.6 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-oi0-f54.google.com Received: from mail-oi0-f54.google.com (HELO mail-oi0-f54.google.com) (209.85.218.54) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 11 Apr 2017 07:34:06 +0000 Received: by mail-oi0-f54.google.com with SMTP id f22so44164672oib.2 for ; Tue, 11 Apr 2017 00:34:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=2Fexe6U19gUKBSF5zbv5wlOb+cCqYVOI8/j39tQPpfs=; b=NZSn2Jqva3ILs0436paq+u+Ys8mnJprHkugVABngFP+qtxuL+icilSsU49LXh1r41i cZIiRiiy/CnBjS/Ep2cdfgVtjvQJFnIrhr9xACCdpHnGh6fPknTEzzjUndW5T52cPS4D zUVHEjbqTdpWz2nZERQajf5/+hKrnt9ZgfPuupjc9kT0F4+u7ZBqZVXxdhn530tcfG7d FFVrLaxFNjX2d1HwQlGoHMqcBsVoo2RuIdGokFm94q86JQypM60cAs/F6WLr9Lzk7Pqk dL6B8jKfXoq1kwuudoLI3N2CoJhHecxpusJYPr2+9QPUPOnRtdQrHEvxHuAL0rtk8HVN Q+EA== X-Gm-Message-State: AFeK/H3G9S6qtTns1nZpzwI3H7xTryxQ5x3188Z5WR5HssxDsrwBIAkhLFoBMfy6G0JAmnDPjHXlgKyYgFey3A== X-Received: by 10.157.82.171 with SMTP id f43mr18433800oth.27.1491896046197; Tue, 11 Apr 2017 00:34:06 -0700 (PDT) MIME-Version: 1.0 Received: by 10.157.16.11 with HTTP; Tue, 11 Apr 2017 00:34:05 -0700 (PDT) In-Reply-To: <748896a2-9273-b008-f840-815a4e59f3f7@redhat.com> References: <748896a2-9273-b008-f840-815a4e59f3f7@redhat.com> From: Richard Biener Date: Tue, 11 Apr 2017 09:34:05 +0200 Message-ID: Subject: Re: [P1] [PATCH] [PR tree-optimization/80374] Do not try to convert integer_zero_node to undesirable types To: Jeff Law Cc: gcc-patches X-IsSubscribed: yes On Mon, Apr 10, 2017 at 9:20 PM, Jeff Law wrote: > > fold_convert can fail for certain types. It can fail either by returning a > error_mark_node or triggering a gcc_assert depending on the exact situation. > > Both are problematical. This patch checks that we can convert > integer_zero_node to the proper type before calling fold_convert. > > Bootstrapped and regression tested on x86_64. Installing on the trunk. I am testing the proper fix below (NULLPTR_TYPE is somewhat special...) Richard. > Jeff > > diff --git a/gcc/ChangeLog b/gcc/ChangeLog > index 6edad21..7db5359 100644 > --- a/gcc/ChangeLog > +++ b/gcc/ChangeLog > @@ -1,3 +1,10 @@ > +2017-04-10 Jeff Law > + > + PR tree-optimization/80374 > + * tree-ssa-dom.c (derive_equivalences_from_bit_ior): Do not try to > + record anything if we can not convert integer_zero_node to the > + desired type. > + > 2017-04-10 Bin Cheng > > PR tree-optimization/80153 > diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog > index b87d0ee..6ed3c99 100644 > --- a/gcc/testsuite/ChangeLog > +++ b/gcc/testsuite/ChangeLog > @@ -1,3 +1,8 @@ > +2017-04-10 Jeff Law > + > + PR tree-optimization/80374 > + * g++.dg/pr80374.c: New test. > + > 2017-04-10 Daniel Santos > > PR testsuite/79867 > diff --git a/gcc/testsuite/g++.dg/pr80374.C b/gcc/testsuite/g++.dg/pr80374.C > new file mode 100644 > index 0000000..b02b656 > --- /dev/null > +++ b/gcc/testsuite/g++.dg/pr80374.C > @@ -0,0 +1,19 @@ > +void a (const char *, const char *, int, const char *) > + __attribute__ ((__noreturn__)); > +template > +void > +c () try > + { > + throw; > + } > +catch (b d) > + { > + if (d) > + a ("", "", 2, __PRETTY_FUNCTION__); > + } > +main () > +{ > + using e = decltype (nullptr); > + c (); > +} > + > diff --git a/gcc/tree-ssa-dom.c b/gcc/tree-ssa-dom.c > index d2263bb..d9e5942 100644 > --- a/gcc/tree-ssa-dom.c > +++ b/gcc/tree-ssa-dom.c > @@ -701,7 +701,8 @@ derive_equivalences_from_bit_ior (tree name, > const_and_copies *const_and_copies, > int recursion_limit) > { > - if (recursion_limit == 0) > + if (recursion_limit == 0 > + || !fold_convertible_p (TREE_TYPE (name), integer_zero_node)) > return; > > if (TREE_CODE (name) == SSA_NAME) > Index: gcc/tree-ssa-dom.c =================================================================== --- gcc/tree-ssa-dom.c (revision 246832) +++ gcc/tree-ssa-dom.c (working copy) @@ -701,13 +701,12 @@ derive_equivalences_from_bit_ior (tree n const_and_copies *const_and_copies, int recursion_limit) { - if (recursion_limit == 0 - || !fold_convertible_p (TREE_TYPE (name), integer_zero_node)) + if (recursion_limit == 0) return; if (TREE_CODE (name) == SSA_NAME) { - tree value = fold_convert (TREE_TYPE (name), integer_zero_node); + tree value = build_zero_cst (TREE_TYPE (name)); /* This records the equivalence for the toplevel object. */ record_equality (name, value, const_and_copies);