From patchwork Mon May 14 17:02:52 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 159069 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 6E642B703B for ; Tue, 15 May 2012 03:03:29 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1337619809; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Date:From:To:Cc:Subject:Message-ID:Reply-To: MIME-Version:Content-Type:Content-Disposition:User-Agent: Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:Sender:Delivered-To; bh=n5/0moSI5gRViH37UES9 FICzFJY=; b=wKsrqKZZIowEN4B6s1LyFSzjDwxr2Ql2vFh3c3SM6oTEPq8uDolr F4S+vEwpypXsH60gVmYQ2otMYW5PaqSaliA+vq/OmGTZQdq2IfI/xeONOO+cM2JR mvCRoPcwHobEwNCf19Y43kFtY4ugwDykrm9lCIjwixeBtnFax2TvLU4= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Received:Received:Date:From:To:Cc:Subject:Message-ID:Reply-To:MIME-Version:Content-Type:Content-Disposition:User-Agent:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=g2LOhzBjI7Z4h6wk5qeeTMtA7QqYPxHU+1XOXArHs/5nTw7B/0ym5HRfwrGmBk LIAgYaLU7VmUELQT/lM6CBwmwiOoiDO23T8H2AGbczh4kBDbLwoenVbqDZ3OhU2t bSE4B6cdOZARbGCt6evieTzviPuTPd81vsqDMylWte5mg=; Received: (qmail 7407 invoked by alias); 14 May 2012 17:03:18 -0000 Received: (qmail 7396 invoked by uid 22791); 14 May 2012 17:03:14 -0000 X-SWARE-Spam-Status: No, hits=-6.2 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, T_RP_MATCHES_RCVD 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; Mon, 14 May 2012 17:02:57 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q4EH2sWI031530 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 14 May 2012 13:02:57 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [10.16.42.4]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q4EH2rKK016100 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 14 May 2012 13:02:53 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [127.0.0.1]) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4) with ESMTP id q4EH2qwZ013034; Mon, 14 May 2012 19:02:52 +0200 Received: (from jakub@localhost) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4/Submit) id q4EH2q0U013033; Mon, 14 May 2012 19:02:52 +0200 Date: Mon, 14 May 2012 19:02:52 +0200 From: Jakub Jelinek To: Uros Bizjak Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix up xbegin expansion (PR target/53315) Message-ID: <20120514170252.GI16117@tyan-ft48-01.lab.bos.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) 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 Hi! This is an updated version of the xbegin bugfix. Bootstrapped/regtested on x86_64-linux and i686-linux, tested with the testcase by Andi on RTM capable hw (or was it sim?). Ok for trunk? 2012-05-14 Andrew Pinski H.J. Lu Jakub Jelinek PR target/53315 * config/i386/i386.md (xbegin_1): Use + in constraint and match_dup. (xbegin): Updated. 2012-05-14 Andi Kleen Jakub Jelinek PR target/53315 * gcc.target/i386/i386.exp (check_effective_target_rtm): New. * gcc.target/i386/rtm-check.h: New file. * gcc.target/i386/pr53315.c: New test. Jakub --- gcc/config/i386/i386.md.jj 2012-05-12 10:21:01.672022706 +0200 +++ gcc/config/i386/i386.md 2012-05-12 10:51:35.783152924 +0200 @@ -18435,11 +18435,13 @@ (define_expand "xbegin" operands[1] = force_reg (SImode, constm1_rtx); - emit_jump_insn (gen_xbegin_1 (operands[0], operands[1], label)); + emit_jump_insn (gen_xbegin_1 (operands[1], label)); emit_label (label); LABEL_NUSES (label) = 1; + emit_move_insn (operands[0], operands[1]); + DONE; }) @@ -18447,13 +18449,12 @@ (define_insn "xbegin_1" [(set (pc) (if_then_else (ne (unspec [(const_int 0)] UNSPEC_XBEGIN_ABORT) (const_int 0)) - (label_ref (match_operand 2)) + (label_ref (match_operand 1)) (pc))) - (set (match_operand:SI 0 "register_operand" "=a") - (unspec_volatile:SI [(match_operand:SI 1 "register_operand" "0")] - UNSPECV_XBEGIN))] + (set (match_operand:SI 0 "register_operand" "+a") + (unspec_volatile:SI [(match_dup 0)] UNSPECV_XBEGIN))] "TARGET_RTM" - "xbegin\t%l2" + "xbegin\t%l1" [(set_attr "type" "other") (set_attr "length" "6")]) --- gcc/testsuite/gcc.target/i386/i386.exp.jj 2011-09-02 16:29:23.000000000 +0200 +++ gcc/testsuite/gcc.target/i386/i386.exp 2012-05-12 11:04:07.212795468 +0200 @@ -1,4 +1,4 @@ -# Copyright (C) 1997, 2004, 2007, 2008, 2009, 2010 +# Copyright (C) 1997, 2004, 2007, 2008, 2009, 2010, 2011, 2012 # Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify @@ -243,6 +243,17 @@ proc check_effective_target_bmi2 { } { } "-mbmi2" ] } +# Return 1 if rtm instructions can be compiled. +proc check_effective_target_rtm { } { + return [check_no_compiler_messages rtm object { + void + _rtm_xend (void) + { + return __builtin_ia32_xend (); + } + } "-mrtm" ] +} + # If the linker used understands -M , pass it to clear hardware # capabilities set by the Sun assembler. set clearcap_ldflags "-Wl,-M,$srcdir/$subdir/clearcap.map" --- gcc/testsuite/gcc.target/i386/rtm-check.h.jj 2012-05-12 15:56:56.201185071 +0200 +++ gcc/testsuite/gcc.target/i386/rtm-check.h 2012-05-12 16:00:35.704909163 +0200 @@ -0,0 +1,32 @@ +#include +#include "cpuid.h" + +static void rtm_test (void); + +static void __attribute__ ((noinline)) do_test (void) +{ + rtm_test (); +} + +int +main () +{ + unsigned int eax, ebx, ecx, edx; + + if (__get_cpuid_max (0, NULL) >= 7) + { + __cpuid_count (7, 0, eax, ebx, ecx, edx); + if (ebx & bit_RTM) + { + do_test (); +#ifdef DEBUG + printf ("PASSED\n"); +#endif + return 0; + } + } +#ifdef DEBUG + printf ("SKIPPED\n"); +#endif + return 0; +} --- gcc/testsuite/gcc.target/i386/pr53315.c.jj 2012-05-12 10:57:51.886971582 +0200 +++ gcc/testsuite/gcc.target/i386/pr53315.c 2012-05-12 16:02:08.493369397 +0200 @@ -0,0 +1,27 @@ +/* PR target/53315 and PR target/53291 */ +/* { dg-do run } */ +/* { dg-options "-O2 -mrtm" } */ +/* { dg-require-effective-target rtm } */ + +#include +#include "rtm-check.h" + +static void +rtm_test (void) +{ + int flag = -1; + unsigned status; + + if ((status = _xbegin ()) == _XBEGIN_STARTED) + { + flag = _xtest (); + _xend (); + } + else + return; + + if (flag != 1) + abort (); + if (_xtest () != 0) + abort (); +}