From patchwork Mon Aug 30 06:24:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 504325 Delivered-To: patch@linaro.org Received: by 2002:a02:8629:0:0:0:0:0 with SMTP id e38csp1526186jai; Sun, 29 Aug 2021 23:58:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx5ON1DaUUPGzjgU0i5feUFXvPu8sv88gkyvTCqMkzAN1nVEeXVcI1mTRGu2HN3BPVnPppU X-Received: by 2002:a25:c305:: with SMTP id t5mr21257248ybf.410.1630306686166; Sun, 29 Aug 2021 23:58:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630306686; cv=none; d=google.com; s=arc-20160816; b=DfwomJclAAGLLtqsHei8hnk3Wc4//Yej0sezKB/fFI0uh1J7q8gtPWl72OaKfu7133 cL7YAegsjHGeFPNu/UYXbixkyzx1iCqb2MKGv9okCJDi+SAiDjA5fse0J2EzEj9Ygpz1 a4VR6XZyG5OUfJi9EyGFitzE7qPjog2Y0KWb21hVpb2mCAr2d8w5o4bJL8O83Z1FiPaX x7Xos+KyFpefvpfwTDSaiWo7XU/nA4r8e24jwvjUqIzjg5P+MnD3YovnfgbAGzSHiNti 76Jvykqdbc8UAoCOd7KkeoLRy05WUthB+KDMSs5kVJnrwwpdre2tzCVubWM+IdjMXhbd NTvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=BNq1ox8+rWVzst3iv6VIsSYBSdVmvqvfqZdAkCFh17E=; b=sABh7uur7iArxZDl94K3YzlCoIYh0pEWH2m6F8YKh0T9OMYRbqTaOL0FPyIgyNpO4m /bNLc2gN/gO+FeKsH5IjgEvXatPy9tJbe0k9tg/MMYRJYRM/lYb8iayBZUEpk2a+WRnD UK0n0iy+vvZhnBCqdmov/W9Fm7FC5bn0yeEwnD8q7jeKDPSpcv9QJ3vRnwHc1b7bw3sa m4E9Bd7YViUjAeL/9+Jk6iv2AU6TeCpF42lpzhIt8gDYN60LCNn0cyt9UjmfG2/WTnS4 nk752c0guS2QwrMZz/CmUkLmjPWbSLSQ3foL51sEhmTVpROGV0f1JOkGnjgeoIWKEjSN 9jyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zOKEbGjc; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id q10si15242248ybj.401.2021.08.29.23.58.06 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 29 Aug 2021 23:58:06 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zOKEbGjc; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:59376 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mKbF7-0002tl-Ij for patch@linaro.org; Mon, 30 Aug 2021 02:58:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47140) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mKamP-0003Df-VS for qemu-devel@nongnu.org; Mon, 30 Aug 2021 02:28:27 -0400 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]:35348) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mKamM-0001oA-7g for qemu-devel@nongnu.org; Mon, 30 Aug 2021 02:28:24 -0400 Received: by mail-pl1-x632.google.com with SMTP id x16so6285088pll.2 for ; Sun, 29 Aug 2021 23:28:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=BNq1ox8+rWVzst3iv6VIsSYBSdVmvqvfqZdAkCFh17E=; b=zOKEbGjcZUKdtyWroSTOS9W8p/2XCePlrJtl/bU48rkWcIM8BnBgKkqzNrVTDLfq15 WfJ/HyMJakhtjtNXTEfhLbA26T0amxvmbRWCQQaiDJL2IQprRaUR2mtGh/uJmRxjgjmr iEaPun2JjcY/BMHujwWNjVuULyo19EcUMSCPPmW4r3pdadbu1xiHxZRxHcb2Kq89WR2+ 1UV11LMij05OcvM2m5Tcd4E2YZkuC175j1RZ8AcltL9IKGAW+UkGk39G8ChwA6hSES5w c7L+tzOMbrzqfLPP66TliEeCzcenQDdgvDX50VuHdIsqRZPbyo10qiPS7jf/HC9htc6R fQCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BNq1ox8+rWVzst3iv6VIsSYBSdVmvqvfqZdAkCFh17E=; b=OsmmSZAYUV6Fsoz0eTI4wR7WMpfA98TH681pyhZjdIvzajO2F1KEOcBxXFDRKeCiGv vIkOhihGKDfTFuf0X3Z+Eg4Bn6XdM9F8y+KSJfSkZBXiCRyKWNja46i8jwClc98jOz8a GggGNIc5A12uzjy22J1VPBjeMKk3W/8IKGO0q8DYeY0wjij+OYM/rQ74c50DoGwuSpiz zU9LNsCRszyJ9Bqnat2chCR852nZhI/5qoUodvW3kbuJFlNhXO3h0PfsQFBAWPiruraq o0b+It9bd9G4pfaIS2h7St16Gu09Ty4L9cNP8Q2ix1P8RA7IjlHLnLmwRIjU0PzjGPZL hfMA== X-Gm-Message-State: AOAM533F8aRsaFag9bfTBBaUbOoyuwZjGuPbQX7X44ouCHFF1sjfhkvK jUXOfYEjSUDFVtpLznlRDlIyOzHJ72mXUw== X-Received: by 2002:a17:90a:9511:: with SMTP id t17mr38092884pjo.194.1630304900843; Sun, 29 Aug 2021 23:28:20 -0700 (PDT) Received: from localhost.localdomain (174-21-72-39.tukw.qwest.net. [174.21.72.39]) by smtp.gmail.com with ESMTPSA id o6sm13337072pjk.4.2021.08.29.23.28.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Aug 2021 23:28:20 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 43/48] tcg/optimize: Stop forcing z_mask to "garbage" for 32-bit values Date: Sun, 29 Aug 2021 23:24:46 -0700 Message-Id: <20210830062451.639572-44-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210830062451.639572-1-richard.henderson@linaro.org> References: <20210830062451.639572-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::632; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x632.google.com 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This "garbage" setting pre-dates the addition of the type changing opcodes INDEX_op_ext_i32_i64, INDEX_op_extu_i32_i64, and INDEX_op_extr{l,h}_i64_i32. So now we have a definitive points at which to adjust z_mask to eliminate such bits from the 32-bit operands. Signed-off-by: Richard Henderson --- tcg/optimize.c | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) -- 2.25.1 diff --git a/tcg/optimize.c b/tcg/optimize.c index 6feaf905e7..334639339b 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -123,10 +123,6 @@ static void init_ts_info(OptContext *ctx, TCGTemp *ts) ti->is_const = true; ti->val = ts->val; ti->z_mask = ts->val; - if (TCG_TARGET_REG_BITS > 32 && ts->type == TCG_TYPE_I32) { - /* High bits of a 32-bit quantity are garbage. */ - ti->z_mask |= ~0xffffffffull; - } } else { ti->is_const = false; ti->z_mask = -1; @@ -191,7 +187,6 @@ static bool tcg_opt_gen_mov(OptContext *ctx, TCGOp *op, TCGArg dst, TCGArg src) TCGTemp *src_ts = arg_temp(src); TempOptInfo *di; TempOptInfo *si; - uint64_t z_mask; TCGOpcode new_op; if (ts_are_copies(dst_ts, src_ts)) { @@ -223,12 +218,7 @@ static bool tcg_opt_gen_mov(OptContext *ctx, TCGOp *op, TCGArg dst, TCGArg src) op->args[0] = dst; op->args[1] = src; - z_mask = si->z_mask; - if (TCG_TARGET_REG_BITS > 32 && new_op == INDEX_op_mov_i32) { - /* High bits of the destination are now garbage. */ - z_mask |= ~0xffffffffull; - } - di->z_mask = z_mask; + di->z_mask = si->z_mask; if (src_ts->type == dst_ts->type) { TempOptInfo *ni = ts_info(si->next_copy); @@ -246,9 +236,14 @@ static bool tcg_opt_gen_mov(OptContext *ctx, TCGOp *op, TCGArg dst, TCGArg src) static bool tcg_opt_gen_movi(OptContext *ctx, TCGOp *op, TCGArg dst, uint64_t val) { - /* Convert movi to mov with constant temp. */ - TCGTemp *tv = tcg_constant_internal(ctx->type, val); + TCGTemp *tv; + if (ctx->type == TCG_TYPE_I32) { + val = (int32_t)val; + } + + /* Convert movi to mov with constant temp. */ + tv = tcg_constant_internal(ctx->type, val); init_ts_info(ctx, tv); return tcg_opt_gen_mov(ctx, op, dst, temp_arg(tv)); } @@ -707,14 +702,16 @@ static bool fold_masks(OptContext *ctx, TCGOp *op) uint64_t z_mask = ctx->z_mask; /* - * 32-bit ops generate 32-bit results. For the result is zero test - * below, we can ignore high bits, but for further optimizations we - * need to record that the high bits contain garbage. + * 32-bit ops generate 32-bit results, which for the purpose of + * simplifying tcg are sign-extended. Certainly that's how we + * represent our constants elsewhere. Note that the bits will + * be reset properly for a 64-bit value when encountering the + * type changing opcodes. */ if (ctx->type == TCG_TYPE_I32) { - ctx->z_mask |= MAKE_64BIT_MASK(32, 32); - a_mask &= MAKE_64BIT_MASK(0, 32); - z_mask &= MAKE_64BIT_MASK(0, 32); + a_mask = (int32_t)a_mask; + z_mask = (int32_t)z_mask; + ctx->z_mask = z_mask; } if (z_mask == 0) {