From patchwork Mon Dec 12 19:20:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 705137 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 3tct425jWpz9t0v for ; Tue, 13 Dec 2016 06:21:22 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="JbO7Ei6+"; 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:date :from:to:cc:subject:message-id:reply-to:mime-version :content-type; q=dns; s=default; b=Qekz34DkR0F5xZ74wHhLRaAg59qSD KoomZp+C/RiB2DKn/OzNNXewt+ftEhK9BomTnlC/6vAE4TfcwKd09UT3k27N/BPA n7Qd79gJnyvqEl3fIhoyG+Etks4MYJzk82JBCMajfqpDa0yo9kOA7DvjC9i0Ehde 0Yx8ypHl4aN9eA= 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=bWJ+6PBILoFm7vM3hb90AI7P1mk=; b=JbO 7Ei6+Vj28aAib960XCiQO+WSkHeZY9wSC1fedP9otcFvDe75x6hNJOUVFVFBacuL 9q9g1sAnmcCRatmwQkujsBtf5GICEfiugDgwl1WRQcjddIRXnP57qFaDd71AyYz8 CIX6idAggI+ToNwKx1ZkIrK+BcQ4BnujphxHBTjQ= Received: (qmail 109968 invoked by alias); 12 Dec 2016 19:21:04 -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 109937 invoked by uid 89); 12 Dec 2016 19:21:03 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-5.0 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=39.000000000, 39000000000, statements 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; Mon, 12 Dec 2016 19:21:02 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 17A3B4E34E; Mon, 12 Dec 2016 19:21:01 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-204-100.brq.redhat.com [10.40.204.100]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id uBCJKxgT004345 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 12 Dec 2016 14:21:00 -0500 Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id uBCJKwI4014884; Mon, 12 Dec 2016 20:20:58 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id uBCJKvC7014883; Mon, 12 Dec 2016 20:20:57 +0100 Date: Mon, 12 Dec 2016 20:20:57 +0100 From: Jakub Jelinek To: Richard Biener Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix gimple slsr throwing call handling (PR tree-optimization/78777) Message-ID: <20161212192049.GF3541@tucnak.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) X-IsSubscribed: yes Hi! The strength reduction has code to emit stuff before or after the last insn in a bb, but uses a wrong predicate to decide where to put it, is_ctrl_stmt covers only a subset of statements that must end a bb. Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2016-12-12 Jakub Jelinek PR tree-optimization/78777 * gimple-ssa-strength-reduction.c (create_add_on_incoming_edge, insert_initializers): Use stmt_ends_bb_p instead of is_ctrl_stmt. * g++.dg/torture/pr78777.C: New test. Jakub --- gcc/gimple-ssa-strength-reduction.c.jj 2016-12-06 10:16:39.000000000 +0100 +++ gcc/gimple-ssa-strength-reduction.c 2016-12-12 16:50:24.729489536 +0100 @@ -2253,7 +2253,7 @@ create_add_on_incoming_edge (slsr_cand_t insert_bb = single_succ_p (e->src) ? e->src : split_edge (e); gsi = gsi_last_bb (insert_bb); - if (!gsi_end_p (gsi) && is_ctrl_stmt (gsi_stmt (gsi))) + if (!gsi_end_p (gsi) && stmt_ends_bb_p (gsi_stmt (gsi))) { gsi_insert_before (&gsi, new_stmt, GSI_SAME_STMT); if (cast_stmt) @@ -3243,7 +3243,7 @@ insert_initializers (slsr_cand_t c) gimple *basis_stmt = lookup_cand (c->basis)->cand_stmt; location_t loc = gimple_location (basis_stmt); - if (!gsi_end_p (gsi) && is_ctrl_stmt (gsi_stmt (gsi))) + if (!gsi_end_p (gsi) && stmt_ends_bb_p (gsi_stmt (gsi))) { if (cast_stmt) { --- gcc/testsuite/g++.dg/torture/pr78777.C.jj 2016-12-12 17:21:00.864314692 +0100 +++ gcc/testsuite/g++.dg/torture/pr78777.C 2016-12-12 17:20:35.000000000 +0100 @@ -0,0 +1,29 @@ +// PR tree-optimization/78777 + +void bar (char); +struct C { char b; }; +struct H { char d[5]; int e; C *f[4]; int g[10]; }; +void baz (C *, unsigned char *, int); +unsigned char j[10]; + +void +foo (H *o, int p, unsigned char *q, int r, char n, H *b) +{ + for (int m = 0; m < o->e; m++) + { + if (o->f[m] || o->g[m]) + continue; + try + { + baz (o->f[m], j, 5); + if (p) + baz (o->f[m], q, r); + } + catch (int) + { + C a = *o->f[m]; + if (b) + bar (n & a.b); + } + } +}