From patchwork Fri May 27 14:12:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kugan Vivekanandarajah X-Patchwork-Id: 68753 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp113221qge; Fri, 27 May 2016 07:12:32 -0700 (PDT) X-Received: by 10.202.234.136 with SMTP id i130mr9662994oih.56.1464358352335; Fri, 27 May 2016 07:12:32 -0700 (PDT) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id r22si8700058otb.2.2016.05.27.07.12.31 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 27 May 2016 07:12:32 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-428454-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org; spf=pass (google.com: domain of gcc-patches-return-428454-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-428454-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org 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:date:message-id:subject:from:to:content-type; q= dns; s=default; b=pK5o9d+81/qQKY76KB8JmNdJKP2JUjjc4YKvrapDLA0FFA hdadEP4m23cFBjvO5SkR/o9B2t6UWvfvqOMAeBxvgOs1dDzIQYPSWd7u41FBvUz2 nvx9Z0gKLu0NsWmn9A9EHSULuvyAC4kB5H/9QVrh9NTlVOeGqGk/oGRAyhZf8= 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:date:message-id:subject:from:to:content-type; s= default; bh=FbRnUoJOta1LnhDw3kLexFv1E78=; b=Ot2F0E5LafiLx+eACFKl tWqV5RJzzovZlhECXcNvSGGoY95jus8WcIUOze9BlOrYX1ybLqqutFFTpcRvbg9z /xQ6Kwx3YG6NdojWoXlpShXYFd4TKel9A/CZJAJMMshpz9jBWtOoTMn0YJ/mMvJN al12ull0ehzjzkY3oHAiq9M= Received: (qmail 113848 invoked by alias); 27 May 2016 14:12:19 -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 113838 invoked by uid 89); 27 May 2016 14:12:18 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-qk0-f170.google.com Received: from mail-qk0-f170.google.com (HELO mail-qk0-f170.google.com) (209.85.220.170) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Fri, 27 May 2016 14:12:08 +0000 Received: by mail-qk0-f170.google.com with SMTP id n63so80227233qkf.0 for ; Fri, 27 May 2016 07:12:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:date:message-id:subject:from:to; bh=+t7oI9mizjfSNFanPVluYtZfqWj6uO0AUmomfDblLuI=; b=hBK1fr7NwYfwILXxt5R4kqa8oGHHtSdTlncaKQ0uj4vndX4xwH0A6xkswVe6jhDcnO 7/7wGWUKMmGbMtpve784jhf1B5vOUuaNBvsYH4HzCtJnpqIcOGCYmXwHEtFE3Izy5KI3 2jdNHUiv1VtNh6jtr4iuZBbY+Tqie3NDFAAb4SvNCJr587OBQSKsjznnrlUhBUPGpqH7 a5tdYIq2DSuRFEUAjNfLz8wwvRs69y2gMas060hhTmxcEhEwKfeQvLDXDTrUB1UNzXco NzdcwMXFntF33AUFjJGtw/NoONCPbhW2yHEwCtPxNzUqNqjaAtM9TFIy2Z4E9iF+6+j3 eMLw== X-Gm-Message-State: ALyK8tJGskuEOA0yH9zyDJ7mqn9N155jy66xodYD1DCVDVLHTrY4tChhr8XDnuoT3xSZ/R91K5SMsCyiXcNcEVCS MIME-Version: 1.0 X-Received: by 10.200.35.148 with SMTP id q20mr3164739qtq.90.1464358326207; Fri, 27 May 2016 07:12:06 -0700 (PDT) Received: by 10.200.42.218 with HTTP; Fri, 27 May 2016 07:12:06 -0700 (PDT) Date: Sat, 28 May 2016 00:12:06 +1000 Message-ID: Subject: [PATCH1][PR71252] Fix missing swap to stmt_to_insert From: Kugan Vivekanandarajah To: "gcc-patches@gcc.gnu.org" , Richard Biener , Jakub Jelinek X-IsSubscribed: yes Hi, This fix the missing swap for stmt-to_insert. I tested this with the attached test case which is not valid any more due to some other commits. This I believe an is obvious fix and maybe the test case is needed. I am running bootstrap and regression testing on x86-64-linux gnu. Is this OK for trunk if the testing is fine ? Thanks, Kugan gcc/ChangeLog: 2016-05-28 Kugan Vivekanandarajah * tree-ssa-reassoc.c (swap_ops_for_binary_stmt): Fix swap such that all fields including stmt_to_insert are swapped. gcc/testsuite/ChangeLog: 2016-05-28 Kugan Vivekanandarajah * gcc.dg/tree-ssa/pr71252-2.c: New test. diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr71252-2.c b/gcc/testsuite/gcc.dg/tree-ssa/pr71252-2.c index e69de29..e621d3e 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/pr71252-2.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr71252-2.c @@ -0,0 +1,9 @@ +/* PR middle-end/71252 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +unsigned a; +int b, c; +void fn1 () +{ + b = a + c + 3 + c; +} diff --git a/gcc/tree-ssa-reassoc.c b/gcc/tree-ssa-reassoc.c index c9ed679..d13be29 100644 --- a/gcc/tree-ssa-reassoc.c +++ b/gcc/tree-ssa-reassoc.c @@ -3763,25 +3763,13 @@ swap_ops_for_binary_stmt (vec ops, || (stmt && is_phi_for_stmt (stmt, oe3->op) && !is_phi_for_stmt (stmt, oe1->op) && !is_phi_for_stmt (stmt, oe2->op))) - { - operand_entry temp = *oe3; - oe3->op = oe1->op; - oe3->rank = oe1->rank; - oe1->op = temp.op; - oe1->rank= temp.rank; - } + std::swap (*oe1, *oe3); else if ((oe1->rank == oe3->rank && oe2->rank != oe3->rank) || (stmt && is_phi_for_stmt (stmt, oe2->op) && !is_phi_for_stmt (stmt, oe1->op) && !is_phi_for_stmt (stmt, oe3->op))) - { - operand_entry temp = *oe2; - oe2->op = oe1->op; - oe2->rank = oe1->rank; - oe1->op = temp.op; - oe1->rank = temp.rank; - } + std::swap (*oe1, *oe3); } /* If definition of RHS1 or RHS2 dominates STMT, return the later of those