From patchwork Sat Nov 12 15:56:56 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 125346 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 D9D601007D8 for ; Sun, 13 Nov 2011 02:57:17 +1100 (EST) Received: (qmail 31226 invoked by alias); 12 Nov 2011 15:57:14 -0000 Received: (qmail 31216 invoked by uid 22791); 12 Nov 2011 15:57:12 -0000 X-SWARE-Spam-Status: No, hits=-7.0 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, SPF_HELO_PASS, TW_TR X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 12 Nov 2011 15:56:58 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id pACFuvex000667 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sat, 12 Nov 2011 10:56:57 -0500 Received: from anchor.twiddle.net (vpn-226-80.phx2.redhat.com [10.3.226.80]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id pACFuunL032180; Sat, 12 Nov 2011 10:56:57 -0500 Message-ID: <4EBE9748.5040300@redhat.com> Date: Sat, 12 Nov 2011 07:56:56 -0800 From: Richard Henderson User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:7.0) Gecko/20110927 Thunderbird/7.0 MIME-Version: 1.0 To: Kaz Kojima CC: gcc-patches@gcc.gnu.org Subject: Re: [PATCH 0/4][CFT] Handle legacy __sync libcalls References: <1321054334-21865-1-git-send-email-rth@redhat.com> <20111112.123910.02275607.kkojima@rr.iij4u.or.jp> In-Reply-To: <20111112.123910.02275607.kkojima@rr.iij4u.or.jp> 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 On 11/11/2011 07:39 PM, Kaz Kojima wrote: > It seems that expand_builtin sets "target" variable to > const0_trx when "ignore" argument is set and this causes > the above ICE. I'm trying a patch ... I think the fix belongs in expand_builtin_compare_and_swap. I'm testing the following. r~ diff --git a/gcc/builtins.c b/gcc/builtins.c index 98dc636..9dc68cc 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -5144,7 +5144,6 @@ expand_builtin_sync_operation (enum machine_mode mode, tree exp, case BUILT_IN_SYNC_FETCH_AND_NAND_4: case BUILT_IN_SYNC_FETCH_AND_NAND_8: case BUILT_IN_SYNC_FETCH_AND_NAND_16: - if (warned_f_a_n) break; @@ -5158,7 +5157,6 @@ expand_builtin_sync_operation (enum machine_mode mode, tree exp, case BUILT_IN_SYNC_NAND_AND_FETCH_4: case BUILT_IN_SYNC_NAND_AND_FETCH_8: case BUILT_IN_SYNC_NAND_AND_FETCH_16: - if (warned_n_a_f) break; @@ -5190,16 +5188,24 @@ expand_builtin_compare_and_swap (enum machine_mode mode, tree exp, bool is_bool, rtx target) { rtx old_val, new_val, mem; + rtx *pbool, *poval; /* Expand the operands. */ mem = get_builtin_sync_mem (CALL_EXPR_ARG (exp, 0), mode); old_val = expand_expr_force_mode (CALL_EXPR_ARG (exp, 1), mode); new_val = expand_expr_force_mode (CALL_EXPR_ARG (exp, 2), mode); - if (!expand_atomic_compare_and_swap ((is_bool ? &target : NULL), - (is_bool ? NULL : &target), - mem, old_val, new_val, false, - MEMMODEL_SEQ_CST, MEMMODEL_SEQ_CST)) + pbool = poval = NULL; + if (target != const0_rtx) + { + if (is_bool) + pbool = ⌖ + else + poval = ⌖ + } + if (!expand_atomic_compare_and_swap (pbool, poval, mem, old_val, new_val, + false, MEMMODEL_SEQ_CST, + MEMMODEL_SEQ_CST)) return NULL_RTX; return target; @@ -5338,8 +5344,9 @@ expand_builtin_atomic_compare_exchange (enum machine_mode mode, tree exp, oldval = copy_to_reg (gen_rtx_MEM (mode, expect)); - if (!expand_atomic_compare_and_swap (&target, &oldval, mem, oldval, - desired, is_weak, success, failure)) + if (!expand_atomic_compare_and_swap ((target == const0_rtx ? NULL : &target), + &oldval, mem, oldval, desired, + is_weak, success, failure)) return NULL_RTX; emit_move_insn (gen_rtx_MEM (mode, expect), oldval);