From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 97803 invoked by alias); 25 Feb 2015 13:26:42 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 97788 invoked by uid 89); 25 Feb 2015 13:26:42 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.2 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx2.suse.de Received: from cantor2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Wed, 25 Feb 2015 13:26:41 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 8D47DABEE for ; Wed, 25 Feb 2015 13:26:38 +0000 (UTC) Date: Wed, 25 Feb 2015 13:36:00 -0000 From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix PR65204 Message-ID: User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-SW-Source: 2015-02/txt/msg01487.txt.bz2 This fixes missed tracking of alignment of non-invariant addresses in CCP. Bootstrapped and tested on x86_64-unknown-linux-gnu, queued for GCC 6. Richard. 2015-02-25 Richard Biener PR tree-optimization/65204 * tree-ssa-ccp.c (evaluate_stmt): Always evaluate address takens for bit-CCP. * gcc.dg/tree-ssa/ssa-ccp-35.c: New testcase. Index: gcc/tree-ssa-ccp.c =================================================================== --- gcc/tree-ssa-ccp.c (revision 220958) +++ gcc/tree-ssa-ccp.c (working copy) @@ -1748,7 +1769,9 @@ evaluate_stmt (gimple stmt) /* Resort to simplification for bitwise tracking. */ if (flag_tree_bit_ccp - && (likelyvalue == CONSTANT || is_gimple_call (stmt)) + && (likelyvalue == CONSTANT || is_gimple_call (stmt) + || (gimple_assign_single_p (stmt) + && gimple_assign_rhs_code (stmt) == ADDR_EXPR)) && !is_constant) { enum gimple_code code = gimple_code (stmt); Index: gcc/testsuite/gcc.dg/tree-ssa/ssa-ccp-35.c =================================================================== --- gcc/testsuite/gcc.dg/tree-ssa/ssa-ccp-35.c (revision 0) +++ gcc/testsuite/gcc.dg/tree-ssa/ssa-ccp-35.c (working copy) @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-ccp1" } */ + +typedef char char16[16] __attribute__ ((aligned (16))); +char16 c16[4] __attribute__ ((aligned (4))); + +int f5 (int i) +{ + __SIZE_TYPE__ s = (__SIZE_TYPE__)&c16[i]; + /* 0 */ + return 3 & s; +} + +/* { dg-final { scan-tree-dump "return 0;" "ccp1" } } */ +/* { dg-final { cleanup-tree-dump "ccp1" } } */