From patchwork Wed Jan 17 11:27:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kyrill Tkachov X-Patchwork-Id: 862224 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-471463-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="ERaKsx9C"; dkim-atps=neutral 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 3zM4Zw2KGcz9rxj for ; Wed, 17 Jan 2018 22:28:07 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; q= dns; s=default; b=IZ8x3j7NKJ+p1s1GQF/rznxEVrKvky5CHR6wrJnhsRi7Ca dG+2Cy7eQpIJmS9RUq3yuIXPQEV23VubZc8WNeAHqPpHHUXAD89H4DkAjdPa7M0T n9HGgaGk0bkLfhuDVsJvI+yW+sp+4/O2bLSBs+gfhzq5qMfwWu9MGOt8KlX/k= 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 :message-id:date:from:mime-version:to:subject:content-type; s= default; bh=HiDrnrYvlH3x6pf0NP1z5nk1DIk=; b=ERaKsx9ClF/DHdUuOz8l aZg5qQLzsK/8n+lAT8OY6+r1xnt6XryXBAXWkCVZjFtzWW5w3KbxePTD8/RFkqqp ZSoDqfKpfiv3YEOzsdqXfk2qjuOOk8S49KGvFnuhDd6yE/lzglaMhbYzhzqEaWUm XgEmdzA4pouqRB2TJjbH4Yk= Received: (qmail 21160 invoked by alias); 17 Jan 2018 11:28:00 -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 21122 invoked by uid 89); 17 Jan 2018 11:27:59 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=preventing, ifconversion, if-conversion, awkward X-HELO: foss.arm.com Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 17 Jan 2018 11:27:57 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2FD9F1435 for ; Wed, 17 Jan 2018 03:27:56 -0800 (PST) Received: from [10.2.207.77] (e100706-lin.cambridge.arm.com [10.2.207.77]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D04013F53D for ; Wed, 17 Jan 2018 03:27:55 -0800 (PST) Message-ID: <5A5F333A.5020604@foss.arm.com> Date: Wed, 17 Jan 2018 11:27:54 +0000 From: Kyrill Tkachov User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: "gcc-patches@gcc.gnu.org" Subject: [PATCH][arm] Convert gcc.target/arm/stl-cond.c into an RTL test Hi all, This is an awkward testsuite failure. The original bug was that we were failing to put out the conditional code in the conditional form of the STL instruction (oops!). So we wanted to output STLNE, but instead output STL. The testacase relies on if-conversion to conditionalise the insn for STL. However, ever since r251643 the expansion of a non-relaxed atomic store always includes a compiler barrier. That blocks if-conversion in all cases. So there's no easy to get to a conditional STL instruction from a C program. But we do want to test for the original bug fix that if the RTL insn for STL is conditionalised it should output the conditional code. The solution in this patch is to convert the test into an RTL test with the COND_EXEC form of the STL insn and scan the assembly output there. This seems to work fine, and gives us an opportunity to create a gcc.dg/rtl/arm directory in the RTL tests. This now makes the gcc.target/arm/stl-cond.c disappear (as the test is deleted) and the new test in gcc.dg/rtl/arm/stl-cond.c passes. Committing to trunk. Thanks, Kyrill 2018-01-17 Kyrylo Tkachov * gcc.dg/rtl/arm/stl-cond.c: New test. * gcc.target/arm/stl-cond.c: Delete. diff --git a/gcc/testsuite/gcc.dg/rtl/arm/stl-cond.c b/gcc/testsuite/gcc.dg/rtl/arm/stl-cond.c new file mode 100644 index 0000000000000000000000000000000000000000..e2bc610e1faf4012d06764d78d7853d2237c7b01 --- /dev/null +++ b/gcc/testsuite/gcc.dg/rtl/arm/stl-cond.c @@ -0,0 +1,61 @@ +/* { dg-do compile { target arm-*-* } } */ +/* { dg-require-effective-target arm_arm_ok } */ +/* { dg-require-effective-target arm_arch_v8a_ok } */ +/* { dg-options "-O2 -marm" } */ +/* { dg-add-options arm_arch_v8a } */ + +/* We want to test that the STL instruction gets the conditional + suffix when under a COND_EXEC. However, COND_EXEC is very hard to + generate from C code because the atomic_store expansion adds a compiler + barrier before the insn, preventing if-conversion. So test the output + here with a hand-crafted COND_EXEC wrapped around an STL. */ + +void __RTL (startwith ("final")) foo (int *a, int b) +{ +(function "foo" + (param "a" + (DECL_RTL (reg/v:SI r0)) + (DECL_RTL_INCOMING (reg:SI r0)) + ) + (param "b" + (DECL_RTL (reg/v:SI r1)) + (DECL_RTL_INCOMING (reg:SI r1)) + ) + (insn-chain + (block 2 + (edge-from entry (flags "FALLTHRU")) + (cnote 5 [bb 2] NOTE_INSN_BASIC_BLOCK) + + (insn:TI 7 (parallel [ + (set (reg:CC cc) + (compare:CC (reg:SI r1) + (const_int 0))) + (set (reg/v:SI r1) + (reg:SI r1 )) + ]) ;; {*movsi_compare0} + (nil)) + + ;; A conditional atomic store-release: STLNE for Armv8-A. + (insn 10 (cond_exec (ne (reg:CC cc) + (const_int 0)) + (set (mem/v:SI (reg/v/f:SI r0) [-1 S4 A32]) + (unspec_volatile:SI [ + (reg/v:SI r1) + (const_int 3) + ] VUNSPEC_STL))) ;; {*p atomic_storesi} + (expr_list:REG_DEAD (reg:CC cc) + (expr_list:REG_DEAD (reg/v:SI r1) + (expr_list:REG_DEAD (reg/v/f:SI r0) + (nil))))) + (edge-to exit (flags "FALLTHRU")) + ) ;; block 2 + ) ;; insn-chain + (crtl + (return_rtx + (reg/i:SI r0) + ) ;; return_rtx + ) ;; crtl +) ;; function +} + +/* { dg-final { scan-assembler "stlne" } } */ diff --git a/gcc/testsuite/gcc.target/arm/stl-cond.c b/gcc/testsuite/gcc.target/arm/stl-cond.c deleted file mode 100644 index de14bb580b82eaf8ca0a3e6e11f842c4baf5c756..0000000000000000000000000000000000000000 --- a/gcc/testsuite/gcc.target/arm/stl-cond.c +++ /dev/null @@ -1,19 +0,0 @@ -/* { dg-do compile } */ -/* { dg-require-effective-target arm_arm_ok } */ -/* { dg-require-effective-target arm_arch_v8a_ok } */ -/* { dg-options "-O2 -marm" } */ -/* { dg-add-options arm_arch_v8a } */ - -struct backtrace_state -{ - int threaded; - int lock_alloc; -}; - -void foo (struct backtrace_state *state) -{ - if (state->threaded) - __sync_lock_release (&state->lock_alloc); -} - -/* { dg-final { scan-assembler "stlne" } } */