From patchwork Wed Oct 25 07:26:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 737858 Delivered-To: patch@linaro.org Received: by 2002:adf:f842:0:b0:32d:baff:b0ca with SMTP id d2csp150761wrq; Wed, 25 Oct 2023 00:34:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF73EKuFa8W0hr/Ee39UujoISHPcQpiLraalbt0jpTOPghodwsh8FJDgTRE2wlxURPMl8g3 X-Received: by 2002:a05:6214:d87:b0:66d:2491:6e69 with SMTP id e7-20020a0562140d8700b0066d24916e69mr13954064qve.36.1698219240085; Wed, 25 Oct 2023 00:34:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698219240; cv=none; d=google.com; s=arc-20160816; b=eulSNrgnpwjq3t+MbbaS/TA1n0lI30MX33DVCcu1ulhSBocTVZspdQxtnnkcHvXNYO 8tFLPyVRJp5FO3UZpFad3E35s4zusTBW3ezaBYPlCrjImoLkfO+oRA0GIMOOUH+pIfLG qF7A/PTK0HpG5LJkt6nCopvCExc8wBjH8HoZiTAP3nBPXKZgeSjqw/Cb98+mNcU+uZaN oqAcWyC2wWEmGf1xehJ7Evcz1ZzCEXTZMcpR7sIxIx4+GoO0fN+BKEtEMqKcCQ/aHRzM OWK5dLms0lmSYgP7bIC/9eF6XjQJkvKGnQFuXDYixKYlF/S/8eMcl1QG/bh7Dqxln8Al xFJg== 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:cc:to :from:dkim-signature; bh=D1jMbpp1weXZkSHBUh0Jn0kijypmzVFb4f/5Y0tU+kg=; fh=ycigHkwOPieh2u5PmcA89sNk/qPD1ZkdDlL8Mchfvw8=; b=Dhb+WAg2EGR4aJM5txJhtf6iw0a2ctXYSv7Cpt+Y5iS29+V5IdRjIJX8pslNSguLI6 lGiBev1EbdZ/hVyOMyf1Sj7jts+PzLFMVsMVY+nGCMYmarLq0zlHgEQw5QgA6O1ehBhX d9e2xRyBsqTsCt+mjczaxzkQpTPCX7AenYylfDwc4WsT+w+JEtkvb6wEz1MaQIOH8yxj ppmEq330DVq4P5G+vAyvml8zV/3EkAnNfJB+S0Af6FAWFAlr9M0mtIJKxMMSeNb4uLJu 6Gn3BsIloIN4I0WJGCSHeWoObDglF3+D4NJZWLm9uFx7gdDQ37D0/c/5xEJvjLaWX7vj Rgxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sC3UJEMw; 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 dw14-20020a0562140a0e00b0065cfc03bc17si7973924qvb.7.2023.10.25.00.33.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 25 Oct 2023 00:34:00 -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=sC3UJEMw; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qvYIV-0000Cc-1c; Wed, 25 Oct 2023 03:27:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qvYIO-00009C-UY for qemu-devel@nongnu.org; Wed, 25 Oct 2023 03:27:18 -0400 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qvYIM-0004eL-TL for qemu-devel@nongnu.org; Wed, 25 Oct 2023 03:27:16 -0400 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1c9bf22fe05so35210245ad.2 for ; Wed, 25 Oct 2023 00:27:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698218833; x=1698823633; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=D1jMbpp1weXZkSHBUh0Jn0kijypmzVFb4f/5Y0tU+kg=; b=sC3UJEMwG0ttGeALGwwds6rcFUjAXl9Vu+WeXo52Sunz4+hVgLWDzNFyxCbp0LxoMh 5ym1SCZY3lutJcpgEpNC3lfylthjp4B4fFCEKgbZupioF0glRvSL1Xsb67hGavXiy/DG PaF0nqFRFby0OUtOXU6rY3wvaAd2mVvMbu2Gp4tqh3NzyS/6xNRA60V5Rs3WtEo+XTQS zeLmcvn9Ma8mc9DPrjAeCwtvUC8Wx9dSPSDX7fFwoDJ4LY/lQMVzZNd2lknpzF+x96mU lHs6RnoI7XMcPE6Bw9SNbC4/eqVvZaV3+XAZ/Xrb+0qSA2hBGLuvZAJUqIh+fV9zdila xxvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698218833; x=1698823633; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=D1jMbpp1weXZkSHBUh0Jn0kijypmzVFb4f/5Y0tU+kg=; b=r3n+aara03lzdNjHp+M+Y0H9rFbOZjg5QgjNz0sS5L6dKqEMGRjcoqhKMscWOObBBY HW/bjUl/VHpnKHYpfcAh7tlAVYipa7POLyHxeP8q27HD3uLeuGMT/fIP4HAlfLwMFG+i Y6rb130ER+YL0TG1kxMklTH6dGwrJnwaaFjR+n55jub52sREMRU309cAdQI3La4TqyZZ iRFIUh7XlK1v9RcziuPNhit4ZuLxnZncw3qQ3s3F0DSK4mjUxrOsvq6MTtCKoaO/SdPd EFR+mdISgk4JJvowhqhdbbvhOtls2g0XapfbAeN5pd2SsnREnv2gjPbuMm9kKhDTUsP0 cYag== X-Gm-Message-State: AOJu0Ywc1sY4kr/i8gYOrx+b8f8OsjjA73uu4nRHySX14DYOLRSDIzPz 4ltuFxOk0OGouwaASHH3owae3Cla36C0PVkhW40= X-Received: by 2002:a17:902:ea0f:b0:1c8:9bc6:2a09 with SMTP id s15-20020a170902ea0f00b001c89bc62a09mr14134277plg.15.1698218833521; Wed, 25 Oct 2023 00:27:13 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id ji5-20020a170903324500b001b06c106844sm8578661plb.151.2023.10.25.00.27.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 00:27:13 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org Subject: [PATCH 05/29] tcg/optimize: Split out arg_new_constant Date: Wed, 25 Oct 2023 00:26:43 -0700 Message-Id: <20231025072707.833943-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231025072707.833943-1-richard.henderson@linaro.org> References: <20231025072707.833943-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::633; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x633.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.29 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-bounces+patch=linaro.org@nongnu.org Fixes a bug wherein raw uses of tcg_constant_internal do not have their TempOptInfo initialized. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- tcg/optimize.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index 76be0fc337..2f2d1c3001 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -237,6 +237,21 @@ static bool args_are_copies(TCGArg arg1, TCGArg arg2) return ts_are_copies(arg_temp(arg1), arg_temp(arg2)); } +static TCGArg arg_new_constant(OptContext *ctx, uint64_t val) +{ + TCGType type = ctx->type; + TCGTemp *ts; + + if (type == TCG_TYPE_I32) { + val = (int32_t)val; + } + + ts = tcg_constant_internal(type, val); + init_ts_info(ctx, ts); + + return temp_arg(ts); +} + static bool tcg_opt_gen_mov(OptContext *ctx, TCGOp *op, TCGArg dst, TCGArg src) { TCGTemp *dst_ts = arg_temp(dst); @@ -293,16 +308,8 @@ 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) { - 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)); + return tcg_opt_gen_mov(ctx, op, dst, arg_new_constant(ctx, val)); } static uint64_t do_constant_folding_2(TCGOpcode op, uint64_t x, uint64_t y) @@ -1340,7 +1347,7 @@ static bool fold_deposit(OptContext *ctx, TCGOp *op) op->opc = and_opc; op->args[1] = op->args[2]; - op->args[2] = temp_arg(tcg_constant_internal(ctx->type, mask)); + op->args[2] = arg_new_constant(ctx, mask); ctx->z_mask = mask & arg_info(op->args[1])->z_mask; return false; } @@ -1350,7 +1357,7 @@ static bool fold_deposit(OptContext *ctx, TCGOp *op) uint64_t mask = deposit64(-1, op->args[3], op->args[4], 0); op->opc = and_opc; - op->args[2] = temp_arg(tcg_constant_internal(ctx->type, mask)); + op->args[2] = arg_new_constant(ctx, mask); ctx->z_mask = mask & arg_info(op->args[1])->z_mask; return false; }