From patchwork Thu Oct 24 22:30:30 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 286047 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 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 44C572C00B8 for ; Fri, 25 Oct 2013 09:30:44 +1100 (EST) 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:references :in-reply-to:content-type; q=dns; s=default; b=jtyINn6hQHizRvHuw 5QaPu9ZJFFZIGU0niAT7JZxKK0/KGYoqCn1DpbOYKjI4GpoCPosIrox+6ZzLsqpk sIblJpK+EhaKtusMUHp71+bPTpgX7tax82RBwPuGHUjeVor2QGk8I1NgZqRQ4L1x qeqssoD3EiXJj4n402EdKHvVg4= 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:references :in-reply-to:content-type; s=default; bh=JOtDmV5JFi+tp/rXwiSFICH XN2k=; b=Gl4amfDjQNaJ5/60c1yTATRkwbte8UNXRiZqhbOg2izmplHDgmu7bZx WpAnM9glCXFRpU5Tt1+eWdMAjzldRth1LsKQ8Jo7F0oR3TsxOgWk/FRvwfvcNdPS H8kFcxVK+kX8kDqxs7842MsvX49wgHJp/5GvyimmbUp+X1tv2Ox0= Received: (qmail 17912 invoked by alias); 24 Oct 2013 22:30:37 -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 17898 invoked by uid 89); 24 Oct 2013 22:30:36 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.3 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 24 Oct 2013 22:30:35 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r9OMUWrN020865 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 24 Oct 2013 18:30:32 -0400 Received: from pebble.twiddle.net (vpn-60-11.rdu2.redhat.com [10.10.60.11]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r9OMUVcX019979; Thu, 24 Oct 2013 18:30:31 -0400 Message-ID: <52699F86.2080400@redhat.com> Date: Thu, 24 Oct 2013 15:30:30 -0700 From: Richard Henderson User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.0 MIME-Version: 1.0 To: Eric Botcazou , gcc-patches@gcc.gnu.org, rsandifo@linux.vnet.ibm.com Subject: Re: [RFC] PR 58542: const_int vs lost modes References: <52686543.1000506@redhat.com> <2249166.AW8VGR967l@polaris> <2705096.z4dVz8XuFW@polaris> <87wql2swpc.fsf@sandifor-thinkpad.stglab.manchester.uk.ibm.com> In-Reply-To: <87wql2swpc.fsf@sandifor-thinkpad.stglab.manchester.uk.ibm.com> X-IsSubscribed: yes On 10/24/2013 05:02 AM, Richard Sandiford wrote: > Do we actually need to do a conversion here at all? It looks like the > modes of "expected" and "desired" should already match "mem", so we could > just use create_input_operand. This works. I've committed the following to mainline, and will test the patch for backport. r~ PR rtl/58542 * optabs.c (maybe_emit_atomic_exchange): Use create_input_operand instead of create_convert_operand_to. (maybe_emit_sync_lock_test_and_set): Likewise. (expand_atomic_compare_and_swap): Likewise. (maybe_emit_compare_and_swap_exchange_loop): Don't convert_modes. diff --git a/gcc/optabs.c b/gcc/optabs.c index 06a626c..a8a7e4f 100644 --- a/gcc/optabs.c +++ b/gcc/optabs.c @@ -7040,8 +7040,7 @@ maybe_emit_atomic_exchange (rtx target, rtx mem, rtx val, enum memmodel model) create_output_operand (&ops[0], target, mode); create_fixed_operand (&ops[1], mem); - /* VAL may have been promoted to a wider mode. Shrink it if so. */ - create_convert_operand_to (&ops[2], val, mode, true); + create_input_operand (&ops[2], val, mode); create_integer_operand (&ops[3], model); if (maybe_expand_insn (icode, 4, ops)) return ops[0].value; @@ -7080,8 +7079,7 @@ maybe_emit_sync_lock_test_and_set (rtx target, rtx mem, rtx val, struct expand_operand ops[3]; create_output_operand (&ops[0], target, mode); create_fixed_operand (&ops[1], mem); - /* VAL may have been promoted to a wider mode. Shrink it if so. */ - create_convert_operand_to (&ops[2], val, mode, true); + create_input_operand (&ops[2], val, mode); if (maybe_expand_insn (icode, 3, ops)) return ops[0].value; } @@ -7123,8 +7121,6 @@ maybe_emit_compare_and_swap_exchange_loop (rtx target, rtx mem, rtx val) { if (!target || !register_operand (target, mode)) target = gen_reg_rtx (mode); - if (GET_MODE (val) != VOIDmode && GET_MODE (val) != mode) - val = convert_modes (mode, GET_MODE (val), val, 1); if (expand_compare_and_swap_loop (mem, target, val, NULL_RTX)) return target; } @@ -7336,8 +7332,8 @@ expand_atomic_compare_and_swap (rtx *ptarget_bool, rtx *ptarget_oval, create_output_operand (&ops[0], target_bool, bool_mode); create_output_operand (&ops[1], target_oval, mode); create_fixed_operand (&ops[2], mem); - create_convert_operand_to (&ops[3], expected, mode, true); - create_convert_operand_to (&ops[4], desired, mode, true); + create_input_operand (&ops[3], expected, mode); + create_input_operand (&ops[4], desired, mode); create_integer_operand (&ops[5], is_weak); create_integer_operand (&ops[6], succ_model); create_integer_operand (&ops[7], fail_model); @@ -7358,8 +7354,8 @@ expand_atomic_compare_and_swap (rtx *ptarget_bool, rtx *ptarget_oval, create_output_operand (&ops[0], target_oval, mode); create_fixed_operand (&ops[1], mem); - create_convert_operand_to (&ops[2], expected, mode, true); - create_convert_operand_to (&ops[3], desired, mode, true); + create_input_operand (&ops[2], expected, mode); + create_input_operand (&ops[3], desired, mode); if (!maybe_expand_insn (icode, 4, ops)) return false; diff --git a/gcc/testsuite/gcc.dg/atomic-store-6.c b/gcc/testsuite/gcc.dg/atomic-store-6.c new file mode 100644 index 0000000..81499cd --- /dev/null +++ b/gcc/testsuite/gcc.dg/atomic-store-6.c @@ -0,0 +1,13 @@ +/* { dg-do run } */ +/* { dg-require-effective-target sync_int_128_runtime } */ +/* { dg-options "-mcx16" { target { i?86-*-* x86_64-*-* } } } */ + +__int128_t i; + +int main() +{ + __atomic_store_16(&i, -1, 0); + if (i != -1) + __builtin_abort(); + return 0; +}