From patchwork Sat Nov 10 03:22:38 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Pinski X-Patchwork-Id: 198169 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 49D952C0086 for ; Sat, 10 Nov 2012 14:22:47 +1100 (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=1353122568; h=Comment: DomainKey-Signature:Received:Received:Received:Received: MIME-Version:Received:Received:Date:Message-ID:Subject:From:To: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=oHOc9B1 /Agjcu3avGYrFU1uzA2A=; b=hdtrpMg68KSW15tsu5rjNBWj7+PCwIziGODNfB+ KtlH3T9CoIx0gHHr0B6pk7oydaT7aU9PJha9RDEAYjaa5LHU98OGzTYf1QKZc2T5 rftEDEmqo45ovaVXJy32lzqMdMHsO95nYTwMDgfGz3dEEIIemkioxX4GKTowv0yP kDsw= 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:MIME-Version:Received:Received:Date:Message-ID:Subject:From:To:Content-Type:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=WySnlwlFScNjTOW7zX/3yZbOde/4s6uVJ8TGge1GTHhsNLkfhDALgsNCqtDLz6 bx+gCHluVzP6l3Ak6gIoH8crTvpckzdQUqZYifdznlrcxOl66tP2OM3AiV1B1eQ9 dZXib3lPh9XRpNR5dn9uEQ3hZJf95Urdx5W0yiBvtgvSk=; Received: (qmail 10732 invoked by alias); 10 Nov 2012 03:22:44 -0000 Received: (qmail 10720 invoked by uid 22791); 10 Nov 2012 03:22:43 -0000 X-SWARE-Spam-Status: No, hits=-4.1 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, KHOP_RCVD_TRUST, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE X-Spam-Check-By: sourceware.org Received: from mail-wi0-f169.google.com (HELO mail-wi0-f169.google.com) (209.85.212.169) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 10 Nov 2012 03:22:40 +0000 Received: by mail-wi0-f169.google.com with SMTP id hq4so1109986wib.2 for ; Fri, 09 Nov 2012 19:22:38 -0800 (PST) MIME-Version: 1.0 Received: by 10.180.83.130 with SMTP id q2mr5542711wiy.22.1352517758694; Fri, 09 Nov 2012 19:22:38 -0800 (PST) Received: by 10.217.64.194 with HTTP; Fri, 9 Nov 2012 19:22:38 -0800 (PST) Date: Fri, 9 Nov 2012 19:22:38 -0800 Message-ID: Subject: [Committed] Add testcase From: Andrew Pinski To: GCC Patches X-IsSubscribed: yes 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 Hi, While I was working on using zero_extract more on the left hand side in combine, I found a bug in my code but there was no testcase in the testsuite that tested it. The code originally comes from uboot which was failing when doing a ping or tftp. Committed the testcase as obvious after a quick test to make sure it works. Note someone might need to mark the testcase as only executable on targets which have 32bit ints. Thanks, Andrew Pinski ChangeLog: * gcc.c-torture/execute/20121108-1.c: New testcase. Index: gcc.c-torture/execute/20121108-1.c =================================================================== --- gcc.c-torture/execute/20121108-1.c (revision 0) +++ gcc.c-torture/execute/20121108-1.c (revision 0) @@ -0,0 +1,51 @@ +char temp[] = "192.168.190.160"; +unsigned result = (((((192u<<8)|168u)<<8)|190u)<<8)|160u; + +int strtoul1(const char *a, char **b, int c) __attribute__((noinline, noclone)); +int strtoul1(const char *a, char **b, int c) +{ + *b = a+3; + if (a == temp) + return 192; + else if (a == temp+4) + return 168; + else if (a == temp+8) + return 190; + else if (a == temp+12) + return 160; + __builtin_abort(); +} + +int string_to_ip(const char *s) __attribute__((noinline,noclone)); +int string_to_ip(const char *s) +{ + int addr; + char *e; + int i; + + if (s == 0) + return(0); + + for (addr=0, i=0; i<4; ++i) { + int val = s ? strtoul1(s, &e, 10) : 0; + addr <<= 8; + addr |= (val & 0xFF); + if (s) { + s = (*e) ? e+1 : e; + } + } + + return addr; +} + +int main(void) +{ + int t = string_to_ip (temp); + printf ("%x\n", t); + printf ("%x\n", result); + if (t != result) + __builtin_abort (); + printf ("WORKS.\n"); + return 0; +} +