From patchwork Tue Aug 16 13:56:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Martin_Li=C5=A1ka?= X-Patchwork-Id: 659934 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3sDg4T3qH3z9t0X for ; Wed, 17 Aug 2016 16:56:25 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=ghqgO/3m; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :resent-from:resent-to:resent-date:resent-message-id:message-id :in-reply-to:references:from:date:subject:to; q=dns; s=default; b= bzxyFWWQFhBd+T093SDq51FSpMMEzwg37CFNbSSYBmw5xSgzw+lgnFGtEKyXCRMa xIQYnexTz2hF13IO3go5kNRZqzqZZrqr/Pl8NTcneV8+rvEMozpmL7SNDlUvC/46 puJoS+spXeriEAbY0KMFbiJa6Bne3O4TYg5KHGn8wac= 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 :resent-from:resent-to:resent-date:resent-message-id:message-id :in-reply-to:references:from:date:subject:to; s=default; bh=xsCg +uXyJcENEvLhia7azu9gLvo=; b=ghqgO/3mmwqE5LTlsQxIFqWWE/37DDIDRmL1 1OBW2IoHM1FXnaoRSLvDprpESHTxNjUWQatLcYapR07yBMo24Hk1IwBI9E496eS/ s7P2hv50Nk/xeYipGfq5aFh8uVchGYY5zv9wa8i/NnFcSmNk1eK88ahiLGAJGPPN JYWaLDM= Received: (qmail 90677 invoked by alias); 17 Aug 2016 06:55:21 -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 90544 invoked by uid 89); 17 Aug 2016 06:55:20 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx2.suse.de Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 17 Aug 2016 06:55:10 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id B062EAC4A for ; Wed, 17 Aug 2016 06:55:07 +0000 (UTC) Resent-From: =?UTF-8?Q?Martin_Li=c5=a1ka?= Resent-To: GCC Patches Resent-Date: Wed, 17 Aug 2016 08:55:06 +0200 Resent-Message-ID: <97f66a30-697e-11ca-b19a-c6b49f3daede@suse.cz> Resent-User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2 Message-Id: <8871f5ae1f3151e1de62622d4f918d24d693a48b.1471416736.git.mliska@suse.cz> In-Reply-To: References: From: marxin Date: Tue, 16 Aug 2016 15:56:01 +0200 Subject: [PATCH 3/3] Test folding of strn{case}cmp and memchr To: gcc-patches@gcc.gnu.org X-IsSubscribed: yes gcc/testsuite/ChangeLog: 2016-08-16 Martin Liska * gcc.dg/tree-ssa/builtins-folding.c: New test. --- gcc/testsuite/gcc.dg/tree-ssa/builtins-folding.c | 59 ++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/builtins-folding.c diff --git a/gcc/testsuite/gcc.dg/tree-ssa/builtins-folding.c b/gcc/testsuite/gcc.dg/tree-ssa/builtins-folding.c new file mode 100644 index 0000000..df63681 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/builtins-folding.c @@ -0,0 +1,59 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +char *buffer1; + +void +main_test (void) +{ + const char* const foo1 = "hello world"; + + /* MEMCHR. */ + if (__builtin_memchr (foo1, 'x', 11)) + __builtin_abort (); + if (__builtin_memchr (foo1, 'x', 100)) + __builtin_abort (); + if (__builtin_memchr (buffer1, 'x', 0) != 0) + __builtin_abort (); + if (__builtin_memchr (foo1, 'o', 11) != foo1 + 4) + __builtin_abort (); + if (__builtin_memchr (foo1, 'w', 2)) + __builtin_abort (); + if (__builtin_memchr (foo1 + 5, 'o', 6) != foo1 + 7) + __builtin_abort (); + if (__builtin_memchr (foo1, 'd', 11) != foo1 + 10) + __builtin_abort (); + if (__builtin_memchr (foo1, 'd', 10)) + __builtin_abort (); + if (__builtin_memchr (foo1, '\0', 11)) + __builtin_abort (); + if (__builtin_memchr (foo1, '\0', 12) != foo1 + 11) + __builtin_abort (); + + /* STRNCMP. */ + if (__builtin_strncmp ("hello", "aaaaa", 0) != 0) + __builtin_abort (); + if (__builtin_strncmp ("aaaaa", "aaaaa", 100) != 0) + __builtin_abort (); + if (__builtin_strncmp ("aaaaa", "", 100) <= 0) + __builtin_abort (); + if (__builtin_strncmp ("", "aaaaa", 100) >= 0) + __builtin_abort (); + if (__builtin_strncmp ("ab", "ba", 1) >= 0) + __builtin_abort (); + + /* STRNCASECMP. */ + if (__builtin_strncasecmp ("hello", "aaaaa", 0) != 0) + __builtin_abort (); + if (__builtin_strncasecmp ("aaaaa", "aaaaa", 100) != 0) + __builtin_abort (); + if (__builtin_strncasecmp ("aaaaa", "", 100) <= 0) + __builtin_abort (); + if (__builtin_strncasecmp ("", "aaaaa", 100) >= 0) + __builtin_abort (); +} + +/* { dg-final { scan-tree-dump-not "__builtin_memchr" "optimized" } } */ +/* { dg-final { scan-tree-dump-not "__builtin_strncmp" "optimized" } } */ +/* { dg-final { scan-tree-dump-not "__builtin_strncasecmp" "optimized" } } */ +/* { dg-final { scan-tree-dump-not "__builtin_abort" "optimized" } } */