From patchwork Tue Sep 12 13:47:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 812854 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-461921-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="MUo2VKy+"; 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 3xs5hf4ZrVz9s5L for ; Tue, 12 Sep 2017 23:47:46 +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:subject:message-id:mime-version:content-type; q=dns; s= default; b=qXhGaNnaNC+CzMNjMm63jBfGai8gXfKvuB96BpOKK3jWVgHWz+e9B l2ZwePWOFqI3U+cM0h6DDciITULbWAtydaAwDGE4k2XOWCO47jo/jp/KFsQZ7Ujl IFnTkx1WUHNK9zEfI7mnwzlRYiRorsnX+yMwCf1sdDwMMFp61ZpzoA= 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=i49v8CpI4FWXVvjsXGYtc693m0k=; b=MUo2VKy+IPWpE1o0x9Bp rBLbAGd8fBgt7cWKSAKIWznB5Qiaxy+xQ1DmxeGSwTeGHY3FDBLb9DLDU6jKxU0V Kn/YcE/OM7igX7JXAmVu2zNHOEPFuTbz0Wgt6eBAKolbHVBflQQRCeAQDcQtLVz4 Q9VwnlhtII/p0EuWhHtqF3c= Received: (qmail 33501 invoked by alias); 12 Sep 2017 13:47:40 -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 33483 invoked by uid 89); 12 Sep 2017 13:47:39 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.1 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:1557 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; Tue, 12 Sep 2017 13:47:38 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 333E8AB43 for ; Tue, 12 Sep 2017 13:47:36 +0000 (UTC) Date: Tue, 12 Sep 2017 15:47:36 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix PR82157 Message-ID: User-Agent: Alpine 2.20 (LSU 67 2015-01-07) MIME-Version: 1.0 The following fixes a latent issue in fold_stmt uncovered by PRE re-org. We muck with the gsi in inapprorpate ways. Bootstrapped on x86_64-unknown-linux-gnu, testing in progress. Richard. 2017-09-12 Richard Biener PR tree-optimization/82157 * tree-ssa-pre.c (remove_dead_inserted_code): Do not remove stmts with side-effects. * gcc.dg/torture/pr82157.c: New testcase. Index: gcc/tree-ssa-pre.c =================================================================== --- gcc/tree-ssa-pre.c (revision 252002) +++ gcc/tree-ssa-pre.c (working copy) @@ -4913,6 +4964,8 @@ remove_dead_inserted_code (void) continue; gimple *t = SSA_NAME_DEF_STMT (def); + if (gimple_has_side_effects (t)) + continue; /* Add uses to the worklist. */ ssa_op_iter iter; Index: gcc/testsuite/gcc.dg/torture/pr82157.c =================================================================== --- gcc/testsuite/gcc.dg/torture/pr82157.c (nonexistent) +++ gcc/testsuite/gcc.dg/torture/pr82157.c (working copy) @@ -0,0 +1,43 @@ +/* { dg-do compile } */ + +int a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z; + +int aa () +{ + w = f < 0 || e >> f; + while (z) + h = i && (r && p) | ((l = p) == c % d); + k = v + 1 < a; + t = -(j < 1) * q; + return u; +} + +int ab () +{ + for (j = 0; 1; j = 5) + if (!s) + return d; +} + +void ac () +{ + char ad = aa (); + ab (); + if (x) + { + for (m = 0; m < 3; m = a) + { + y = a && b; + if (g) + break; + } + n = j; + } + o = j & ad; +} + +int main () +{ + ac (); + return 0; +}