From patchwork Thu May 2 14:04:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 1094240 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-499996-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="yrwRa5iV"; 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 44vxpF48D0z9s4Y for ; Fri, 3 May 2019 00:04:21 +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=xRYF75YVbdtlMVXQ6VPYtvnLtKRCMow98SlCXauJ9f9cznsl3HQhO pAevbISJoKxwNgoiu+6QpIvtI09Yar8iVhbYJ/sNhVdBkDK+8g3Wtd5vU4nttFrl YNatcNyyCDqMV2N3tcVvJO203I0maHiqglfRXKN/4+Sigh1SdC1Upw= 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=D7doIxMd2DXuppNDydKm88zcKP0=; b=yrwRa5iVDzafX/7lhEyX V4X3qxQmdhbXvFfNffTe9Pkym/NO/itGNlPsUOKZJgK0PJ6YQzm1J0RFAzP07pxH 25yzofQbtC+4W+hbqfmGshWa/Jk+3V6BdH4x0kvy9JsDifoBY9N2JBqrcD3Rfd/X 7CHUJ9wNhTN4qOTfPT/3VTI= Received: (qmail 46851 invoked by alias); 2 May 2019 14:04:14 -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 46843 invoked by uid 89); 2 May 2019 14:04:14 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-10.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, KAM_NUMSUBJECT, SPF_PASS autolearn=ham version=3.3.1 spammy=HX-Languages-Length:1503 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; Thu, 02 May 2019 14:04:13 +0000 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 3C49CAD9D for ; Thu, 2 May 2019 14:04:11 +0000 (UTC) Date: Thu, 2 May 2019 16:04:11 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix PR89509 Message-ID: User-Agent: Alpine 2.20 (LSU 67 2015-01-07) MIME-Version: 1.0 The following fixes PR89509. Bootstrapped / tested on x86_64-unknown-linux-gnu, applied. Richard. 2019-05-02 Richard Biener PR tree-optimization/89509 * tree-ssa-structalias.c (compute_dependence_clique): Look at the first subvar when determining whether it is restrict. * gcc.dg/torture/restrict-8.c: New testcase. Index: gcc/tree-ssa-structalias.c =================================================================== --- gcc/tree-ssa-structalias.c (revision 269212) +++ gcc/tree-ssa-structalias.c (working copy) @@ -7572,9 +7572,12 @@ compute_dependence_clique (void) EXECUTE_IF_SET_IN_BITMAP (vi->solution, 0, j, bi) { varinfo_t oi = get_varinfo (j); + if (oi->head != j) + oi = get_varinfo (oi->head); if (oi->is_restrict_var) { - if (restrict_var) + if (restrict_var + && restrict_var != oi) { if (dump_file && (dump_flags & TDF_DETAILS)) { Index: gcc/testsuite/gcc.dg/torture/restrict-8.c =================================================================== --- gcc/testsuite/gcc.dg/torture/restrict-8.c (nonexistent) +++ gcc/testsuite/gcc.dg/torture/restrict-8.c (working copy) @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-* } { "-O0" } { "" } } */ +/* { dg-options "-fdump-tree-fre1" } */ + +struct S { int i; void *p; int j; }; +int +foo (struct S * __restrict p, int *q, int flag) +{ + int *x = &p->j; + if (flag) + x = &p->i; + *q = 1; + *x = 2; + return *q; +} + +/* { dg-final { scan-tree-dump "return 1;" "fre1" } } */