From nobody Wed Apr 16 15:36:26 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1603817685; cv=none; d=zohomail.com; s=zohoarc; b=KN7QVT/N7BHUeTsHCqGp8ZtLz1P256GTlD6Fbc0rsSyy7/LhzvOXqejtu/O9G3QVJ31fjyBYg55razg8oRByQPUbdB4JLa5rb9q1BP2JD/2zVNT4xQ75CGByCAjVheLTKbLzOlb1nXmMfE1sOEmdcON06uXF1I5Gti7CUxEnjBY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603817685; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=FtSerDr+mVNWKALcskLCjbwxaDT2P8IL1JFsGYyWdws=; b=WICjTY4wUB2gbGhd4jEyB2n6pZCLzcaR/RN1kcSB4EKVuMQSSqnbJxbQBAoJsylhhVh40pWealVPOL98rJaZbQYcJH4RXt8sFiF7MvYvYMlEMn8cZaWsMB7Nm64nLYhz0BuWXfwfZvsLTFaabsRqdLXrSs6i3kUGJW8lRCcBn6M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1603817685577333.4938695348717; Tue, 27 Oct 2020 09:54:45 -0700 (PDT) Received: from localhost ([::1]:38202 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kXSF9-0006r2-Oi for importer@patchew.org; Tue, 27 Oct 2020 12:54:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56470) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kXSBv-0003JJ-Sv for qemu-devel@nongnu.org; Tue, 27 Oct 2020 12:51:24 -0400 Received: from mail-pj1-x1036.google.com ([2607:f8b0:4864:20::1036]:34708) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kXSBs-0004RV-NW for qemu-devel@nongnu.org; Tue, 27 Oct 2020 12:51:23 -0400 Received: by mail-pj1-x1036.google.com with SMTP id i3so194175pju.1 for ; Tue, 27 Oct 2020 09:51:20 -0700 (PDT) Received: from localhost.localdomain ([71.212.141.89]) by smtp.gmail.com with ESMTPSA id q16sm2955283pfj.117.2020.10.27.09.51.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Oct 2020 09:51:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FtSerDr+mVNWKALcskLCjbwxaDT2P8IL1JFsGYyWdws=; b=kyROPe9FrbRXhBLLMpI0OcoItkuaDwFzyLJCunkky+D2rRFglVf2JpsKOOoSHL5uiL Zv+li1bvOlO8Hnd/5zu0PBCRbKRN8q2VXlCtaBrG5eGGmuLlADusSwLyxg8BOtTk9zJP HuLjAWj4cSrXpQXoT9Ejt+MASANwS7FpJ1sjBh/4uefFfZr4BlcAM2N7FjZMjcdrof73 x3z8Nbe2S508ruXrHQvxZlX8gc6lzQ8PlMn6PdKQXmT1ogt7EVzgKu4Ieygu8qf9NNht 8FaviIjYJ2m3UqoN/P1+yMfr+sRZZwEuvm4lmmpOxiPenUCv3mA1L3zOgE5iSDs7Hlfq KEJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FtSerDr+mVNWKALcskLCjbwxaDT2P8IL1JFsGYyWdws=; b=s99VYhyPaQHqiLLSohM/tMvdEUrPkRSmIg0xywY3/tlYEYnEvmYPLdoH4L9yLytAt3 mp7/Ojw9TpuiOWSniZNqYkIdklS1dJqU+0JH+TuWfToDnoZGNnOx0hTuBQ4Ty1z2jTHB v2FQnxfCJyySYIvk3/KYxpIxNFxQa7AEUsrYu+7DXlsL59T1pdh4/BhQvCdejWCsPQ9Q fXeNmemuJPk3eDCyec9+YyZputnRO2Z+jUzU1TFoDj9hOYz8UZhxaTm29d6aoGD1DV39 cTNU0MEkcVb5kXgiSYsoy8TQQwVpj2hk6lU7CntcFIdC0dXPNob6A0aLOLmjOwvUdrpk qPQg== X-Gm-Message-State: AOAM533Tbe8dQ0HckjSe1nCuGbz9XqHmkK3AjvTWsSI0CaxdINHvDkeD Dg3CRzY4/Ic6AC3rO28c1S+fX0d815Qc8w== X-Google-Smtp-Source: ABdhPJx92/586tQyLeBYKM1/7kgi4UT7uV5ewRtBTkCldqS6aE23SzDix+8muyD6etNT7enKyhaG3w== X-Received: by 2002:a17:902:a503:b029:d6:d9d:f901 with SMTP id s3-20020a170902a503b02900d60d9df901mr3591781plq.54.1603817478598; Tue, 27 Oct 2020 09:51:18 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 1/3] tcg: Do not kill globals at conditional branches Date: Tue, 27 Oct 2020 09:51:12 -0700 Message-Id: <20201027165114.71508-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201027165114.71508-1-richard.henderson@linaro.org> References: <20201027165114.71508-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::1036; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1036.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) We can easily register allocate the entire extended basic block (in this case, the set of blocks connected by fallthru), simply by not discarding the register state at the branch. This does not help blocks starting with a label, as they are reached via a taken branch, and that would require saving the complete register state at the branch. Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Richard Henderson --- include/tcg/tcg-opc.h | 7 +++--- include/tcg/tcg.h | 4 +++- tcg/tcg.c | 55 +++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 60 insertions(+), 6 deletions(-) diff --git a/include/tcg/tcg-opc.h b/include/tcg/tcg-opc.h index e3929b80d2..67092e82c6 100644 --- a/include/tcg/tcg-opc.h +++ b/include/tcg/tcg-opc.h @@ -81,7 +81,7 @@ DEF(extract_i32, 1, 1, 2, IMPL(TCG_TARGET_HAS_extract_i32= )) DEF(sextract_i32, 1, 1, 2, IMPL(TCG_TARGET_HAS_sextract_i32)) DEF(extract2_i32, 1, 2, 1, IMPL(TCG_TARGET_HAS_extract2_i32)) =20 -DEF(brcond_i32, 0, 2, 2, TCG_OPF_BB_END) +DEF(brcond_i32, 0, 2, 2, TCG_OPF_BB_END | TCG_OPF_COND_BRANCH) =20 DEF(add2_i32, 2, 4, 0, IMPL(TCG_TARGET_HAS_add2_i32)) DEF(sub2_i32, 2, 4, 0, IMPL(TCG_TARGET_HAS_sub2_i32)) @@ -89,7 +89,8 @@ DEF(mulu2_i32, 2, 2, 0, IMPL(TCG_TARGET_HAS_mulu2_i32)) DEF(muls2_i32, 2, 2, 0, IMPL(TCG_TARGET_HAS_muls2_i32)) DEF(muluh_i32, 1, 2, 0, IMPL(TCG_TARGET_HAS_muluh_i32)) DEF(mulsh_i32, 1, 2, 0, IMPL(TCG_TARGET_HAS_mulsh_i32)) -DEF(brcond2_i32, 0, 4, 2, TCG_OPF_BB_END | IMPL(TCG_TARGET_REG_BITS =3D=3D= 32)) +DEF(brcond2_i32, 0, 4, 2, + TCG_OPF_BB_END | TCG_OPF_COND_BRANCH | IMPL(TCG_TARGET_REG_BITS =3D=3D= 32)) DEF(setcond2_i32, 1, 4, 1, IMPL(TCG_TARGET_REG_BITS =3D=3D 32)) =20 DEF(ext8s_i32, 1, 1, 0, IMPL(TCG_TARGET_HAS_ext8s_i32)) @@ -159,7 +160,7 @@ DEF(extrh_i64_i32, 1, 1, 0, IMPL(TCG_TARGET_HAS_extrh_i64_i32) | (TCG_TARGET_REG_BITS =3D=3D 32 ? TCG_OPF_NOT_PRESENT : 0)) =20 -DEF(brcond_i64, 0, 2, 2, TCG_OPF_BB_END | IMPL64) +DEF(brcond_i64, 0, 2, 2, TCG_OPF_BB_END | TCG_OPF_COND_BRANCH | IMPL64) DEF(ext8s_i64, 1, 1, 0, IMPL64 | IMPL(TCG_TARGET_HAS_ext8s_i64)) DEF(ext16s_i64, 1, 1, 0, IMPL64 | IMPL(TCG_TARGET_HAS_ext16s_i64)) DEF(ext32s_i64, 1, 1, 0, IMPL64 | IMPL(TCG_TARGET_HAS_ext32s_i64)) diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h index 8804a8c4a2..8ff9dad4ef 100644 --- a/include/tcg/tcg.h +++ b/include/tcg/tcg.h @@ -990,7 +990,7 @@ typedef struct TCGArgConstraint { =20 #define TCG_MAX_OP_ARGS 16 =20 -/* Bits for TCGOpDef->flags, 8 bits available. */ +/* Bits for TCGOpDef->flags, 8 bits available, all used. */ enum { /* Instruction exits the translation block. */ TCG_OPF_BB_EXIT =3D 0x01, @@ -1008,6 +1008,8 @@ enum { TCG_OPF_NOT_PRESENT =3D 0x20, /* Instruction operands are vectors. */ TCG_OPF_VECTOR =3D 0x40, + /* Instruction is a conditional branch. */ + TCG_OPF_COND_BRANCH =3D 0x80 }; =20 typedef struct TCGOpDef { diff --git a/tcg/tcg.c b/tcg/tcg.c index a8c28440e2..f49f1a7f35 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -2519,6 +2519,28 @@ static void la_global_sync(TCGContext *s, int ng) } } =20 +/* + * liveness analysis: conditional branch: all temps are dead, + * globals and local temps should be synced. + */ +static void la_bb_sync(TCGContext *s, int ng, int nt) +{ + la_global_sync(s, ng); + + for (int i =3D ng; i < nt; ++i) { + if (s->temps[i].temp_local) { + int state =3D s->temps[i].state; + s->temps[i].state =3D state | TS_MEM; + if (state !=3D TS_DEAD) { + continue; + } + } else { + s->temps[i].state =3D TS_DEAD; + } + la_reset_pref(&s->temps[i]); + } +} + /* liveness analysis: sync globals back to memory and kill. */ static void la_global_kill(TCGContext *s, int ng) { @@ -2795,6 +2817,8 @@ static void liveness_pass_1(TCGContext *s) /* If end of basic block, update. */ if (def->flags & TCG_OPF_BB_EXIT) { la_func_end(s, nb_globals, nb_temps); + } else if (def->flags & TCG_OPF_COND_BRANCH) { + la_bb_sync(s, nb_globals, nb_temps); } else if (def->flags & TCG_OPF_BB_END) { la_bb_end(s, nb_globals, nb_temps); } else if (def->flags & TCG_OPF_SIDE_EFFECTS) { @@ -2907,7 +2931,10 @@ static bool liveness_pass_2(TCGContext *s) nb_oargs =3D def->nb_oargs; =20 /* Set flags similar to how calls require. */ - if (def->flags & TCG_OPF_BB_END) { + if (def->flags & TCG_OPF_COND_BRANCH) { + /* Like reading globals: sync_globals */ + call_flags =3D TCG_CALL_NO_WRITE_GLOBALS; + } else if (def->flags & TCG_OPF_BB_END) { /* Like writing globals: save_globals */ call_flags =3D 0; } else if (def->flags & TCG_OPF_SIDE_EFFECTS) { @@ -3379,6 +3406,28 @@ static void tcg_reg_alloc_bb_end(TCGContext *s, TCGR= egSet allocated_regs) save_globals(s, allocated_regs); } =20 +/* + * At a conditional branch, we assume all temporaries are dead and + * all globals and local temps are synced to their location. + */ +static void tcg_reg_alloc_cbranch(TCGContext *s, TCGRegSet allocated_regs) +{ + sync_globals(s, allocated_regs); + + for (int i =3D s->nb_globals; i < s->nb_temps; i++) { + TCGTemp *ts =3D &s->temps[i]; + /* + * The liveness analysis already ensures that temps are dead. + * Keep tcg_debug_asserts for safety. + */ + if (ts->temp_local) { + tcg_debug_assert(ts->val_type !=3D TEMP_VAL_REG || ts->mem_coh= erent); + } else { + tcg_debug_assert(ts->val_type =3D=3D TEMP_VAL_DEAD); + } + } +} + /* * Specialized code generation for INDEX_op_movi_*. */ @@ -3730,7 +3779,9 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCG= Op *op) } } =20 - if (def->flags & TCG_OPF_BB_END) { + if (def->flags & TCG_OPF_COND_BRANCH) { + tcg_reg_alloc_cbranch(s, i_allocated_regs); + } else if (def->flags & TCG_OPF_BB_END) { tcg_reg_alloc_bb_end(s, i_allocated_regs); } else { if (def->flags & TCG_OPF_CALL_CLOBBER) { --=20 2.25.1 From nobody Wed Apr 16 15:36:26 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1603817808; cv=none; d=zohomail.com; s=zohoarc; b=I5o6s+xuWlD+jFdsPhk8rl9tcZxfV35ppbQ3LDaG/ow1qdLh7tt8WTE+xqYHtbDxAqNdOFKUkf/daiUx01lFny5BrdKO9qiCnFXBx7/IAk3sdjJz7ym73g68TMM1dANI0sUojuEkNDcbvTC99iVGL6pmdGwjstwP5DhT1v0nj9E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603817808; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=l4c7t48Ie241pwgULUUoEJnXqKB0sfr3ZrdrLJQD0q8=; b=e8Xdkvo0upjfj5yVdJpETt6qIWDU6LtSmNgeRdVe+sayMINYx69wcDMBlWxLlilOCR889/ReregUVsoLde3pwpEnl/+8gULF5EqhDsxQQYVC1DqkYdeCt4uSfYGrrNt5A02UvZlMvW/sMnXvqvxHH2pXCQkc+tIiXyFWwJ1YHxg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1603817808868280.4866512711634; Tue, 27 Oct 2020 09:56:48 -0700 (PDT) Received: from localhost ([::1]:42824 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kXSH9-0000TZ-Ui for importer@patchew.org; Tue, 27 Oct 2020 12:56:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56498) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kXSBx-0003KK-A3 for qemu-devel@nongnu.org; Tue, 27 Oct 2020 12:51:25 -0400 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]:40028) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kXSBu-0004Rf-9p for qemu-devel@nongnu.org; Tue, 27 Oct 2020 12:51:24 -0400 Received: by mail-pf1-x42e.google.com with SMTP id w21so1247529pfc.7 for ; Tue, 27 Oct 2020 09:51:21 -0700 (PDT) Received: from localhost.localdomain ([71.212.141.89]) by smtp.gmail.com with ESMTPSA id q16sm2955283pfj.117.2020.10.27.09.51.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Oct 2020 09:51:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=l4c7t48Ie241pwgULUUoEJnXqKB0sfr3ZrdrLJQD0q8=; b=CiHWkFYGtjvojIFuuJhgfB8hhCPzI8v3+crXsbMSfQN4lnr1NFHv4PHPC63sv3rN0k BchGrxwK7DljmRBtrun4Ykd7TAl1QzC5Cv3If2Tqyu3kixmNK9o0dAefln8w50TccJT4 ays/ZNdcr2FFrLTMmjobcYHksFxBnJ+AyPP65//UELNSE3DXM8lZ1l8dygOYrB2cC/Cg DHYOUiuZJ5zssTy7sSDMS3YotKHZIL+FsFq62hev9X+C5nJOOoSVe25GIrOneLxdojXX QHEZWirEcw3ese+WRUZXrg8rLtFli5LDl24mZO8Nrb0klbyCTS3lEVaDRvXTtPgYs+I7 gByA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=l4c7t48Ie241pwgULUUoEJnXqKB0sfr3ZrdrLJQD0q8=; b=einuG9DixxaXmaTDmKpgXUUpLs4L8h+AgzZfl4P3nsM8bOMZcUrIL9mqGwgCyZfhUk sBCZ5vQLpuWTMGn4z2Fwk8aM+vA21e7apiRP/mKO/iJPL50J1sQ6QLTay74Av2W2mHJ9 rn6xf8iFduyzAzXQu7E4iU/RCmXyNp9ABAftQokCv68DhSUlyTHxCVX3QB9/SFhvhZYI XJnTv0TYL1bnj6dk229riM5uxg78wdplArS9AIe/0THbK8gsu23S7RL9JGzCEp0ewSzj uvRLr3nnzVIMqjoU/5U6RoVV2p9ZZuP76sI2O6IGjalyiVWpFFkVEfJ2RdNw9eDQvz7y g5Zg== X-Gm-Message-State: AOAM530U9DH9Au7S7D+BUXAD71klLVHwrOlHr3TVIax+9Y1S3xAp5nfR OUsAEjCqvirbpPdYuT2VNY2ypjRsdEprEw== X-Google-Smtp-Source: ABdhPJzkZQGNXws9uH0UfuAa0mn7L/q7AbXG/1gskpG3XLdNJovUOFnLxGaOH66IPTs2Cb4tdCrOyg== X-Received: by 2002:a65:50c9:: with SMTP id s9mr2713518pgp.20.1603817480617; Tue, 27 Oct 2020 09:51:20 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 2/3] tcg/optimize: Flush data at labels not TCG_OPF_BB_END Date: Tue, 27 Oct 2020 09:51:13 -0700 Message-Id: <20201027165114.71508-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201027165114.71508-1-richard.henderson@linaro.org> References: <20201027165114.71508-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::42e; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42e.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) We can easily propagate temp values through the entire extended basic block (in this case, the set of blocks connected by fallthru), simply by not discarding the register state at the branch. Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Richard Henderson --- tcg/optimize.c | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index 220f4601d5..9952c28bdc 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -1484,29 +1484,30 @@ void tcg_optimize(TCGContext *s) } } } - goto do_reset_output; + /* fall through */ =20 default: do_default: - /* Default case: we know nothing about operation (or were unab= le - to compute the operation result) so no propagation is done. - We trash everything if the operation is the end of a basic - block, otherwise we only trash the output args. "mask" is - the non-zero bits mask for the first output arg. */ - if (def->flags & TCG_OPF_BB_END) { - bitmap_zero(temps_used.l, nb_temps); - } else { - do_reset_output: - for (i =3D 0; i < nb_oargs; i++) { - reset_temp(op->args[i]); - /* Save the corresponding known-zero bits mask for the - first output argument (only one supported so far). = */ - if (i =3D=3D 0) { - arg_info(op->args[i])->mask =3D mask; - } + /* + * Default case: we know nothing about operation (or were unab= le + * to compute the operation result) so no propagation is done. + */ + for (i =3D 0; i < nb_oargs; i++) { + reset_temp(op->args[i]); + /* + * Save the corresponding known-zero bits mask for the + * first output argument (only one supported so far). + */ + if (i =3D=3D 0) { + arg_info(op->args[i])->mask =3D mask; } } break; + + case INDEX_op_set_label: + /* Trash everything at the start of a new extended bb. */ + bitmap_zero(temps_used.l, nb_temps); + break; } =20 /* Eliminate duplicate and redundant fence instructions. */ --=20 2.25.1 From nobody Wed Apr 16 15:36:26 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1603817672; cv=none; d=zohomail.com; s=zohoarc; b=ExYWts1QcZQrI2vAUnQCfwXs5SEljmpTmFYMvEGm5QQ7W/a1o9gwW8KIMGglLAJMy+l3lKY4c7NI4STLKEFqddp59RBjQhUxWK15ieWWePwjlg2QsmI1KH/cNZmDqbdDLXTbOHPCsfblDy/PenIFtbEbyRusdoW94o+yaBQNRG8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603817672; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=SJ7E8JqgOLx2ZEpYUNi3ic5vKG5NWEQV9qbwhc56KHQ=; b=hBaD7BDDDPWLQK4oFDxIpZQ4bMdd1CRcC+AZLC8ZYVbEIB0jfccREGD+4Y7ZYxqbaRVSOnwSmRA96qLZ1EavxE5vnXRUMeXTREX9cIYszLTzTBVlGBPs46XdC+SyGgGXSwWIAXMFCyqP2eAtK0dfS2naQ23zCZJIYCGcsixJvlk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1603817672366690.9717691784236; Tue, 27 Oct 2020 09:54:32 -0700 (PDT) Received: from localhost ([::1]:37820 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kXSEx-0006ha-9I for importer@patchew.org; Tue, 27 Oct 2020 12:54:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56532) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kXSC0-0003NR-BU for qemu-devel@nongnu.org; Tue, 27 Oct 2020 12:51:28 -0400 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]:43264) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kXSBv-0004Ro-Je for qemu-devel@nongnu.org; Tue, 27 Oct 2020 12:51:27 -0400 Received: by mail-pl1-x62e.google.com with SMTP id o9so1054465plx.10 for ; Tue, 27 Oct 2020 09:51:23 -0700 (PDT) Received: from localhost.localdomain ([71.212.141.89]) by smtp.gmail.com with ESMTPSA id q16sm2955283pfj.117.2020.10.27.09.51.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Oct 2020 09:51:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SJ7E8JqgOLx2ZEpYUNi3ic5vKG5NWEQV9qbwhc56KHQ=; b=fPualdzQSWBq+Cbb+/WPwqu/ApZ1ZDK3IVAnh8cfGam3aUKZ592jzZtZvdXO3eH39J eU61iCSp6ptAYZmuYHTs6TnU/rRNh/0a5nKtuSHWlNPqRJTyaceiB0GZCg2A74VnKhSY e9xyNDrfPSFKdhYJ0Rl+H7Vn9l1tCAp3AJfvhscLpC3NTHW1sRn4u8l1SMZPHuk3tF7q RwFwZiYTrZTJByUJl1URPrscDwdRbChqOaAfMaBH7aKjki1lox0/wke/1bAqvoVn75IZ 9iDe06s9ctSNvXJaAHQFEN3O5ghfLmBbB8oyMcyr5Z1wINnXLiTliopdWr2Wo0xwNTqD I2Vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SJ7E8JqgOLx2ZEpYUNi3ic5vKG5NWEQV9qbwhc56KHQ=; b=KVzFuCKAAdmd9qmHu2DdDwHugrSBpKZsfclWv4KInlAtCEsKWEScFKgTcU3BI8DDOP IuVHpmWk1Db/UKIi0XgDpffYGLzmb9fvpRvx/Bf6I1EnMzaTPvwXRcWM20dBFAqnIMlG h4aNUyr8cM6lPGJPNSAQ49M0I+VTNV/D9w8bHJ1YuaTqYUEaDVm7x/+wT+0of5JZpUE5 SCswNzo9XTdiCA3Jb7xhh6ea4nATMZ+BemNiMO19c6h+XEmuI1IR2MvtcF7mcSAvMA4O jNGNlgJRacS/s71Z/mV/kbT5ty47j+jKifKgmruSJN9SHyruU2zpxti/LWDo7OIxjKbe dTcA== X-Gm-Message-State: AOAM5310KFO+In8uwdhXvoGGN6F9rGTHJ0oPKBB9KfwL8NcCvwStaBET fXzD+ABjqm+Oildovw6OkdpSOi7m9TQZQQ== X-Google-Smtp-Source: ABdhPJzjgihkqa6PvHlMUcYfxsWLQbAqqZmnnceeTOMpErPIBKZkavL6ob0UsKxOhvtT20OUhC3Rsw== X-Received: by 2002:a17:90a:a898:: with SMTP id h24mr2843421pjq.179.1603817481803; Tue, 27 Oct 2020 09:51:21 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 3/3] accel/tcg: Add CPU_LOG_EXEC tracing for cpu_io_recompile() Date: Tue, 27 Oct 2020 09:51:14 -0700 Message-Id: <20201027165114.71508-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201027165114.71508-1-richard.henderson@linaro.org> References: <20201027165114.71508-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::62e; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62e.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" From: Peter Maydell When using -icount, it's useful for the CPU_LOG_EXEC logging to include information about when cpu_io_recompile() was called, because it alerts the reader of the log that the tracing of a previous TB execution may not actually correspond to an actually executed instruction. For instance if you're using -icount and also -singlestep then a guest instruction that makes an IO access appears in two "Trace" lines, once in a TB that triggers the cpu_io_recompile() and then again in the TB that actually executes. (This is a similar reason to why the "Stopped execution of TB chain before..." logging in cpu_tb_exec() is helpful when trying to track execution flow in the logs.) Signed-off-by: Peter Maydell Message-Id: <20201013122658.4620-1-peter.maydell@linaro.org> Signed-off-by: Richard Henderson --- accel/tcg/translate-all.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index d76097296d..4572b4901f 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -2267,6 +2267,10 @@ void cpu_io_recompile(CPUState *cpu, uintptr_t retad= dr) tb_destroy(tb); } =20 + qemu_log_mask_and_addr(CPU_LOG_EXEC, tb->pc, + "cpu_io_recompile: rewound execution of TB to " + TARGET_FMT_lx "\n", tb->pc); + /* TODO: If env->pc !=3D tb->pc (i.e. the faulting instruction was not * the first in the TB) then we end up generating a whole new TB and * repeating the fault, which is horribly inefficient. --=20 2.25.1