From patchwork Thu Aug 6 12:23:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 1341672 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=suse.de Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BMnjF0qzDz9sPB for ; Thu, 6 Aug 2020 22:24:01 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D11F73857C6C; Thu, 6 Aug 2020 12:23:57 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by sourceware.org (Postfix) with ESMTPS id 86F113858D37 for ; Thu, 6 Aug 2020 12:23:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 86F113858D37 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tdevries@suse.de X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id BC549AAC7; Thu, 6 Aug 2020 12:24:11 +0000 (UTC) Date: Thu, 6 Aug 2020 14:23:52 +0200 From: Tom de Vries To: gcc-patches@gcc.gnu.org Subject: [PATCH][testsuite] Add gcc.dg/ia64-sync-5.c Message-ID: <20200806122351.GA20360@delia> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Hi, There currently is no sync_char_short-enabled run test that tests __sync_val_compare_and_swap. Fix this by copying ia64-sync-3.c and modifying it for char/short. Tested on x86_64. OK for trunk? Thanks, - Tom [testsuite] Add gcc.dg/ia64-sync-5.c 2020-08-06 Kwok Cheung Yeung Tom de Vries gcc/testsuite/ChangeLog: * gcc.dg/ia64-sync-5.c: New test. --- gcc/testsuite/gcc.dg/ia64-sync-5.c | 83 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) diff --git a/gcc/testsuite/gcc.dg/ia64-sync-5.c b/gcc/testsuite/gcc.dg/ia64-sync-5.c new file mode 100644 index 00000000000..8b16b29b20e --- /dev/null +++ b/gcc/testsuite/gcc.dg/ia64-sync-5.c @@ -0,0 +1,83 @@ +/* { dg-do run } */ +/* { dg-require-effective-target sync_char_short } */ +/* { dg-options } */ +/* { dg-options "-march=i486" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ +/* { dg-options "-mcpu=v9" { target sparc*-*-* } } */ + +/* Test basic functionality of the intrinsics. */ + +/* This is a copy of gcc.dg/ia64-sync-3.c, for 8-bit and 16-bit. */ + +__extension__ typedef __SIZE_TYPE__ size_t; + +extern void abort (void); +extern void *memcpy (void *, const void *, size_t); +extern int memcmp (const void *, const void *, size_t); + +static char AC[4]; +static char init_qi[4] = { -30,-30,-50,-50 }; +static char test_qi[4] = { -115,-115,25,25 }; + +static void +do_qi (void) +{ + if (__sync_val_compare_and_swap(AC+0, -30, -115) != -30) + abort (); + if (__sync_val_compare_and_swap(AC+0, -30, -115) != -115) + abort (); + if (__sync_bool_compare_and_swap(AC+1, -30, -115) != 1) + abort (); + if (__sync_bool_compare_and_swap(AC+1, -30, -115) != 0) + abort (); + + if (__sync_val_compare_and_swap(AC+2, AC[2], 25) != -50) + abort (); + if (__sync_val_compare_and_swap(AC+2, AC[2], 25) != 25) + abort (); + if (__sync_bool_compare_and_swap(AC+3, AC[3], 25) != 1) + abort (); + if (__sync_bool_compare_and_swap(AC+3, AC[3], 25) != 1) + abort (); +} + +static short AS[4]; +static short init_hi[4] = { -30,-30,-50,-50 }; +static short test_hi[4] = { -115,-115,25,25 }; + +static void +do_hi (void) +{ + if (__sync_val_compare_and_swap(AS+0, -30, -115) != -30) + abort (); + if (__sync_val_compare_and_swap(AS+0, -30, -115) != -115) + abort (); + if (__sync_bool_compare_and_swap(AS+1, -30, -115) != 1) + abort (); + if (__sync_bool_compare_and_swap(AS+1, -30, -115) != 0) + abort (); + + if (__sync_val_compare_and_swap(AS+2, AS[2], 25) != -50) + abort (); + if (__sync_val_compare_and_swap(AS+2, AS[2], 25) != 25) + abort (); + if (__sync_bool_compare_and_swap(AS+3, AS[3], 25) != 1) + abort (); + if (__sync_bool_compare_and_swap(AS+3, AS[3], 25) != 1) + abort (); +} + +int main() +{ + memcpy(AC, init_qi, sizeof(init_qi)); + memcpy(AS, init_hi, sizeof(init_hi)); + + do_qi (); + do_hi (); + + if (memcmp (AC, test_qi, sizeof(test_qi))) + abort (); + if (memcmp (AS, test_hi, sizeof(test_hi))) + abort (); + + return 0; +}