From patchwork Mon Jun 18 04:05:45 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Schmidt X-Patchwork-Id: 165383 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id B4A24B72B9 for ; Mon, 18 Jun 2012 14:06:20 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1340597181; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Received:Received:Message-ID:Subject:From:To: Cc:Date:Content-Type:Content-Transfer-Encoding:Mime-Version: Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:Sender:Delivered-To; bh=MHO25qjgAKHvuRVA8D55 GCKhivM=; b=heoR41ExKbuAjAT/Rq+u/qmW4GjjbsTZt3iQ4M5SFzW7fSTgF76e 0vysjzBZk+WGiMyuOM77Mq0Kwflki/BlGwrMuei5CppipRNyf3WXkdq4RfEAXA6e S/BKfXFfJH1mYKJ2ClUlDX0opGb8XebCiVs8L82I3ZgblETmd79nFnY= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Received:Received:Received:Received:Message-ID:Subject:From:To:Cc:Date:Content-Type:Content-Transfer-Encoding:Mime-Version:X-Content-Scanned:x-cbid:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=gjJod0gHjOwEpBTJ98eMzW15aqU+2/p2cFVE/QNWnvr9txIxV1aEmk0qaxd5KL /0gd17l+BzBV6Y2MQD4T8qAD/dLxcBSnKqaDjE584EPhBTmmH9GaG2EQt/ogMrwu 8NaykO0D+mCxNSzjmg5pXcxBsJLdh0unHLnsLu0do5xDo=; Received: (qmail 4596 invoked by alias); 18 Jun 2012 04:06:12 -0000 Received: (qmail 4574 invoked by uid 22791); 18 Jun 2012 04:06:10 -0000 X-SWARE-Spam-Status: No, hits=-5.0 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, TW_NL, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from e38.co.us.ibm.com (HELO e38.co.us.ibm.com) (32.97.110.159) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 18 Jun 2012 04:05:56 +0000 Received: from /spool/local by e38.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Sun, 17 Jun 2012 22:05:51 -0600 Received: from d03dlp02.boulder.ibm.com (9.17.202.178) by e38.co.us.ibm.com (192.168.1.138) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Sun, 17 Jun 2012 22:05:46 -0600 Received: from d03relay01.boulder.ibm.com (d03relay01.boulder.ibm.com [9.17.195.226]) by d03dlp02.boulder.ibm.com (Postfix) with ESMTP id 150DE3E4005B for ; Mon, 18 Jun 2012 04:05:45 +0000 (WET) Received: from d03av02.boulder.ibm.com (d03av02.boulder.ibm.com [9.17.195.168]) by d03relay01.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q5I45ijR188138 for ; Sun, 17 Jun 2012 22:05:44 -0600 Received: from d03av02.boulder.ibm.com (loopback [127.0.0.1]) by d03av02.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q5I45i6W003873 for ; Sun, 17 Jun 2012 22:05:44 -0600 Received: from [9.65.142.169] (sig-9-65-142-169.mts.ibm.com [9.65.142.169]) by d03av02.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id q5I45hPM003802; Sun, 17 Jun 2012 22:05:43 -0600 Message-ID: <1339992345.18291.33.camel@gnopaine> Subject: [PATCH] Fix PR53703 From: "William J. Schmidt" To: gcc-patches@gcc.gnu.org Cc: rguenther@suse.de, bergner@vnet.ibm.com Date: Sun, 17 Jun 2012 23:05:45 -0500 Mime-Version: 1.0 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 12061804-5518-0000-0000-0000053FABEF 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 The test case exposes a bug that occurs only when a diamond control flow pattern has the arguments of the joining phi in a different order from the successor arcs of the entry block. My logic for setting bb_for_def[12] was just brain-dead. This cleans that up and also prevents wasting time examining phis of virtual ops, which I noticed happening while debugging this. Bootstrapped and regtested on powerpc64-unknown-linux-gnu with no new failures. Ok for trunk? Thanks, Bill gcc: 2012-06-17 Bill Schmidt PR tree-optimization/53703 * tree-ssa-phiopt.c (hoist_adjacent_loads): Skip virtual phis; correctly set bb_for_def[12]. gcc/testsuite: 2012-06-17 Bill Schmidt PR tree-optimization/53703 * gcc.dg/torture/pr53703.c: New test. Index: gcc/testsuite/gcc.dg/torture/pr53703.c =================================================================== --- gcc/testsuite/gcc.dg/torture/pr53703.c (revision 0) +++ gcc/testsuite/gcc.dg/torture/pr53703.c (revision 0) @@ -0,0 +1,149 @@ +/* Reduced test case from PR53703. Used to ICE. */ + +/* { dg-do compile } */ +/* { dg-options "-w" } */ + +typedef long unsigned int size_t; +typedef unsigned short int sa_family_t; +struct sockaddr {}; +typedef unsigned char __u8; +typedef unsigned short __u16; +typedef unsigned int __u32; +struct nlmsghdr { + __u32 nlmsg_len; + __u16 nlmsg_type; +}; +struct ifaddrmsg { + __u8 ifa_family; +}; +enum { + IFA_ADDRESS, + IFA_LOCAL, +}; +enum { + RTM_NEWLINK = 16, + RTM_NEWADDR = 20, +}; +struct rtattr { + unsigned short rta_len; + unsigned short rta_type; +}; +struct ifaddrs { + struct ifaddrs *ifa_next; + unsigned short ifa_flags; +}; +typedef unsigned short int uint16_t; +typedef unsigned int uint32_t; +struct nlmsg_list { + struct nlmsg_list *nlm_next; + int size; +}; +struct rtmaddr_ifamap { + void *address; + void *local; + int address_len; + int local_len; +}; +int usagi_getifaddrs (struct ifaddrs **ifap) +{ + struct nlmsg_list *nlmsg_list, *nlmsg_end, *nlm; + size_t dlen, xlen, nlen; + int build; + for (build = 0; build <= 1; build++) + { + struct ifaddrs *ifl = ((void *)0), *ifa = ((void *)0); + struct nlmsghdr *nlh, *nlh0; + uint16_t *ifflist = ((void *)0); + struct rtmaddr_ifamap ifamap; + for (nlm = nlmsg_list; nlm; nlm = nlm->nlm_next) + { + int nlmlen = nlm->size; + for (nlh = nlh0; + ((nlmlen) >= (int)sizeof(struct nlmsghdr) + && (nlh)->nlmsg_len >= sizeof(struct nlmsghdr) + && (nlh)->nlmsg_len <= (nlmlen)); + nlh = ((nlmlen) -= ( (((nlh)->nlmsg_len)+4U -1) & ~(4U -1) ), + (struct nlmsghdr*)(((char*)(nlh)) + + ( (((nlh)->nlmsg_len)+4U -1) + & ~(4U -1) )))) + { + struct ifinfomsg *ifim = ((void *)0); + struct ifaddrmsg *ifam = ((void *)0); + struct rtattr *rta; + sa_family_t nlm_family = 0; + uint32_t nlm_scope = 0, nlm_index = 0; + memset (&ifamap, 0, sizeof (ifamap)); + switch (nlh->nlmsg_type) + { + case RTM_NEWLINK: + ifim = (struct ifinfomsg *) + ((void*)(((char*)nlh) + + ((0)+( ((((int) + ( ((sizeof(struct nlmsghdr))+4U -1) + & ~(4U -1) )))+4U -1) + & ~(4U -1) )))); + case RTM_NEWADDR: + ifam = (struct ifaddrmsg *) + ((void*)(((char*)nlh) + + ((0)+( ((((int) + ( ((sizeof(struct nlmsghdr))+4U -1) + & ~(4U -1) )))+4U -1) + & ~(4U -1) )))); + nlm_family = ifam->ifa_family; + if (build) + ifa->ifa_flags = ifflist[nlm_index]; + break; + default: + continue; + } + if (!build) + { + void *rtadata = ((void*)(((char*)(rta)) + + (( ((sizeof(struct rtattr))+4 -1) + & ~(4 -1) ) + (0)))); + size_t rtapayload = ((int)((rta)->rta_len) + - (( ((sizeof(struct rtattr))+4 -1) + & ~(4 -1) ) + (0))); + switch (nlh->nlmsg_type) + { + case RTM_NEWLINK: + break; + case RTM_NEWADDR: + if (nlm_family == 17) + break; + switch (rta->rta_type) + { + case IFA_ADDRESS: + ifamap.address = rtadata; + ifamap.address_len = rtapayload; + case IFA_LOCAL: + ifamap.local = rtadata; + } + } + } + if (nlh->nlmsg_type == RTM_NEWADDR && nlm_family != 17) + { + if (!ifamap.local) + { + ifamap.local = ifamap.address; + ifamap.local_len = ifamap.address_len; + } + if (!ifamap.address) + { + ifamap.address = ifamap.local; + } + if (ifamap.address_len != ifamap.local_len + || (ifamap.address != ((void *)0) + && memcmp (ifamap.address, ifamap.local, + ifamap.address_len))) + { + if (!build) + dlen += (((ifa_sa_len (nlm_family, + ifamap.address_len))+4U -1) + & ~(4U -1) ); + } + } + } + } + } +} Index: gcc/tree-ssa-phiopt.c =================================================================== --- gcc/tree-ssa-phiopt.c (revision 188509) +++ gcc/tree-ssa-phiopt.c (working copy) @@ -1853,7 +1853,9 @@ hoist_adjacent_loads (basic_block bb0, basic_block if (TREE_CODE (arg1) != SSA_NAME || TREE_CODE (arg2) != SSA_NAME || SSA_NAME_IS_DEFAULT_DEF (arg1) - || SSA_NAME_IS_DEFAULT_DEF (arg2)) + || SSA_NAME_IS_DEFAULT_DEF (arg2) + || !is_gimple_reg (arg1) + || !is_gimple_reg (arg2)) continue; def1 = SSA_NAME_DEF_STMT (arg1); @@ -1914,17 +1916,11 @@ hoist_adjacent_loads (basic_block bb0, basic_block defswap = def1; def1 = def2; def2 = defswap; - /* Don't swap bb1 and bb2 as we may have more than one - phi to process successfully. */ - bb_for_def1 = bb2; - bb_for_def2 = bb1; } - else - { - bb_for_def1 = bb1; - bb_for_def2 = bb2; - } + bb_for_def1 = gimple_bb (def1); + bb_for_def2 = gimple_bb (def2); + /* Check for proper alignment of the first field. */ tree_offset1 = bit_position (field1); tree_offset2 = bit_position (field2);