From patchwork Fri Sep 28 01:18:22 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 187682 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 116542C00B2 for ; Fri, 28 Sep 2012 11:18:38 +1000 (EST) Received: from localhost ([::1]:37421 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1THPDw-0001iI-5U for incoming@patchwork.ozlabs.org; Thu, 27 Sep 2012 21:18:36 -0400 Received: from eggs.gnu.org ([208.118.235.92]:33803) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1THPDn-0001hD-RA for qemu-devel@nongnu.org; Thu, 27 Sep 2012 21:18:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1THPDm-00058Y-Si for qemu-devel@nongnu.org; Thu, 27 Sep 2012 21:18:27 -0400 Received: from mail-da0-f45.google.com ([209.85.210.45]:50287) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1THPDm-00058U-MC for qemu-devel@nongnu.org; Thu, 27 Sep 2012 21:18:26 -0400 Received: by dadn15 with SMTP id n15so527950dad.4 for ; Thu, 27 Sep 2012 18:18:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=/J+qwg39uw2woVi/4pUFr3UrQ9jznF1tscWy345Y258=; b=bL0FX22I1pJVyjPHb5xvx0sfJx9bdui/SlGyKDsgkjJk2i0Ab0cb5XwSVtZqXG6aOx NnDfopg4nI26bxFA4ikbLK/btqfrioB97xhX8qnfsBsXt4uIUWKG5FWp8W6NDPc3XNxO 7Yc0BRpjNP/JCNKMk0QWB2R3O9ApyXbq0e18PaKSKqlod4HTywsFuVIO2r4ZCzXVJeuZ LObKUNcRDVZ3vbd4QCFEwx5/eI5aNTHY1MhoTryrTBGR/VLEEkCbR3ar0FZ9B09+Flpk Ot5MtNAtYOw/vqF9Wu4amliF/h/Od/JrJsIBDIe1fzwd4arAfYRbtL/Pz9oXnWryHJv3 Ha2A== Received: by 10.66.77.170 with SMTP id t10mr13649515paw.0.1348795106083; Thu, 27 Sep 2012 18:18:26 -0700 (PDT) Received: from anchor.twiddle.home.com ([173.160.232.49]) by mx.google.com with ESMTPS id x8sm4580603paw.16.2012.09.27.18.18.25 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 27 Sep 2012 18:18:25 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 27 Sep 2012 18:18:22 -0700 Message-Id: <1348795102-28788-1-git-send-email-rth@twiddle.net> X-Mailer: git-send-email 1.7.11.4 In-Reply-To: <1348785610-23418-1-git-send-email-rth@twiddle.net> References: <1348785610-23418-1-git-send-email-rth@twiddle.net> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.210.45 Cc: Alexander Graf Subject: [Qemu-devel] [PATCH 141/147] target-s390: Optimize XC X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Notice XC with same address and convert that to store of zero. Signed-off-by: Richard Henderson --- target-s390x/insn-data.def | 2 +- target-s390x/translate.c | 50 +++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 48 insertions(+), 4 deletions(-) diff --git a/target-s390x/insn-data.def b/target-s390x/insn-data.def index e915984..480f1fd 100644 --- a/target-s390x/insn-data.def +++ b/target-s390x/insn-data.def @@ -271,7 +271,7 @@ C(0xb982, XGR, RRE, Z, r1, r2, r1, 0, xor, nz64) C(0xb9e7, XGRK, RRF_a, DO, r2, r3, r1, 0, xor, nz64) C(0xe382, XG, RXY_a, Z, r1, m2_64, r1, 0, xor, nz64) - C(0xd700, XC, SS_a, Z, la1, a2, 0, 0, xc, 0) + C(0xd700, XC, SS_a, Z, 0, 0, 0, 0, xc, 0) /* EXCLUSIVE OR IMMEDIATE */ D(0xc006, XIHF, RIL_a, EI, r1_o, i2_32u, r1, 0, xori, 0, 0x2020) D(0xc007, XILF, RIL_a, EI, r1_o, i2_32u, r1, 0, xori, 0, 0x2000) diff --git a/target-s390x/translate.c b/target-s390x/translate.c index b945ba1..5b88efb 100644 --- a/target-s390x/translate.c +++ b/target-s390x/translate.c @@ -3403,10 +3403,54 @@ static ExitStatus op_unpk(DisasContext *s, DisasOps *o) static ExitStatus op_xc(DisasContext *s, DisasOps *o) { - TCGv_i32 l = tcg_const_i32(get_field(s->fields, l1)); + int d1 = get_field(s->fields, d1); + int d2 = get_field(s->fields, d2); + int b1 = get_field(s->fields, b1); + int b2 = get_field(s->fields, b2); + int l = get_field(s->fields, l1); + TCGv_i32 t32; + + o->addr1 = get_address(s, 0, b1, d1); + + /* If the addresses are identical, this is a store/memset of zero. */ + if (b1 == b2 && d1 == d2 && (l + 1) <= 32) { + o->in2 = tcg_const_i64(0); + + l++; + while (l >= 8) { + tcg_gen_qemu_st64(o->in2, o->addr1, get_mem_index(s)); + l -= 8; + if (l > 0) { + tcg_gen_addi_i64(o->addr1, o->addr1, 8); + } + } + if (l >= 4) { + tcg_gen_qemu_st32(o->in2, o->addr1, get_mem_index(s)); + l -= 4; + if (l > 0) { + tcg_gen_addi_i64(o->addr1, o->addr1, 4); + } + } + if (l >= 2) { + tcg_gen_qemu_st16(o->in2, o->addr1, get_mem_index(s)); + l -= 2; + if (l > 0) { + tcg_gen_addi_i64(o->addr1, o->addr1, 2); + } + } + if (l) { + tcg_gen_qemu_st8(o->in2, o->addr1, get_mem_index(s)); + } + gen_op_movi_cc(s, 0); + return NO_EXIT; + } + + /* But in general we'll defer to a helper. */ + o->in2 = get_address(s, 0, b2, d2); + t32 = tcg_const_i32(l); potential_page_fault(s); - gen_helper_xc(cc_op, cpu_env, l, o->addr1, o->in2); - tcg_temp_free_i32(l); + gen_helper_xc(cc_op, cpu_env, t32, o->addr1, o->in2); + tcg_temp_free_i32(t32); set_cc_static(s); return NO_EXIT; }