From patchwork Tue Aug 28 08:35:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 962776 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-484551-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="ZQnaqoLe"; 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 4202Bm414wz9rvt for ; Tue, 28 Aug 2018 18:35:27 +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:cc:subject:message-id:mime-version:content-type; q=dns; s=default; b=TuVQDnLF21dBoKs26jtd7XOKFgfGDkrnOtoktX3B0Af81UnDLP fb+YHbq0d///tx/yh96hgyZP7Dm1NxcUpm2/SBDXszwJBcqJBN+d3w/qvhU8at9U vX265kLiq7o9j2inDT9KGiyIzCZcUMUjk6/D8CeyDq3mKrkSBeJzso+mQ= 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:mime-version:content-type; s= default; bh=gAfx/YDMtMZCdo/FyT16zlqz860=; b=ZQnaqoLelH5eP/Vjomt4 64tUrb5DcVOv4/M7Ckb4RWzS+O1Gu89U2Z/pPjF150ylNlbhNZeXaVkupAeazcUh SQX2//ayBAzgEV4AKEQC9JeexPeB03GHdeh8WLNjYEBtBXNy6qMEkOn0TWKcD3Eb 3UttL1/c4Book57zpO9Tuqg= Received: (qmail 5053 invoked by alias); 28 Aug 2018 08:35:18 -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 4954 invoked by uid 89); 28 Aug 2018 08:35:07 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-10.6 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, KAM_NUMSUBJECT, SPF_PASS autolearn=ham version=3.3.2 spammy=bits_per_unit, BITS_PER_UNIT, complete_type_p, COMPLETE_TYPE_P 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, 28 Aug 2018 08:35:05 +0000 Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id A86C0AD83 for ; Tue, 28 Aug 2018 08:35:03 +0000 (UTC) Date: Tue, 28 Aug 2018 10:35:03 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org cc: Michael Matz Subject: [PATCH][1/4] Fix PR87117 Message-ID: User-Agent: Alpine 2.20 (LSU 67 2015-01-07) MIME-Version: 1.0 I believe Micha stumbled over this as well. For stores to string literals we miss VDEFs and loads from STRING_CSTs miss VUSEs. Bootstrap and regtest running on x86_64-unknown-linux-gnu. 2018-08-28 Richard Biener PR tree-optimization/87117 * tree-ssa-sccvn.c (fully_constant_vn_reference_p): Exclude void which is is_gimple_reg_type by checking for COMPLETE_TYPE_P. * gcc.dg/pr87117-1.c: New testcase. Index: gcc/tree-ssa-sccvn.c =================================================================== --- gcc/tree-ssa-sccvn.c (revision 263906) +++ gcc/tree-ssa-sccvn.c (working copy) @@ -1408,6 +1408,7 @@ fully_constant_vn_reference_p (vn_refere /* Simplify reads from constants or constant initializers. */ else if (BITS_PER_UNIT == 8 + && COMPLETE_TYPE_P (ref->type) && is_gimple_reg_type (ref->type) && (!INTEGRAL_TYPE_P (ref->type) || TYPE_PRECISION (ref->type) % BITS_PER_UNIT == 0)) Index: gcc/testsuite/gcc.dg/pr87117-1.c =================================================================== --- gcc/testsuite/gcc.dg/pr87117-1.c (nonexistent) +++ gcc/testsuite/gcc.dg/pr87117-1.c (working copy) @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-inline -fno-tree-dce" } */ + +int a, b, c; +long *d; +void fn1() +{ + for (; 0 < a;) + a++; +} +void fn3() +{ + for (; c; c++) + d[c] = 0; +} +void fn2() +{ + if (b) + fn3(); + fn1(); +}