From patchwork Fri Jun 30 20:40:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Pinski X-Patchwork-Id: 782993 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 3wzpLl3gprz9s3s for ; Sat, 1 Jul 2017 06:40:14 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="gxJudzTA"; 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=DTqBILkJqYSjiNo pQFhMBdQW4WsF8BJXLrw4wopfeWbT1tb/d/EydDuaTevsdWbtM+UQGi4lKy+8OVP jnmR9E9CgTahKS22+uHynZtshVbYg3aCdYI1mJZH9AtoumMGf9IyHjMWI2zJXOMx 3Pt6271iBsM7n/a7Lv1FtUwHm4LI= 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=jYHkKTjJxfG8VfVUTM4Lz v6+ihk=; b=gxJudzTAan4wok4KCtbS3jDUGW1h/M3uE5ZxXSgXRjmm+p9TwkLTD ecI0oWOobje5jXcmQhZPtaT3twiX0DIXgJ0P0RH+UEKhEo2uY3kzu6IG+82OJlzb oPPQPLLIKUd6Y4Tq05DzEgbzADvBBaGI07iX+w9JoVWUbfqaTBTjJ4= Received: (qmail 40460 invoked by alias); 30 Jun 2017 20:40:06 -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 40443 invoked by uid 89); 30 Jun 2017 20:40:05 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.0 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:2257 X-HELO: mail-yb0-f170.google.com Received: from mail-yb0-f170.google.com (HELO mail-yb0-f170.google.com) (209.85.213.170) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 30 Jun 2017 20:40:03 +0000 Received: by mail-yb0-f170.google.com with SMTP id 84so41709209ybe.0 for ; Fri, 30 Jun 2017 13:40:03 -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=GtC9F8YO/+9auPUD7FqxdBZJ1042tu1Ble+4A/IO4ho=; b=XdBgH02jS6+9/qz+cbe5C2C5vAGtLgWUeCdf2z3E6SFh/LGhv/nk2qbYUXy5O1Lfdn +6hL4OTIYbFq/OzYgTwaTuabw06Q2YWdeUGZIqc9V18ExOKZe2YVkxqCJyAf5HcXSZhd mLV2og+hxN7OrWEBR3C3YCvb//rUCbN8jem3Oc4AAaTAKQa3W6Qtad8091Ymmk4voaut F3N8wB3fWuuuF7Aj2C7Cr1eHDOr4R+94Sd2xFWvM3v/zRyWPAaPBrensCU5oH5XR1POw 1b4VoGAe8X4yK4SBlu0qJq6xNjQjIZK/J6RCFBwKjFSDhUnpxUVDesR+6cn0p430jMXF Wcgg== X-Gm-Message-State: AKS2vOwUddMVg580xQXpPzsuvaMXGOuhXsaHubwy99D0g+061t/a+UHI pykN/BB+G9JGl2UnY173Svz/cSXUNA== X-Received: by 10.37.176.140 with SMTP id f12mr17844337ybj.231.1498855202213; Fri, 30 Jun 2017 13:40:02 -0700 (PDT) MIME-Version: 1.0 Received: by 10.129.47.200 with HTTP; Fri, 30 Jun 2017 13:40:01 -0700 (PDT) In-Reply-To: References: From: Andrew Pinski Date: Fri, 30 Jun 2017 13:40:01 -0700 Message-ID: Subject: Re: [PATCH] [PR 81245] Fix tree-if-conv calling of update_stmt after fold_stmt To: Richard Biener Cc: GCC Patches X-IsSubscribed: yes On Fri, Jun 30, 2017 at 1:20 AM, Richard Biener wrote: > On Thu, Jun 29, 2017 at 10:12 PM, Andrew Pinski wrote: >> Hi, >> As described in the bug, tree-if-conv is calling update_stmt on an >> old stmt which might have been removed from the IR already >> (transforming of an assignment to a call in this case). This fixes >> the problem by calling update_stmt on the new statement that fold_stmt >> might have created. >> >> OK? Bootstrapped and tested on aarch64-linux-gnu with no regressions. > > update_stmt is not necessary when fold_stmt doesn't return true as > gsi_insert_before already updates the stmt. > > Thus ok with moving update_stmt under the conditional. This is what I applied. Thanks, Andrew > > Thanks, > Richard. > >> Thanks, >> Andrew Pinski >> ChangeLog: >> * tree-if-conv.c (predicate_scalar_phi): Update new_stmt if fold_stmt >> returned true. >> >> testsuite/ChangeLog: >> * gcc.dg/torture/pr81245.c: New testcase. Index: testsuite/gcc.dg/torture/pr81245.c =================================================================== --- testsuite/gcc.dg/torture/pr81245.c (nonexistent) +++ testsuite/gcc.dg/torture/pr81245.c (working copy) @@ -0,0 +1,16 @@ +/* { dg-options "-ffast-math" } */ +/* { dg-do compile } */ +/* This test used to crash the vectorizer as the ifconvert pass + used to convert the if to copysign but called update_stmt on + the old statement after calling fold_stmt. */ +double sg[18]; +void f(void) +{ + for (int i = 0 ;i < 18;i++) + { + if (sg[i] < 0.0) + sg[i] = -1.0; + else + sg[i] = 1.0; + } +} Index: tree-if-conv.c =================================================================== --- tree-if-conv.c (revision 249844) +++ tree-if-conv.c (working copy) @@ -1853,8 +1853,11 @@ new_stmt = gimple_build_assign (res, rhs); gsi_insert_before (gsi, new_stmt, GSI_SAME_STMT); gimple_stmt_iterator new_gsi = gsi_for_stmt (new_stmt); - fold_stmt (&new_gsi, ifcvt_follow_ssa_use_edges); - update_stmt (new_stmt); + if (fold_stmt (&new_gsi, ifcvt_follow_ssa_use_edges)) + { + new_stmt = gsi_stmt (new_gsi); + update_stmt (new_stmt); + } if (dump_file && (dump_flags & TDF_DETAILS)) {