From patchwork Fri Aug 7 10:21:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 1342199 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=suse.de Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BNLxW2Kttz9sTF for ; Fri, 7 Aug 2020 20:21:34 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AE9F8385ED4D; Fri, 7 Aug 2020 10:21:30 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by sourceware.org (Postfix) with ESMTPS id 6BDE03858D35 for ; Fri, 7 Aug 2020 10:21:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 6BDE03858D35 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=rguenther@suse.de X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 223E6B6A6 for ; Fri, 7 Aug 2020 10:21:45 +0000 (UTC) Date: Fri, 7 Aug 2020 12:21:27 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] tree-optimization/96514 - avoid if-converting control-altering calls Message-ID: User-Agent: Alpine 2.21 (LSU 202 2017-01-01) MIME-Version: 1.0 X-Spam-Status: No, score=-10.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" This avoids if-converting when encountering control-altering calls. Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. 2020-08-07 Richard Biener PR tree-optimization/96514 * tree-if-conv.c (if_convertible_bb_p): If the last stmt is a call that is control-altering, fail. * gcc.dg/pr96514.c: New testcase. --- gcc/testsuite/gcc.dg/pr96514.c | 27 +++++++++++++++++++++++++++ gcc/tree-if-conv.c | 5 +++++ 2 files changed, 32 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/pr96514.c diff --git a/gcc/testsuite/gcc.dg/pr96514.c b/gcc/testsuite/gcc.dg/pr96514.c new file mode 100644 index 00000000000..891b4da2b1e --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr96514.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ + +int __attribute__ ((pure, returns_twice)) +r0 (void); + +void +vy (int t7) +{ + while (t7 == 0) + r0 (); +} + +void +qw (int t7) +{ + vy (t7); + + if (0) + r0 (); +} + +void __attribute__ ((simd)) +un (int t7) +{ + qw (t7); + qw (t7); +} diff --git a/gcc/tree-if-conv.c b/gcc/tree-if-conv.c index fc894eb94da..257759d01bf 100644 --- a/gcc/tree-if-conv.c +++ b/gcc/tree-if-conv.c @@ -1139,6 +1139,11 @@ if_convertible_bb_p (class loop *loop, basic_block bb, basic_block exit_bb) if (EDGE_COUNT (bb->succs) > 2) return false; + gimple *last = last_stmt (bb); + if (gcall *call = safe_dyn_cast (last)) + if (gimple_call_ctrl_altering_p (call)) + return false; + if (exit_bb) { if (bb != loop->latch)