From patchwork Sun Nov 12 21:16:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 837278 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-466610-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="mabnttbn"; 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 3yZmmy2zGnz9sPs for ; Mon, 13 Nov 2017 08:17:03 +1100 (AEDT) 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=lvwadHb1DAMg7CdCXCZU99ZKyXtlP 9dlbzh4PFjkueZzICYoXkQhkRyp147LcPJmwf6AYEWjApoKUAIDk32kq904FrHEc IChhxYbW8h9hgw+Oo+wxbCMuXavGirdLTdjoa90m61Nd4TMxzGWh8998Z3T/CueO TMYBADCgZeD6dE= 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=HUNTjgoRfUl2xmlmHTqFaZb8cmw=; b=mab nttbn4hnSRHAis5MXobtram7vtxxP6q8FzAsedA877doXfrJE0GvjGDvGjl2HwAP 4pwKsgQbZhrtxVq8aKoclaH8ZendYfi6HB3l1Gl9OgBW1NpsHDoeP0CSs5eF24gT +XVCOURW3yv2Wb7DWcuB1WIw5XczuVbRBDLHELLc= Received: (qmail 127391 invoked by alias); 12 Nov 2017 21:16:54 -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 127378 invoked by uid 89); 12 Nov 2017 21:16:53 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.9 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= 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; Sun, 12 Nov 2017 21:16:52 +0000 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9096EC047B62; Sun, 12 Nov 2017 21:16:51 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-116-247.ams2.redhat.com [10.36.116.247]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 14EA35E26E; Sun, 12 Nov 2017 21:16:50 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id vACLGllG029679; Sun, 12 Nov 2017 22:16:48 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id vACLGjPB029678; Sun, 12 Nov 2017 22:16:45 +0100 Date: Sun, 12 Nov 2017 22:16:45 +0100 From: Jakub Jelinek To: Richard Biener Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix store-merging of cst followed by load (PR tree-optimization/82954) Message-ID: <20171112211645.GX14653@tucnak> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.7.1 (2016-10-04) X-IsSubscribed: yes Hi! The conditions split groups if some operand is loaded in first stmt and the second load is incompatible with it, or if it is loaded and second stmt has constant in there instead of load. But as this testcase shows, I didn't handle properly the case when some operand is a constant first and in second stmt changes into a load. We need to split group between those too. Bootstrapped/regtested on {x86_64,i686,powerpc64{,le}}-linux, ok for trunk? 2017-11-12 Jakub Jelinek PR tree-optimization/82954 * gimple-ssa-store-merging.c (imm_store_chain_info::coalesce_immediate_stores): If !infof->ops[N].base_addr, split group if info->ops[N].base_addr. * gcc.c-torture/execute/pr82954.c: New test. Jakub --- gcc/gimple-ssa-store-merging.c.jj 2017-11-10 15:42:39.000000000 +0100 +++ gcc/gimple-ssa-store-merging.c 2017-11-12 15:18:16.614785829 +0100 @@ -1198,10 +1198,12 @@ imm_store_chain_info::coalesce_immediate std::swap (info->ops[0], info->ops[1]); info->ops_swapped_p = true; } - if ((!infof->ops[0].base_addr - || compatible_load_p (merged_store, info, base_addr, 0)) - && (!infof->ops[1].base_addr - || compatible_load_p (merged_store, info, base_addr, 1))) + if ((infof->ops[0].base_addr + ? compatible_load_p (merged_store, info, base_addr, 0) + : !info->ops[0].base_addr) + && (infof->ops[1].base_addr + ? compatible_load_p (merged_store, info, base_addr, 1) + : !info->ops[1].base_addr)) { merged_store->merge_into (info); continue; --- gcc/testsuite/gcc.c-torture/execute/pr82954.c.jj 2017-11-12 15:27:44.478188823 +0100 +++ gcc/testsuite/gcc.c-torture/execute/pr82954.c 2017-11-12 15:27:27.000000000 +0100 @@ -0,0 +1,22 @@ +/* PR tree-optimization/82954 */ + +__attribute__((noipa)) void +foo (int *__restrict p, int *__restrict q) +{ + p[0] = p[0] ^ 1; + p[1] = p[1] ^ 2; + p[2] = p[2] ^ q[2]; + p[3] = p[3] ^ q[3]; +} + +int +main () +{ + int p[4] = { 16, 32, 64, 128 }; + int q[4] = { 8, 4, 2, 1 }; + asm volatile ("" : : "g" (p), "g" (q) : "memory"); + foo (p, q); + if (p[0] != 17 || p[1] != 34 || p[2] != 66 || p[3] != 129) + __builtin_abort (); + return 0; +}